Bougie(pas fini)
This commit is contained in:
		| @@ -4,14 +4,9 @@ | |||||||
|  |  | ||||||
| package frc.robot; | package frc.robot; | ||||||
|  |  | ||||||
| import com.pathplanner.lib.auto.AutoBuilder; |  | ||||||
| import com.pathplanner.lib.auto.NamedCommands; |  | ||||||
| import com.pathplanner.lib.auto.AutoBuilder; |  | ||||||
| import com.pathplanner.lib.auto.NamedCommands; | import com.pathplanner.lib.auto.NamedCommands; | ||||||
| import edu.wpi.first.math.MathUtil; | import edu.wpi.first.math.MathUtil; | ||||||
| import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; |  | ||||||
| import edu.wpi.first.wpilibj2.command.Command; | import edu.wpi.first.wpilibj2.command.Command; | ||||||
| import edu.wpi.first.wpilibj2.command.Commands; |  | ||||||
| import edu.wpi.first.wpilibj2.command.RunCommand; | import edu.wpi.first.wpilibj2.command.RunCommand; | ||||||
| import edu.wpi.first.wpilibj2.command.button.CommandXboxController; | import edu.wpi.first.wpilibj2.command.button.CommandXboxController; | ||||||
| import frc.robot.commands.AlgueExpire; | import frc.robot.commands.AlgueExpire; | ||||||
| @@ -27,12 +22,12 @@ import frc.robot.commands.L4; | |||||||
| import frc.robot.commands.StationPince; | import frc.robot.commands.StationPince; | ||||||
| import frc.robot.subsystems.Elevateur; | import frc.robot.subsystems.Elevateur; | ||||||
| import frc.robot.subsystems.Pince; | import frc.robot.subsystems.Pince; | ||||||
|  | import frc.robot.subsystems.Bougie; | ||||||
| public class RobotContainer { | public class RobotContainer { | ||||||
|    |    | ||||||
|   CommandXboxController manette1 = new CommandXboxController(0); |   CommandXboxController manette1 = new CommandXboxController(0); | ||||||
|   CommandXboxController manette2 = new CommandXboxController(1); |   CommandXboxController manette2 = new CommandXboxController(1); | ||||||
|  // private final SendableChooser<Command> autoChooser; |   Bougie bougie = new Bougie(); | ||||||
|   Pince pince = new Pince(); |   Pince pince = new Pince(); | ||||||
|   Elevateur elevateur = new Elevateur(); |   Elevateur elevateur = new Elevateur(); | ||||||
|   ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); |   ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); | ||||||
| @@ -41,21 +36,21 @@ public class RobotContainer { | |||||||
|     elevateur.setDefaultCommand(new RunCommand(()->{ |     elevateur.setDefaultCommand(new RunCommand(()->{ | ||||||
|       elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); |       elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); | ||||||
|     }, elevateur)); |     }, elevateur)); | ||||||
|    /*  NamedCommands.registerCommand("Station",new StationPince(pince, elevateur)); |      NamedCommands.registerCommand("Station",new StationPince(pince, elevateur)); | ||||||
|     NamedCommands.registerCommand("L4", new L4(elevateur, pince)); |     NamedCommands.registerCommand("L4", new L4(elevateur, pince)); | ||||||
|     NamedCommands.registerCommand("L3", new L3(elevateur, pince)); |     NamedCommands.registerCommand("L3", new L3(elevateur, pince)); | ||||||
|     NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince)); |     NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince,bougie)); | ||||||
|     NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince)); |     NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince,bougie)); | ||||||
|     NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince)); |     NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince)); | ||||||
|     autoChooser = AutoBuilder.buildAutoChooser();*/ |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   private void configureBindings() { |   private void configureBindings() { | ||||||
|     // manette1 |     // manette1 | ||||||
|     manette1.a().whileTrue(new AlgueExpire(pince)); |     manette1.a().whileTrue(new AlgueExpire(pince)); | ||||||
|     manette1.b().whileTrue(new CoralAlgueInspire(pince)); |     manette1.b().whileTrue(new CoralAlgueInspire(pince)); | ||||||
|     manette1.x().whileTrue(new CoralInspire(pince)); |     manette1.x().whileTrue(new CoralInspire(pince,bougie)); | ||||||
|     manette1.y().whileTrue(new CoralExpire(pince)); |     manette1.y().whileTrue(new CoralExpire(pince,bougie)); | ||||||
|     manette1.povUp().whileTrue(new L4(elevateur, pince)); |     manette1.povUp().whileTrue(new L4(elevateur, pince)); | ||||||
|     manette1.povRight().whileTrue(new L2(elevateur, pince)); |     manette1.povRight().whileTrue(new L2(elevateur, pince)); | ||||||
|     manette1.povLeft().whileTrue(new L3(elevateur, pince)); |     manette1.povLeft().whileTrue(new L3(elevateur, pince)); | ||||||
| @@ -66,6 +61,6 @@ public class RobotContainer { | |||||||
|   } |   } | ||||||
|    |    | ||||||
|   public Command getAutonomousCommand() { |   public Command getAutonomousCommand() { | ||||||
|     return null;// autoChooser.getSelected(); |     return Command() | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -6,14 +6,16 @@ package frc.robot.commands; | |||||||
|  |  | ||||||
| import edu.wpi.first.wpilibj2.command.Command; | import edu.wpi.first.wpilibj2.command.Command; | ||||||
| import frc.robot.subsystems.Pince; | import frc.robot.subsystems.Pince; | ||||||
|  | import frc.robot.subsystems.Bougie; | ||||||
| /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | ||||||
| public class CoralExpire extends Command { | public class CoralExpire extends Command { | ||||||
|   private Pince pince; |   private Pince pince; | ||||||
|  |   Bougie bougie; | ||||||
|   /** Creates a new CoralAlgue. */ |   /** Creates a new CoralAlgue. */ | ||||||
|   public CoralExpire(Pince pince) { |   public CoralExpire(Pince pince, Bougie bougie) { | ||||||
|     this.pince = pince; |     this.pince = pince; | ||||||
|     addRequirements(pince); |     this.bougie = bougie; | ||||||
|  |     addRequirements(pince,bougie); | ||||||
|     // Use addRequirements() here to declare subsystem dependencies. |     // Use addRequirements() here to declare subsystem dependencies. | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -24,8 +26,13 @@ public class CoralExpire extends Command { | |||||||
|   // Called every time the scheduler runs while the command is scheduled. |   // Called every time the scheduler runs while the command is scheduled. | ||||||
|   @Override |   @Override | ||||||
|   public void execute() { |   public void execute() { | ||||||
|  |     if(pince.emperagecoral() > 8){ | ||||||
|       pince.aspirecoral(-.5); |       pince.aspirecoral(-.5); | ||||||
|    } |    } | ||||||
|  |    else{ | ||||||
|  |     pince.aspirecoral(-.5); | ||||||
|  |     bougie.Rouge();} | ||||||
|  |   } | ||||||
|  |  | ||||||
|   // Called once the command ends or is interrupted. |   // Called once the command ends or is interrupted. | ||||||
|   @Override |   @Override | ||||||
|   | |||||||
| @@ -6,14 +6,16 @@ package frc.robot.commands; | |||||||
|  |  | ||||||
| import edu.wpi.first.wpilibj2.command.Command; | import edu.wpi.first.wpilibj2.command.Command; | ||||||
| import frc.robot.subsystems.Pince; | import frc.robot.subsystems.Pince; | ||||||
|  | import frc.robot.subsystems.Bougie; | ||||||
| /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | ||||||
| public class CoralInspire extends Command { | public class CoralInspire extends Command { | ||||||
|   private Pince pince; |   private Pince pince; | ||||||
|  |   Bougie bougie; | ||||||
|   /** Creates a new CoralAlgue. */ |   /** Creates a new CoralAlgue. */ | ||||||
|   public CoralInspire(Pince pince) { |   public CoralInspire(Pince pince, Bougie bougie) { | ||||||
|     this.pince = pince; |     this.pince = pince; | ||||||
|     addRequirements(pince); |     this.bougie = bougie; | ||||||
|  |     addRequirements(pince,bougie); | ||||||
|     // Use addRequirements() here to declare subsystem dependencies. |     // Use addRequirements() here to declare subsystem dependencies. | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -25,6 +27,7 @@ public class CoralInspire extends Command { | |||||||
|   @Override |   @Override | ||||||
|   public void execute() { |   public void execute() { | ||||||
|     if(pince.emperagecoral()>8){ |     if(pince.emperagecoral()>8){ | ||||||
|  |     bougie.Vert(); | ||||||
|     pince.aspirecoral(0);   |     pince.aspirecoral(0);   | ||||||
|     } |     } | ||||||
|     else{ |     else{ | ||||||
|   | |||||||
							
								
								
									
										37
									
								
								src/main/java/frc/robot/subsystems/Bougie.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/main/java/frc/robot/subsystems/Bougie.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | |||||||
|  | // Copyright (c) FIRST and other WPILib contributors. | ||||||
|  | // Open Source Software; you can modify and/or share it under the terms of | ||||||
|  | // the WPILib BSD license file in the root directory of this project. | ||||||
|  |  | ||||||
|  | package frc.robot.subsystems; | ||||||
|  |  | ||||||
|  | import com.ctre.phoenix.led.CANdle; | ||||||
|  | import com.ctre.phoenix.led.CANdleConfiguration; | ||||||
|  | import com.ctre.phoenix.led.RainbowAnimation; | ||||||
|  |  | ||||||
|  | import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||||||
|  |  | ||||||
|  | public class Bougie extends SubsystemBase { | ||||||
|  |   CANdle candle = new CANdle(5); | ||||||
|  |   CANdleConfiguration config = new CANdleConfiguration(); | ||||||
|  |   RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 64); | ||||||
|  |   /** Creates a new Bougie. */ | ||||||
|  |   public Bougie() { | ||||||
|  |     config.brightnessScalar = 0.5; | ||||||
|  |     candle.configAllSettings(config); | ||||||
|  |   } | ||||||
|  |   public void Rouge() { | ||||||
|  |    candle.setLEDs(255, 0, 0); | ||||||
|  |   } | ||||||
|  |   public void Vert() { | ||||||
|  |    candle.setLEDs(0, 255, 0); | ||||||
|  |   } | ||||||
|  |   public void Bleu() { | ||||||
|  |    candle.setLEDs(0, 0, 255); | ||||||
|  |   } | ||||||
|  |   public void RainBow(){candle.animate(rainbowAnim);} | ||||||
|  |   public void RainBowStop(){candle.animate(null);} | ||||||
|  |   @Override | ||||||
|  |   public void periodic() { | ||||||
|  |     // This method will be called once per scheduler run | ||||||
|  |   } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user