This commit is contained in:
samuel desharnais 2024-12-16 18:16:12 -05:00
parent dde21cddfd
commit 7222a1ec1e
4 changed files with 23 additions and 16 deletions

View File

@ -21,7 +21,9 @@ public class LEDactive extends Command {
// Called when the command is initially scheduled. // Called when the command is initially scheduled.
@Override @Override
public void initialize() {} public void initialize() {
led.led(25, 25, 100);
}
// Called every time the scheduler runs while the command is scheduled. // Called every time the scheduler runs while the command is scheduled.
@Override @Override
@ -29,7 +31,7 @@ public class LEDactive extends Command {
if(accumulateur.photocell()) if(accumulateur.photocell())
led.led(0, 255, 0); led.led(0, 255, 0);
else{ else{
led.led(25, 25, 100); led.led(255, 0, 0);
} }
} }
@ -37,7 +39,7 @@ public class LEDactive extends Command {
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.
@Override @Override
public void end(boolean interrupted) { public void end(boolean interrupted) {
led.led(25, 25, 100); led.led(0, 0, 0);
} }
// Returns true when the command should end. // Returns true when the command should end.

View File

@ -4,8 +4,7 @@
package frc.robot; package frc.robot;
import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.auto.NamedCommands;
import edu.wpi.first.math.MathUtil; import edu.wpi.first.math.MathUtil;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
@ -16,23 +15,27 @@ 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.Desaccumuler; import frc.robot.Commands.Desaccumuler;
import frc.robot.Commands.FollowAprilTag; import frc.robot.Commands.FollowAprilTag;
import frc.robot.Commands.LEDactive;
import frc.robot.Commands.Lancer; import frc.robot.Commands.Lancer;
import frc.robot.Subsystems.Accumulateur; import frc.robot.Subsystems.Accumulateur;
import frc.robot.Subsystems.LED;
//import frc.robot.Subsystems.Drive; //import frc.robot.Subsystems.Drive;
import frc.robot.Subsystems.Lanceur; import frc.robot.Subsystems.Lanceur;
import frc.robot.Subsystems.Limelight3G; import frc.robot.Subsystems.Limelight3G;
//import com.pathplanner.lib.auto.AutoBuilder;
//import com.pathplanner.lib.auto.NamedCommands;
public class RobotContainer { public class RobotContainer {
private final SendableChooser<Command> autoChooser; // private final SendableChooser<Command> autoChooser;
Lanceur lanceur= new Lanceur(); Lanceur lanceur= new Lanceur();
Accumulateur accumulateur = new Accumulateur(); Accumulateur accumulateur = new Accumulateur();
Limelight3G limelight3G = new Limelight3G(); Limelight3G limelight3G = new Limelight3G();
LED led = new LED();
//Drive drive = new Drive(); //Drive drive = new Drive();
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
CommandXboxController manette = new CommandXboxController(0); CommandXboxController manette = new CommandXboxController(0);
public RobotContainer() { public RobotContainer() {
NamedCommands.registerCommand("lancer", new Lancer(lanceur, accumulateur)); //NamedCommands.registerCommand("lancer", new Lancer(lanceur, accumulateur));
autoChooser = AutoBuilder.buildAutoChooser(); //autoChooser = AutoBuilder.buildAutoChooser();
dashboard.addCamera("limelight3G", "limelight3G","limelight.local:5800") dashboard.addCamera("limelight3G", "limelight3G","limelight.local:5800")
.withSize(3,4) .withSize(3,4)
.withPosition(5,0); .withPosition(5,0);
@ -43,9 +46,9 @@ public class RobotContainer {
//drive.setDefaultCommand(new RunCommand(()->{ //drive.setDefaultCommand(new RunCommand(()->{
// drive.drive(-MathUtil.applyDeadband(manette.getRightX(),0.2), MathUtil.applyDeadband(-manette.getRightY(),0.2), MathUtil.applyDeadband(-manette.getRightX(), 0.2)); // drive.drive(-MathUtil.applyDeadband(manette.getRightX(),0.2), MathUtil.applyDeadband(-manette.getRightY(),0.2), MathUtil.applyDeadband(-manette.getRightX(), 0.2));
//},drive)); //},drive));
dashboard.add("autochooser",autoChooser) // dashboard.add("autochooser",autoChooser)
.withSize(1,1) //.withSize(1,1)
.withPosition(8,0); // .withPosition(8,0);
} }
private void configureBindings() { private void configureBindings() {
@ -53,9 +56,11 @@ public class RobotContainer {
manette.x().whileTrue(new Lancer(lanceur,accumulateur)); manette.x().whileTrue(new Lancer(lanceur,accumulateur));
manette.leftBumper().toggleOnTrue(new FollowAprilTag(limelight3G, lanceur)); manette.leftBumper().toggleOnTrue(new FollowAprilTag(limelight3G, lanceur));
manette.a().whileTrue(new Desaccumuler(accumulateur)); manette.a().whileTrue(new Desaccumuler(accumulateur));
manette.y().whileTrue(new LEDactive(accumulateur, led));
} }
public Command getAutonomousCommand() { public Command getAutonomousCommand() {
return autoChooser.getSelected(); return null;
// return autoChooser.getSelected();
} }
} }

View File

@ -11,7 +11,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class LED extends SubsystemBase { public class LED extends SubsystemBase {
/** Creates a new LED. */ /** Creates a new LED. */
public LED() {} public LED() {}
CANdle led = new CANdle(0); CANdle led = new CANdle(1);
public void led(int R, int G, int B){ public void led(int R, int G, int B){
led.setLEDs(R, G, B); led.setLEDs(R, G, B);
} }

View File

@ -32,10 +32,10 @@ public class Lanceur extends SubsystemBase {
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
final WPI_TalonSRX lanceur1 = new WPI_TalonSRX(0); final WPI_TalonSRX lanceur1 = new WPI_TalonSRX(0);
final WPI_TalonSRX lanceur2 = new WPI_TalonSRX(1); final WPI_TalonSRX lanceur2 = new WPI_TalonSRX(2);
final CANSparkMax tourelle = new CANSparkMax(2, MotorType.kBrushless); final CANSparkMax tourelle = new CANSparkMax(2, MotorType.kBrushless);
final DigitalInput limitswitch1 = new DigitalInput(0); final DigitalInput limitswitch1 = new DigitalInput(0);
final DigitalInput limitswitch2 = new DigitalInput(1); final DigitalInput limitswitch2 = new DigitalInput(3);
private GenericEntry vitesse = private GenericEntry vitesse =
dashboard.add("vitesselanceur", 0.2) dashboard.add("vitesselanceur", 0.2)
.withSize(0,0) .withSize(0,0)