leds baleeuse et saaaaaaaaaaam

This commit is contained in:
Antoine PerreaultE 2025-02-11 19:51:37 -05:00
parent 6683613c7f
commit 3458203225
5 changed files with 99 additions and 28 deletions

View File

@ -12,19 +12,20 @@ import frc.robot.commands.BalayeuseCoral;
import frc.robot.commands.BalayeuseHaut; import frc.robot.commands.BalayeuseHaut;
import frc.robot.commands.L1Requin; import frc.robot.commands.L1Requin;
import frc.robot.subsystems.Requin; import frc.robot.subsystems.Requin;
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);
Requin requin = new Requin(); Requin requin = new Requin();
Bougie bougie = new Bougie();
public RobotContainer() { public RobotContainer() {
configureBindings(); configureBindings();
} }
private void configureBindings() { private void configureBindings() {
manette2.b().whileTrue(new BalayeuseAlgue(requin)); manette2.b().whileTrue(new BalayeuseAlgue(requin,bougie));
manette2.x().whileTrue(new BalayeuseCoral(requin)); manette2.x().whileTrue(new BalayeuseCoral(requin,bougie));
manette2.y().whileTrue(new L1Requin(requin)); manette2.y().whileTrue(new L1Requin(requin,bougie));
manette2.rightBumper().whileTrue(new BalayeuseHaut(requin)); manette2.rightBumper().whileTrue(new BalayeuseHaut(requin));
} }

View File

@ -5,15 +5,18 @@
package frc.robot.commands; package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Bougie;
import frc.robot.subsystems.Requin; import frc.robot.subsystems.Requin;
/* 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 BalayeuseAlgue extends Command { public class BalayeuseAlgue extends Command {
private Requin requin; private Requin requin;
private Bougie bougie;
/** Creates a new Balayeuse. */ /** Creates a new Balayeuse. */
public BalayeuseAlgue(Requin requin) { public BalayeuseAlgue(Requin requin,Bougie bougie) {
this.requin = requin; this.requin = requin;
addRequirements(requin); this.bougie =bougie;
addRequirements(requin, bougie);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
} }
@ -26,6 +29,13 @@ public class BalayeuseAlgue extends Command {
public void execute() { public void execute() {
if(requin.encodeur()>=500 && requin.encodeur()<=510){ if(requin.encodeur()>=500 && requin.encodeur()<=510){
requin.rotationer(0); requin.rotationer(0);
if(requin.stop()){
requin.balaye(0);
bougie.Vert();
}
else{
requin.balaye(0.5);
}
} }
else if(requin.encodeur()>=510){ else if(requin.encodeur()>=510){
requin.rotationer(0.5); requin.rotationer(0.5);
@ -33,12 +43,7 @@ public class BalayeuseAlgue extends Command {
else{ else{
requin.rotationer(-0.5); requin.rotationer(-0.5);
} }
if(requin.stop()){
requin.balaye(0);
}
else{
requin.balaye(0.5);
}
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.

View File

@ -5,15 +5,18 @@
package frc.robot.commands; package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Bougie;
import frc.robot.subsystems.Requin; import frc.robot.subsystems.Requin;
/* 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 BalayeuseCoral extends Command { public class BalayeuseCoral extends Command {
private Requin requin; private Requin requin;
private Bougie bougie;
/** Creates a new Balayeuse. */ /** Creates a new Balayeuse. */
public BalayeuseCoral(Requin requin) { public BalayeuseCoral(Requin requin,Bougie bougie) {
this.requin = requin; this.requin = requin;
addRequirements(requin); this.bougie = bougie;
addRequirements(requin,bougie);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
} }
@ -26,6 +29,13 @@ public class BalayeuseCoral extends Command {
public void execute() { public void execute() {
if(requin.encodeur()>=100 && requin.encodeur()<=110){ if(requin.encodeur()>=100 && requin.encodeur()<=110){
requin.rotationer(0); requin.rotationer(0);
if(requin.stop()){
requin.balaye(0);
bougie.Vert();
}
else{
requin.balaye(0.5);
}
} }
else if(requin.encodeur()>=110){ else if(requin.encodeur()>=110){
requin.rotationer(0.5); requin.rotationer(0.5);
@ -33,12 +43,7 @@ public class BalayeuseCoral extends Command {
else{ else{
requin.rotationer(-0.5); requin.rotationer(-0.5);
} }
if(requin.stop()){
requin.balaye(0);
}
else{
requin.balaye(0.5);
}
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.

View File

@ -5,15 +5,18 @@
package frc.robot.commands; package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Bougie;
import frc.robot.subsystems.Requin; import frc.robot.subsystems.Requin;
/* 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 L1Requin extends Command { public class L1Requin extends Command {
private Requin requin; private Requin requin;
private Bougie bougie;
/** Creates a new Balayeuse. */ /** Creates a new Balayeuse. */
public L1Requin(Requin requin) { public L1Requin(Requin requin,Bougie bougie) {
this.requin = requin; this.requin = requin;
addRequirements(requin); this.bougie = bougie;
addRequirements(requin,bougie);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
} }
@ -26,6 +29,13 @@ public class L1Requin extends Command {
public void execute() { public void execute() {
if(requin.encodeur()>=800 && requin.encodeur()<=810){ if(requin.encodeur()>=800 && requin.encodeur()<=810){
requin.rotationer(0); requin.rotationer(0);
if(requin.stop()){
requin.balaye(-0.5);
}
else{
requin.balaye(-0.5);
bougie.Rouge();
}
} }
else if(requin.encodeur()>=810){ else if(requin.encodeur()>=810){
requin.rotationer(0.5); requin.rotationer(0.5);
@ -33,12 +43,10 @@ public class L1Requin extends Command {
else{ else{
requin.rotationer(-0.5); requin.rotationer(-0.5);
} }
if(requin.stop()){
requin.balaye(0);
}
else{
requin.balaye(0.5);
}
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.

View File

@ -0,0 +1,52 @@
// 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,0,8,8);
candle.setLEDs(255, 0, 0,0,24,8);
candle.setLEDs(255, 0, 0,0,40,8);
candle.setLEDs(255, 0, 0,0,56,8);
}
public void Vert() {
candle.setLEDs(0, 255, 0,0,8,8);
candle.setLEDs(0, 255, 0,0,24,8);
candle.setLEDs(0, 255, 0,0,40,8);
candle.setLEDs(0, 255, 0,0,56,8);
}
public void Bleu() {
candle.setLEDs(0, 0, 255,0,16,8);
candle.setLEDs(0, 0, 255,0,32,8);
candle.setLEDs(0, 0, 255,0,48,8);
candle.setLEDs(0, 0, 255,0,64,8);
}
public void Jaune() {
candle.setLEDs(255, 215, 0,0,16,8);
candle.setLEDs(255, 215, 0,0,32,8);
candle.setLEDs(255, 215, 0,0,48,8);
candle.setLEDs(255, 215, 0,0,64,8);
}
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
}
}