Bougie(pas fini)

This commit is contained in:
Antoine PerreaultE 2025-02-10 19:49:13 -05:00
parent 451d3c6e20
commit 319c370c6e
4 changed files with 63 additions and 21 deletions

View File

@ -4,14 +4,9 @@
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 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.Commands;
import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.commands.AlgueExpire;
@ -27,12 +22,12 @@ import frc.robot.commands.L4;
import frc.robot.commands.StationPince;
import frc.robot.subsystems.Elevateur;
import frc.robot.subsystems.Pince;
import frc.robot.subsystems.Bougie;
public class RobotContainer {
CommandXboxController manette1 = new CommandXboxController(0);
CommandXboxController manette2 = new CommandXboxController(1);
// private final SendableChooser<Command> autoChooser;
Bougie bougie = new Bougie();
Pince pince = new Pince();
Elevateur elevateur = new Elevateur();
ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY);
@ -41,21 +36,21 @@ public class RobotContainer {
elevateur.setDefaultCommand(new RunCommand(()->{
elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2));
}, elevateur));
/* NamedCommands.registerCommand("Station",new StationPince(pince, elevateur));
NamedCommands.registerCommand("Station",new StationPince(pince, elevateur));
NamedCommands.registerCommand("L4", new L4(elevateur, pince));
NamedCommands.registerCommand("L3", new L3(elevateur, pince));
NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince));
NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince));
NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince,bougie));
NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince,bougie));
NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince));
autoChooser = AutoBuilder.buildAutoChooser();*/
}
private void configureBindings() {
// manette1
manette1.a().whileTrue(new AlgueExpire(pince));
manette1.b().whileTrue(new CoralAlgueInspire(pince));
manette1.x().whileTrue(new CoralInspire(pince));
manette1.y().whileTrue(new CoralExpire(pince));
manette1.x().whileTrue(new CoralInspire(pince,bougie));
manette1.y().whileTrue(new CoralExpire(pince,bougie));
manette1.povUp().whileTrue(new L4(elevateur, pince));
manette1.povRight().whileTrue(new L2(elevateur, pince));
manette1.povLeft().whileTrue(new L3(elevateur, pince));
@ -64,8 +59,8 @@ public class RobotContainer {
manette2.leftBumper().toggleOnTrue(new DepartPince(pince));
manette2.a().whileTrue(new StationPince(pince,elevateur));
}
public Command getAutonomousCommand() {
return null;// autoChooser.getSelected();
return Command()
}
}

View File

@ -6,14 +6,16 @@ package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command;
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 */
public class CoralExpire extends Command {
private Pince pince;
Bougie bougie;
/** Creates a new CoralAlgue. */
public CoralExpire(Pince pince) {
public CoralExpire(Pince pince, Bougie bougie) {
this.pince = pince;
addRequirements(pince);
this.bougie = bougie;
addRequirements(pince,bougie);
// Use addRequirements() here to declare subsystem dependencies.
}
@ -24,7 +26,12 @@ public class CoralExpire extends Command {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if(pince.emperagecoral() > 8){
pince.aspirecoral(-.5);
}
else{
pince.aspirecoral(-.5);
bougie.Rouge();}
}
// Called once the command ends or is interrupted.

View File

@ -6,14 +6,16 @@ package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command;
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 */
public class CoralInspire extends Command {
private Pince pince;
Bougie bougie;
/** Creates a new CoralAlgue. */
public CoralInspire(Pince pince) {
public CoralInspire(Pince pince, Bougie bougie) {
this.pince = pince;
addRequirements(pince);
this.bougie = bougie;
addRequirements(pince,bougie);
// Use addRequirements() here to declare subsystem dependencies.
}
@ -25,6 +27,7 @@ public class CoralInspire extends Command {
@Override
public void execute() {
if(pince.emperagecoral()>8){
bougie.Vert();
pince.aspirecoral(0);
}
else{

View 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
}
}