Search in sources :

Example 1 with Field2d

use of edu.wpi.first.wpilibj.smartdashboard.Field2d in project FRC2022-Rapid-React by BitBucketsFRC4183.

the class Robot method robotInit.

/**
 * This function is run when the robot is first started up and should be used
 * for any
 * initialization code.
 */
@Override
public void robotInit() {
    this.config = new Config();
    this.buttons = new Buttons();
    this.field = new Field2d();
    this.autonomousPathChooser.addOption("Nothing", AutonomousPath.NOTHING);
    this.autonomousPathChooser.addOption("Hardcoded: Shoot Preload, Drive Back", AutonomousPath.HARDCODED_SHOOT_DRIVE_BACK);
    this.autonomousPathChooser.addOption("Hardcoded: Shoot Preload, Drive Back and Shoot Loaded", AutonomousPath.HARDCODED_SHOOT_DRIVE_BACK_AND_SHOOT_HIGH);
    this.autonomousPathChooser.addOption("Hardcoded: Shoot Preload, Drive Back and Shoot Loaded Low", AutonomousPath.HARDCODED_SHOOT_DRIVE_BACK_AND_SHOOT_LOW);
    this.autonomousPathChooser.addOption("PathPlanner: Drive Backwards", AutonomousPath.PATH_PLANNER_DRIVE_BACKWARDS);
    this.autonomousPathChooser.addOption("PathPlanner: Shoot Preload and Drive Backwards", AutonomousPath.PATH_PLANNER_SHOOT_AND_DRIVE_BACKWARDS);
    this.autonomousPathChooser.addOption("PathPlanner: Shoot Preload, Intake Two Balls", AutonomousPath.PATH_PLANNER_SHOOT_INTAKE_TWO_BALLS);
    this.autonomousPathChooser.addOption("PathPlanner: Main - No Terminal", AutonomousPath.MAIN_NO_TERMINAL);
    this.autonomousPathChooser.addOption("PathPlanner: Main - With Terminal", AutonomousPath.MAIN_WITH_TERMINAL);
    this.autonomousPathChooser.setDefaultOption("Default (Nothing)", AutonomousPath.NOTHING);
    SmartDashboard.putData("Autonomous Path Chooser", this.autonomousPathChooser);
    // Add Subsystems Here
    if (config.enableAutonomousSubsystem) {
        this.robotSubsystems.add(autonomousSubsystem = new AutonomousSubsystem(this.config));
    }
    if (config.enableRGBSubsystem) {
        this.robotSubsystems.add(rgbSubsystem = new RGBSubsystem(this.config));
    }
    if (config.enableDriveSubsystem) {
        this.robotSubsystems.add(drivetrainSubsystem = new DrivetrainSubsystem(this.config));
    }
    if (config.enableIntakeSubsystem) {
        this.robotSubsystems.add(intakeSubsystem = new IntakeSubsystem(this.config));
    }
    if (config.enableShooterSubsystem) {
        this.robotSubsystems.add(shooterSubsystem = new ShooterSubsystem(this.config));
    }
    if (config.enableClimberSubsystem) {
        this.robotSubsystems.add(climberSubsystem = new ClimberSubsystem(this.config));
    }
    // create a new field to update
    SmartDashboard.putData("Field", field);
    // Configure the button bindings
    this.configureButtonBindings();
    // Subsystem Initialize Loop
    if (System.getenv().containsKey("CI")) {
        this.robotSubsystems.add(new LogTestSubsystem(this.config));
        this.robotSubsystems.add(new SimulatorTestSubsystem(this.config));
    }
    this.robotSubsystems.add(new SetModeTestSubsystem(this.config));
    // Subsystem Initialize Loop
    this.robotSubsystems.forEach(BitBucketsSubsystem::init);
}
Also used : Config(frc.robot.config.Config) Field2d(edu.wpi.first.wpilibj.smartdashboard.Field2d) SimulatorTestSubsystem(frc.robot.simulator.SimulatorTestSubsystem) SetModeTestSubsystem(frc.robot.simulator.SetModeTestSubsystem)

Example 2 with Field2d

use of edu.wpi.first.wpilibj.smartdashboard.Field2d in project Entropy2022 by Team138Entropy.

the class TrajectoryFollower method init.

private void init() {
    // Create and push Field2d to SmartDashboard.
    mField = new Field2d();
    SmartDashboard.putData("Autonomous Field", mField);
}
Also used : Field2d(edu.wpi.first.wpilibj.smartdashboard.Field2d)

Example 3 with Field2d

use of edu.wpi.first.wpilibj.smartdashboard.Field2d in project RoboCode2022 by HarkerRobo.

the class Robot method robotInit.

/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code. It corrects the starting rotation motors
 * using CAN coders but doesn't move the motors, only setting their sensor positions.
 */
