nettoyage
This commit is contained in:
		@@ -43,85 +43,85 @@ import frc.robot.subsystems.Limelight3G;
 | 
				
			|||||||
import frc.robot.subsystems.Pince;
 | 
					import frc.robot.subsystems.Pince;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class RobotContainer {
 | 
					public class RobotContainer {
 | 
				
			||||||
    private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
 | 
					  private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
 | 
				
			||||||
    private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond); // 3/4 of a rotation per second max angular velocity
 | 
					  private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond); // 3/4 of a rotation per second max angular velocity
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Setting up bindings for necessary control of the swerve drive platform */
 | 
					  /* Setting up bindings for necessary control of the swerve drive platform */
 | 
				
			||||||
    private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
 | 
					  private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
 | 
				
			||||||
            .withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1) // Add a 10% deadband
 | 
					    .withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1) // Add a 10% deadband
 | 
				
			||||||
            .withDriveRequestType(DriveRequestType.OpenLoopVoltage); // Use open-loop control for drive motors
 | 
					    .withDriveRequestType(DriveRequestType.OpenLoopVoltage); // Use open-loop control for drive motors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final Telemetry logger = new Telemetry(MaxSpeed);
 | 
					  private final Telemetry logger = new Telemetry(MaxSpeed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final CommandXboxController manette1 = new CommandXboxController(0);
 | 
					  private final CommandXboxController manette1 = new CommandXboxController(0);
 | 
				
			||||||
    private final CommandXboxController manette2 = new CommandXboxController(1);
 | 
					  private final CommandXboxController manette2 = new CommandXboxController(1);
 | 
				
			||||||
   
 | 
					  
 | 
				
			||||||
    public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();
 | 
					  public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();
 | 
				
			||||||
    Elevateur elevateur = new Elevateur();
 | 
					  Elevateur elevateur = new Elevateur();
 | 
				
			||||||
    Pince pince = new Pince();
 | 
					  Pince pince = new Pince();
 | 
				
			||||||
    ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY);
 | 
					  ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY);
 | 
				
			||||||
    PinceManuel pinceManuel = new PinceManuel(pince);
 | 
					  PinceManuel pinceManuel = new PinceManuel(pince);
 | 
				
			||||||
    PinceManuel2 pinceManuel2 = new PinceManuel2(pince);
 | 
					  PinceManuel2 pinceManuel2 = new PinceManuel2(pince);
 | 
				
			||||||
    private final SendableChooser<Command> autoChooser;
 | 
					  private final SendableChooser<Command> autoChooser;
 | 
				
			||||||
    Bougie bougie = new Bougie();
 | 
					  Bougie bougie = new Bougie();
 | 
				
			||||||
    Limelight3G limelight3g = new Limelight3G();
 | 
					  Limelight3G limelight3g = new Limelight3G();
 | 
				
			||||||
    Limelight3 limelight3 = new Limelight3();
 | 
					  Limelight3 limelight3 = new Limelight3();
 | 
				
			||||||
    Pose2d pose = new Pose2d();
 | 
					  Pose2d pose = new Pose2d();
 | 
				
			||||||
    private final Pigeon2 gyro = new Pigeon2(13); // ID du Pigeon 2
 | 
					  private final Pigeon2 gyro = new Pigeon2(13); // ID du Pigeon 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public double getAngle() {
 | 
					  public double getAngle() {
 | 
				
			||||||
        return gyro.getYaw().getValueAsDouble(); // Retourne l'angle actuel du robot
 | 
					      return gyro.getYaw().getValueAsDouble(); // Retourne l'angle actuel du robot
 | 
				
			||||||
    }
 | 
					  }
 | 
				
			||||||
    public RobotContainer() {
 | 
					  public RobotContainer() {
 | 
				
			||||||
    autoChooser = AutoBuilder.buildAutoChooser("New Auto");
 | 
					  autoChooser = AutoBuilder.buildAutoChooser("New Auto");
 | 
				
			||||||
    SmartDashboard.putData("Auto Mode", autoChooser);
 | 
					  SmartDashboard.putData("Auto Mode", autoChooser);
 | 
				
			||||||
    configureBindings();
 | 
					  configureBindings();
 | 
				
			||||||
    NamedCommands.registerCommand("AprilTag", new AprilTag3G(limelight3g, drivetrain, null, null));
 | 
					  NamedCommands.registerCommand("AprilTag", new AprilTag3G(limelight3g, drivetrain, null, null));
 | 
				
			||||||
    }
 | 
					  }
 | 
				
			||||||
    private void configureBindings() {
 | 
					  private void configureBindings() {
 | 
				
			||||||
      elevateur.setDefaultCommand(new RunCommand(()->{
 | 
					    // Elevateur manuel
 | 
				
			||||||
        elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2));
 | 
					
 | 
				
			||||||
      }, elevateur));
 | 
					    elevateur.setDefaultCommand(new RunCommand(()->{
 | 
				
			||||||
      pince.setDefaultCommand(new RunCommand(()->{
 | 
					      elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2));
 | 
				
			||||||
        pince.pivote(MathUtil.applyDeadband(manette2.getRightY()/5, 0.2));
 | 
					    }, elevateur));
 | 
				
			||||||
      }, pince));
 | 
					
 | 
				
			||||||
        // Note that X is defined as forward according to WPILib convention,
 | 
					    //Pince manuel
 | 
				
			||||||
        // and Y is defined as to the left according to WPILib convention.
 | 
					    pince.setDefaultCommand(new RunCommand(()->{
 | 
				
			||||||
        drivetrain.setDefaultCommand(
 | 
					      pince.pivote(MathUtil.applyDeadband(manette2.getRightY()/5, 0.2));
 | 
				
			||||||
            // Drivetrain will execute this command periodically
 | 
					    }, pince));
 | 
				
			||||||
            drivetrain.applyRequest(() ->
 | 
					
 | 
				
			||||||
                drive.withVelocityX(MathUtil.applyDeadband(-manette1.getLeftY()*MaxSpeed, 0.2)) // Drive forward with negative Y (forward)
 | 
					      // Note that X is defined as forward according to WPILib convention,
 | 
				
			||||||
                    .withVelocityY(MathUtil.applyDeadband(-manette1.getLeftX()*MaxSpeed, 0.2)) // Drive left with negative X (left)
 | 
					      // and Y is defined as to the left according to WPILib convention.
 | 
				
			||||||
                    .withRotationalRate(MathUtil.applyDeadband(-manette1.getRightX()*MaxAngularRate, 0.15)) // Drive counterclockwise with negative X (left)
 | 
					      drivetrain.setDefaultCommand(
 | 
				
			||||||
            )
 | 
					          // Drivetrain will execute this command periodically
 | 
				
			||||||
        );
 | 
					          drivetrain.applyRequest(() ->
 | 
				
			||||||
 | 
					            drive.withVelocityX(MathUtil.applyDeadband(-manette1.getLeftY()*MaxSpeed, 0.2)) // Drive forward with negative Y (forward)
 | 
				
			||||||
 | 
					              .withVelocityY(MathUtil.applyDeadband(-manette1.getLeftX()*MaxSpeed, 0.2)) // Drive left with negative X (left)
 | 
				
			||||||
 | 
					              .withRotationalRate(MathUtil.applyDeadband(-manette1.getRightX()*MaxAngularRate, 0.15)) // Drive counterclockwise with negative X (left)
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // reset the field-centric heading on left bumper press
 | 
					    // reset the field-centric heading on left bumper press
 | 
				
			||||||
        manette1.start().onTrue(drivetrain.runOnce(() -> drivetrain.seedFieldCentric()));
 | 
					    manette1.start().onTrue(drivetrain.runOnce(() -> drivetrain.seedFieldCentric()));
 | 
				
			||||||
        manette1.leftTrigger().whileTrue(new AprilTag3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY));
 | 
					    manette1.leftTrigger().whileTrue(new AprilTag3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY));
 | 
				
			||||||
        manette1.rightTrigger().whileTrue(new Forme3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY));
 | 
					    manette1.rightTrigger().whileTrue(new Forme3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY));
 | 
				
			||||||
        manette1.a().whileTrue(new reset(elevateur,pince));
 | 
					    manette1.a().whileTrue(new reset(elevateur,pince));
 | 
				
			||||||
        manette1.b().whileTrue(new L2(elevateur, pince));
 | 
					    manette1.b().whileTrue(new L2(elevateur, pince));
 | 
				
			||||||
        
 | 
					    
 | 
				
			||||||
 | 
					    // manette2.leftTrigger().whileTrue(new AprilTag3G(limelight3g,drivetrain,manette1::getLeftX,manette1::getLeftY));
 | 
				
			||||||
       // manette2.leftTrigger().whileTrue(new AprilTag3G(limelight3g,drivetrain,manette1::getLeftX,manette1::getLeftY));
 | 
					    drivetrain.registerTelemetry(logger::telemeterize);
 | 
				
			||||||
 | 
					  }  
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        drivetrain.registerTelemetry(logger::telemeterize);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Command getAutonomousCommand() {
 | 
					    public Command getAutonomousCommand() {
 | 
				
			||||||
        return new SequentialCommandGroup(Commands.runOnce(()->{
 | 
					      return new SequentialCommandGroup(Commands.runOnce(()->{
 | 
				
			||||||
            boolean flip = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red;
 | 
					        boolean flip = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red;
 | 
				
			||||||
            if(flip){
 | 
					        if(flip){
 | 
				
			||||||
                drivetrain.resetPose(FlippingUtil.flipFieldPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose()));
 | 
					            drivetrain.resetPose(FlippingUtil.flipFieldPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose()));
 | 
				
			||||||
            }
 | 
					        }
 | 
				
			||||||
            else{
 | 
					        else{
 | 
				
			||||||
                drivetrain.resetPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose());
 | 
					            drivetrain.resetPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose());
 | 
				
			||||||
            }
 | 
					        }
 | 
				
			||||||
        }),autoChooser.getSelected(), new RainBow(bougie));
 | 
					      }),autoChooser.getSelected(), new RainBow(bougie));
 | 
				
			||||||
    }
 | 
					    }    
 | 
				
			||||||
             
 | 
					}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user