@Override
public void robotInit() {
    Limelight.setLEDS(false);
    pd = new PowerDistribution();
    pd.setSwitchableChannel(false);
    field = new Field2d();
    SmartDashboard.putData(field);
    // new Compressor(PneumaticsModuleType.REVPH).disable();
    // default commands are commands that are always running on the robot
    CommandScheduler.getInstance().setDefaultCommand(Drivetrain.getInstance(), new SwerveManual());
    CommandScheduler.getInstance().setDefaultCommand(Indexer.getInstance(), new IndexerManual());
    CommandScheduler.getInstance().setDefaultCommand(Intake.getInstance(), new IntakeManual());
    CommandScheduler.getInstance().setDefaultCommand(Hood.getInstance(), new HoodManual());
    CommandScheduler.getInstance().setDefaultCommand(Climber.getInstance(), new ClimberManual());
    Drivetrain.getInstance().readCANCoders();
    new Notifier(() -> Drivetrain.getInstance().readCANCoders()).startSingle(5);
    // CommandScheduler.getInstance().setDefaultCommand(Shooter.getInstance(), new ShooterManual());
    // OI.getInstance();
    SmartDashboard.putNumber("desired velocity", 0);
    SmartDashboard.putNumber("desired hood angle", 0.5);
    SmartDashboard.putNumber("desired angle", 90);
    SmartDashboard.putNumber("intake RPS", 0.1);
    SmartDashboard.putNumber("desired hood pos", 0);
    SmartDashboard.putNumber("hood P", HoodManual.HOOD_KP);
    SmartDashboard.putNumber("hood I", HoodManual.HOOD_KI);
    SmartDashboard.putNumber("hood D", HoodManual.HOOD_KD);
    SmartDashboard.putNumber("hood izone", HoodManual.HOOD_IZONE);
// DoubleSolenoid pressure = new DoubleSolenoid(PneumaticsModuleType.REVPH, 0, 4);
// pressure.set(DoubleSolenoid.Value.kForward);
// NetworkTableInstance.getDefault().setUpdateRate(0.02);
}
Also used : ClimberManual(frc.robot.commands.climber.ClimberManual) IndexerManual(frc.robot.commands.indexer.IndexerManual) IntakeManual(frc.robot.commands.intake.IntakeManual) HoodManual(frc.robot.commands.hood.HoodManual) PowerDistribution(edu.wpi.first.wpilibj.PowerDistribution) SwerveManual(frc.robot.commands.drivetrain.SwerveManual) Field2d(edu.wpi.first.wpilibj.smartdashboard.Field2d) Notifier(edu.wpi.first.wpilibj.Notifier)

Example 4 with Field2d

use of edu.wpi.first.wpilibj.smartdashboard.Field2d in project FRC_Rapid_React_2022 by CommandoRobotics.

the class FollowTrajectoryCommand method initialize.

// Called when the command is initially scheduled.
@Override
public void initialize() {
    var initialState = m_trajectory.sample(0);
    var initialXVelocity = initialState.velocityMetersPerSecond * initialState.poseMeters.getRotation().getCos();
    var initialYVelocity = initialState.velocityMetersPerSecond * initialState.poseMeters.getRotation().getSin();
    m_prevSpeeds = m_kinematics.toWheelSpeeds(new ChassisSpeeds(initialXVelocity, initialYVelocity, 0.0));
    // Post the current trajectory to the Field2d object
    Field2d field = (Field2d) SmartDashboard.getData("Field");
    field.getObject("Current Robot Trajectory").setTrajectory(m_trajectory);
    m_timer.reset();
    m_timer.start();
}
Also used : Field2d(edu.wpi.first.wpilibj.smartdashboard.Field2d) ChassisSpeeds(edu.wpi.first.math.kinematics.ChassisSpeeds)

Aggregations

Field2d (edu.wpi.first.wpilibj.smartdashboard.Field2d)4 ChassisSpeeds (edu.wpi.first.math.kinematics.ChassisSpeeds)1 Notifier (edu.wpi.first.wpilibj.Notifier)1 PowerDistribution (edu.wpi.first.wpilibj.PowerDistribution)1 ClimberManual (frc.robot.commands.climber.ClimberManual)1 SwerveManual (frc.robot.commands.drivetrain.SwerveManual)1 HoodManual (frc.robot.commands.hood.HoodManual)1 IndexerManual (frc.robot.commands.indexer.IndexerManual)1 IntakeManual (frc.robot.commands.intake.IntakeManual)1 Config (frc.robot.config.Config)1 SetModeTestSubsystem (frc.robot.simulator.SetModeTestSubsystem)1 SimulatorTestSubsystem (frc.robot.simulator.SimulatorTestSubsystem)1