Compare commits
35 Commits
coaching
...
c8d0ee3a03
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8d0ee3a03 | ||
|
|
3300d74a78 | ||
|
|
bdffb48ece | ||
|
|
5f44d5304a | ||
|
|
9aa7018812 | ||
|
|
d98dc4e467 | ||
|
|
b0ad34519e | ||
|
|
7b734cc046 | ||
|
|
cdca0230a4 | ||
|
|
56b28100df | ||
|
|
db935eceda | ||
|
|
da28ff48db | ||
|
|
5b6e3ac7b2 | ||
|
|
9585c17bdb | ||
|
|
07eeaffa32 | ||
|
|
8202b012cb | ||
|
|
e5f7b05063 | ||
|
|
5916f4f141 | ||
| 4438560698 | |||
| b2d4647e41 | |||
| 75922f581c | |||
| a429b936d2 | |||
|
|
3b06cbd447 | ||
|
|
7b535a845f | ||
|
|
42e35fca8a | ||
|
|
272f89962a | ||
|
|
52c72e9a61 | ||
|
|
4d1b353e25 | ||
|
|
9d09af20b0 | ||
|
|
ae9a6bd046 | ||
|
|
10b0110315 | ||
| 098f16665a | |||
| 1240160ed7 | |||
| 4068016d36 | |||
|
|
6afc342006 |
@@ -0,0 +1,99 @@
|
|||||||
|
{
|
||||||
|
"version": "2025.0",
|
||||||
|
"command": {
|
||||||
|
"type": "sequential",
|
||||||
|
"data": {
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "DescendreBalayeuse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "deadline",
|
||||||
|
"data": {
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "wait",
|
||||||
|
"data": {
|
||||||
|
"waitTime": 3.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "path",
|
||||||
|
"data": {
|
||||||
|
"pathName": "Depot"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "Aspirer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "path",
|
||||||
|
"data": {
|
||||||
|
"pathName": "Tir"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "deadline",
|
||||||
|
"data": {
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "Lancer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "Aspirer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "path",
|
||||||
|
"data": {
|
||||||
|
"pathName": "GrimperReservoir"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "GrimperReservoir"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "MonterGrimpeur"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "gauche"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "DescendreGrimpeur"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resetOdom": true,
|
||||||
|
"folder": null,
|
||||||
|
"choreoAuto": false
|
||||||
|
}
|
||||||
@@ -14,6 +14,12 @@
|
|||||||
"type": "deadline",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
"commands": [
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "wait",
|
||||||
|
"data": {
|
||||||
|
"waitTime": 3.0
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -42,15 +48,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "named",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
"name": "Lancer"
|
"commands": [
|
||||||
}
|
{
|
||||||
},
|
"type": "named",
|
||||||
{
|
"data": {
|
||||||
"type": "named",
|
"name": "Lancer"
|
||||||
"data": {
|
}
|
||||||
"name": "TournerA180"
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "Aspirer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -72,9 +85,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "named",
|
||||||
"data": {
|
"data": {
|
||||||
"pathName": "MonterMur"
|
"name": "droite"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,12 @@
|
|||||||
"type": "deadline",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
"commands": [
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "wait",
|
||||||
|
"data": {
|
||||||
|
"waitTime": 3.0
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -42,15 +48,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "named",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
"name": "Lancer"
|
"commands": [
|
||||||
}
|
{
|
||||||
},
|
"type": "named",
|
||||||
{
|
"data": {
|
||||||
"type": "named",
|
"name": "Lancer"
|
||||||
"data": {
|
}
|
||||||
"name": "TournerAZero"
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "Aspirer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -72,9 +85,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "named",
|
||||||
"data": {
|
"data": {
|
||||||
"pathName": "MonterReservoir"
|
"name": "gauche"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.0502282453637657,
|
"x": 1.0,
|
||||||
"y": 2.4758915834522113
|
"y": 2.6
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 1.0408884389937225,
|
"x": 0.9906601936299568,
|
||||||
"y": 2.742159765250622
|
"y": 2.866268181798411
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
"linkedName": null
|
"linkedName": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.0502282453637657,
|
"x": 1.0,
|
||||||
"y": 2.7734807417974334
|
"y": 2.9
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 1.0547546338516156,
|
"x": 1.00452638848785,
|
||||||
"y": 2.523521721541598
|
"y": 2.6500409797441646
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
|||||||
import frc.robot.commands.Aspirer;
|
import frc.robot.commands.Aspirer;
|
||||||
import frc.robot.commands.DescendreBalyeuse;
|
import frc.robot.commands.DescendreBalyeuse;
|
||||||
import frc.robot.commands.DescendreGrimpeur;
|
import frc.robot.commands.DescendreGrimpeur;
|
||||||
|
import frc.robot.commands.Inverser;
|
||||||
import frc.robot.commands.Lancer;
|
import frc.robot.commands.Lancer;
|
||||||
import frc.robot.commands.LancerAspirer;
|
import frc.robot.commands.LancerAspirer;
|
||||||
import frc.robot.commands.LancerBaseVitesse;
|
import frc.robot.commands.LancerBaseVitesse;
|
||||||
@@ -30,6 +31,8 @@ import frc.robot.commands.ModeOposerDemeleur;
|
|||||||
import frc.robot.commands.MonterBalyeuse;
|
import frc.robot.commands.MonterBalyeuse;
|
||||||
import frc.robot.commands.MonterGrimpeur;
|
import frc.robot.commands.MonterGrimpeur;
|
||||||
import frc.robot.commands.ModeAuto.AspirerAuto;
|
import frc.robot.commands.ModeAuto.AspirerAuto;
|
||||||
|
import frc.robot.commands.ModeAuto.BougerDroiteAuto;
|
||||||
|
import frc.robot.commands.ModeAuto.BougerGaucheAuto;
|
||||||
import frc.robot.commands.ModeAuto.GrimperMur;
|
import frc.robot.commands.ModeAuto.GrimperMur;
|
||||||
import frc.robot.commands.ModeAuto.GrimperReservoir;
|
import frc.robot.commands.ModeAuto.GrimperReservoir;
|
||||||
import frc.robot.commands.ModeAuto.LancerAuto;
|
import frc.robot.commands.ModeAuto.LancerAuto;
|
||||||
@@ -42,8 +45,8 @@ import frc.robot.generated.TunerConstants;
|
|||||||
import frc.robot.subsystems.Balayeuse;
|
import frc.robot.subsystems.Balayeuse;
|
||||||
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
import frc.robot.subsystems.Grimpeur;
|
import frc.robot.subsystems.Grimpeur;
|
||||||
|
import frc.robot.subsystems.LEDSubsystem;
|
||||||
import frc.robot.subsystems.Lanceur;
|
import frc.robot.subsystems.Lanceur;
|
||||||
import frc.robot.subsystems.Led;
|
|
||||||
import frc.robot.subsystems.LimeLight3;
|
import frc.robot.subsystems.LimeLight3;
|
||||||
import frc.robot.subsystems.Limelight3G;
|
import frc.robot.subsystems.Limelight3G;
|
||||||
|
|
||||||
@@ -54,7 +57,7 @@ public class RobotContainer {
|
|||||||
Lanceur lanceur = new Lanceur();
|
Lanceur lanceur = new Lanceur();
|
||||||
LimeLight3 limeLight3 = new LimeLight3();
|
LimeLight3 limeLight3 = new LimeLight3();
|
||||||
Limelight3G limeLight3G = new Limelight3G();
|
Limelight3G limeLight3G = new Limelight3G();
|
||||||
Led led = new Led();
|
LEDSubsystem ledSubsystem = new LEDSubsystem();
|
||||||
CommandXboxController manette = new CommandXboxController(0);
|
CommandXboxController manette = new CommandXboxController(0);
|
||||||
CommandXboxController manette1 = new CommandXboxController(1);
|
CommandXboxController manette1 = new CommandXboxController(1);
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
|
||||||
@@ -64,15 +67,13 @@ public class RobotContainer {
|
|||||||
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 SwerveRequest.SwerveDriveBrake brake = new SwerveRequest.SwerveDriveBrake();
|
|
||||||
private final SwerveRequest.PointWheelsAt point = new SwerveRequest.PointWheelsAt();
|
|
||||||
|
|
||||||
private final Telemetry logger = new Telemetry(MaxSpeed);
|
|
||||||
|
|
||||||
public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();
|
public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();
|
||||||
|
|
||||||
|
|
||||||
public RobotContainer() {
|
public RobotContainer() {
|
||||||
|
NamedCommands.registerCommand("droite", new BougerDroiteAuto(drivetrain));
|
||||||
|
NamedCommands.registerCommand("gauche", new BougerGaucheAuto(drivetrain));
|
||||||
NamedCommands.registerCommand("GrimperMur", new GrimperMur(limeLight3,drivetrain));
|
NamedCommands.registerCommand("GrimperMur", new GrimperMur(limeLight3,drivetrain));
|
||||||
NamedCommands.registerCommand("GrimperReservoir", new GrimperReservoir(limeLight3G,drivetrain));
|
NamedCommands.registerCommand("GrimperReservoir", new GrimperReservoir(limeLight3G,drivetrain));
|
||||||
NamedCommands.registerCommand("Lancer", new LancerAuto(lanceur, limeLight3G));
|
NamedCommands.registerCommand("Lancer", new LancerAuto(lanceur, limeLight3G));
|
||||||
@@ -94,6 +95,7 @@ public class RobotContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void configureBindings() {
|
private void configureBindings() {
|
||||||
|
ledSubsystem.setDefaultCommand(ledSubsystem.updateLEDs());
|
||||||
drivetrain.setDefaultCommand(
|
drivetrain.setDefaultCommand(
|
||||||
drivetrain.applyRequest(() ->
|
drivetrain.applyRequest(() ->
|
||||||
drive.withVelocityY(MathUtil.applyDeadband(-manette.getLeftX()*Math.abs(-manette.getLeftX())*MaxSpeed*0.7, 0.05))
|
drive.withVelocityY(MathUtil.applyDeadband(-manette.getLeftX()*Math.abs(-manette.getLeftX())*MaxSpeed*0.7, 0.05))
|
||||||
@@ -126,6 +128,9 @@ public class RobotContainer {
|
|||||||
manette1.b().whileTrue(new ModeOposer(lanceur));
|
manette1.b().whileTrue(new ModeOposer(lanceur));
|
||||||
manette1.a().whileTrue(new ModeOposerDemeleur(lanceur));
|
manette1.a().whileTrue(new ModeOposerDemeleur(lanceur));
|
||||||
manette1.y().whileTrue(new ModeOposerBalayeuse(balayeuse));
|
manette1.y().whileTrue(new ModeOposerBalayeuse(balayeuse));
|
||||||
|
manette1.povRight().whileTrue(new BougerDroiteAuto(drivetrain));
|
||||||
|
manette1.povLeft().whileTrue(new BougerGaucheAuto(drivetrain));
|
||||||
|
manette1.start().whileTrue(new Inverser(drivetrain));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command getAutonomousCommand() {
|
public Command getAutonomousCommand() {
|
||||||
|
|||||||
@@ -5,33 +5,33 @@
|
|||||||
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.Led;
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
|
|
||||||
/* 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 RainBowAnim extends Command {
|
public class Inverser extends Command {
|
||||||
private Led led;
|
CommandSwerveDrivetrain drivetrain;
|
||||||
/** Creates a new RainBowAnim. */
|
boolean inverse = false;
|
||||||
public RainBowAnim(Led led) {
|
/** Creates a new Inverser. */
|
||||||
this.led = led;
|
public Inverser(CommandSwerveDrivetrain drivetrain) {
|
||||||
addRequirements(led);
|
this.drivetrain = drivetrain;
|
||||||
|
addRequirements(drivetrain);
|
||||||
// Use addRequirements() here to declare subsystem dependencies.
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
led.RainBow();
|
drivetrain.getPigeon2().setYaw(drivetrain.getPigeon2().getYaw().getValueAsDouble()+180);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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() {
|
||||||
|
}
|
||||||
|
|
||||||
// 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.RainBowStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
@@ -40,6 +40,7 @@ public class Lancer extends Command {
|
|||||||
if(limeLight3G.getV()){}
|
if(limeLight3G.getV()){}
|
||||||
pidController = new PIDController(0.0007, 0,0, 0.001);
|
pidController = new PIDController(0.0007, 0,0, 0.001);
|
||||||
timer.reset();
|
timer.reset();
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@@ -47,7 +48,9 @@ public class Lancer extends Command {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
double[] BotPose = new double[6];
|
double[] BotPose = new double[6];
|
||||||
if(limeLight3G.getV()){
|
if(limeLight3G.getV()){
|
||||||
if(!alliance.isPresent()){return;}
|
if(!alliance.isPresent()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(alliance.get() == Alliance.Blue){
|
if(alliance.get() == Alliance.Blue){
|
||||||
BotPose = limeLight3G.getBotPoseBlue();
|
BotPose = limeLight3G.getBotPoseBlue();
|
||||||
}
|
}
|
||||||
@@ -59,10 +62,11 @@ public class Lancer extends Command {
|
|||||||
vitesse = 410.57 * ((Math.sqrt(Math.pow(Math.abs(4.625594-botx), 2) + Math.pow(Math.abs(4.034536-boty), 2)))) + 2250;
|
vitesse = 410.57 * ((Math.sqrt(Math.pow(Math.abs(4.625594-botx), 2) + Math.pow(Math.abs(4.034536-boty), 2)))) + 2250;
|
||||||
}
|
}
|
||||||
if(limeLight3G.getV()){
|
if(limeLight3G.getV()){
|
||||||
System.out.println(vitesse);
|
|
||||||
|
|
||||||
double output = pidController.calculate(lanceur.Vitesse(),vitesse);
|
double output = pidController.calculate(lanceur.Vitesse(),vitesse);
|
||||||
lanceur.Lancer(output);
|
lanceur.Lancer(output);
|
||||||
|
System.out.println(output);
|
||||||
if(lanceur.Vitesse() >= vitesse-800){
|
if(lanceur.Vitesse() >= vitesse-800){
|
||||||
timer.start();
|
timer.start();
|
||||||
if(timer.get() >1){
|
if(timer.get() >1){
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class Limelighter extends Command {
|
|||||||
double boty;
|
double boty;
|
||||||
double angle;
|
double angle;
|
||||||
double calcul;
|
double calcul;
|
||||||
|
double x;
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
@@ -42,7 +43,9 @@ public class Limelighter extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
@@ -50,38 +53,63 @@ public class Limelighter extends Command {
|
|||||||
double[] BotPose = new double[6];
|
double[] BotPose = new double[6];
|
||||||
System.out.println("e");
|
System.out.println("e");
|
||||||
if (limelight3g.getV()) {
|
if (limelight3g.getV()) {
|
||||||
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
|
if (!alliance.isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (alliance.get() == Alliance.Blue) {
|
||||||
|
x = 4.6;
|
||||||
BotPose = limelight3g.getBotPoseBlue();
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
|
}
|
||||||
botx = BotPose[1];
|
else {
|
||||||
boty = BotPose[0];
|
x = 11.915394;
|
||||||
angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
BotPose = limelight3g.getBotPoseRed();
|
||||||
calcul = limelight3g.Calcule(botx, 4, boty, 4.6, angle);
|
}
|
||||||
if(calcul < -5 && calcul > -180){
|
botx = BotPose[0];
|
||||||
|
boty = BotPose[1];
|
||||||
|
angle = BotPose[5];
|
||||||
|
calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
||||||
|
if(calcul > -5 && calcul < 5){
|
||||||
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else if(calcul > 5){
|
||||||
drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
drive.withRotationalRate(0.5*180/Math.PI));
|
drive.withRotationalRate(2));
|
||||||
}
|
}
|
||||||
else if(calcul > 5 && calcul < 180){
|
else if(calcul < -5){
|
||||||
drivetrain.setControl(
|
drivetrain.setControl(drive.withRotationalRate(-2));
|
||||||
drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(calcul >= 180){
|
|
||||||
drivetrain.setControl(
|
|
||||||
drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(calcul <= -180){
|
|
||||||
drivetrain.setControl(
|
|
||||||
drive.withRotationalRate(0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
drivetrain.setControl(
|
|
||||||
drive.withRotationalRate(0));
|
|
||||||
}
|
|
||||||
drivetrain.setControl(
|
|
||||||
drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
|
||||||
System.out.println(angle);
|
|
||||||
if (calcul < 0.2 && calcul > -0.2) {
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0));
|
|
||||||
}
|
}
|
||||||
|
// botx = BotPose[1];
|
||||||
|
// boty = BotPose[0];
|
||||||
|
// angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
|
// calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
||||||
|
// if(calcul < -5 && calcul > -180){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else if(calcul > 5 && calcul < 180){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else if(calcul < -5){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else if(calcul <= -180){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(0));
|
||||||
|
// }
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
||||||
|
// System.out.println(angle);
|
||||||
|
// if (calcul < 0.2 && calcul > -0.2) {
|
||||||
|
// drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
drivetrain.setControl(drive.withRotationalRate(0));
|
drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
// 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.commands.ModeAuto;
|
||||||
|
|
||||||
|
import static edu.wpi.first.units.Units.*;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
|
import edu.wpi.first.wpilibj.Timer;
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import frc.robot.generated.TunerConstants;
|
||||||
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
|
|
||||||
|
/* 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 BougerDroiteAuto extends Command {
|
||||||
|
CommandSwerveDrivetrain drivetrain;
|
||||||
|
Timer timer = new Timer();
|
||||||
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
|
Optional<Alliance> alliance;
|
||||||
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
|
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
|
||||||
|
/** Creates a new AvanceAuto. */
|
||||||
|
public BougerDroiteAuto(CommandSwerveDrivetrain drivetrain) {
|
||||||
|
this.drivetrain = drivetrain;
|
||||||
|
addRequirements(drivetrain);
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
timer.reset();
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
if(alliance.get() == Alliance.Blue){
|
||||||
|
if(timer.get() < .75){
|
||||||
|
System.out.println("8765");
|
||||||
|
drivetrain.setControl(drive.withVelocityY(-1.5));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(timer.get() < 0.75){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(1.5));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return timer.get() > 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// 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.commands.ModeAuto;
|
||||||
|
|
||||||
|
import static edu.wpi.first.units.Units.*;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
|
import edu.wpi.first.wpilibj.Timer;
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import frc.robot.generated.TunerConstants;
|
||||||
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
|
|
||||||
|
/* 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 BougerGaucheAuto extends Command {
|
||||||
|
CommandSwerveDrivetrain drivetrain;
|
||||||
|
Timer timer = new Timer();
|
||||||
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
|
Optional<Alliance> alliance;
|
||||||
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
|
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
|
||||||
|
/** Creates a new AvanceAuto. */
|
||||||
|
public BougerGaucheAuto(CommandSwerveDrivetrain drivetrain) {
|
||||||
|
this.drivetrain = drivetrain;
|
||||||
|
addRequirements(drivetrain);
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
timer.reset();
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
if(timer.get() < 1.25){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(1.5));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return timer.get() > 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,12 +14,14 @@ import com.ctre.phoenix6.hardware.Pigeon2;
|
|||||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.math.MathUtil;
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
import frc.robot.generated.TunerConstants;
|
import frc.robot.generated.TunerConstants;
|
||||||
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
import frc.robot.subsystems.LimeLight3;
|
import frc.robot.subsystems.LimeLight3;
|
||||||
|
import frc.robot.subsystems.Limelight3G;
|
||||||
|
|
||||||
/* 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 GrimperMur extends Command {
|
public class GrimperMur extends Command {
|
||||||
@@ -31,6 +33,7 @@ public class GrimperMur extends Command {
|
|||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
double angle;
|
double angle;
|
||||||
|
double pigeonAngle;
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
@@ -47,51 +50,65 @@ public class GrimperMur extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
// alliance = DriverStation.getAlliance();
|
||||||
|
// if(drivetrain.Equipe()){
|
||||||
|
// angle+=180;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
// 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() {
|
||||||
BotPose = limeLight3.getBotPoseBlue();
|
if(limeLight3.getV()){
|
||||||
botx = BotPose[0];
|
BotPose = limeLight3.getBotPoseBlue();
|
||||||
boty = BotPose[1];
|
botx = BotPose[0];
|
||||||
System.out.println(drivetrain.getPigeon2().getYaw().getValueAsDouble());
|
boty = BotPose[1];
|
||||||
if(angle < 0){
|
if(angle < 0){
|
||||||
angle = angle + 360;
|
angle = angle + 360;
|
||||||
}
|
}
|
||||||
if(alliance.get() == Alliance.Blue){
|
if(alliance.get() == Alliance.Red){
|
||||||
y = 2.961328;
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
x = 1.11;
|
System.out.println(pigeonAngle);
|
||||||
angle = 0;
|
y = 2.6;
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > 350 || drivetrain.getPigeon2().getYaw().getValueAsDouble() < 10){
|
x = 15.6;
|
||||||
drivetrain.setControl(drive.withVelocityY(y-boty).withVelocityX(x-botx));
|
angle = 180;
|
||||||
|
if(pigeonAngle< 190 && pigeonAngle> 170){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp((-(y-boty)*6.5), -2, 2)).withVelocityX(MathUtil.clamp((-(x-botx)*6.5),-2,2)));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-1));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble()+180;
|
||||||
|
System.out.println(pigeonAngle);
|
||||||
|
y = 5.2;
|
||||||
|
x = 1.11;
|
||||||
|
angle = 0;
|
||||||
|
if(pigeonAngle> 358 || pigeonAngle< 2){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp(((y-boty)*5.5), -2, 2)).withVelocityX(MathUtil.clamp(((x-botx)*5.5),-2,2)).withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>0 && pigeonAngle<180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-1));
|
||||||
|
System.out.println("x");
|
||||||
|
}
|
||||||
|
else if(pigeonAngle>180){
|
||||||
|
System.out.println("e");
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0).withRotationalRate(0));
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
x = 11.45966;
|
|
||||||
y = 6.959326;
|
|
||||||
angle = 180;
|
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > 170 && drivetrain.getPigeon2().getYaw().getValueAsDouble() < 190){
|
|
||||||
drivetrain.setControl(drive.withVelocityY(y-boty).withVelocityX(x-botx));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.ctre.phoenix6.hardware.Pigeon2;
|
|||||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.math.MathUtil;
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
@@ -31,9 +32,10 @@ public class GrimperReservoir extends Command {
|
|||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
double angle;
|
double angle;
|
||||||
|
double pigeonAngle;
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance;
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
|
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
|
||||||
@@ -47,51 +49,65 @@ public class GrimperReservoir extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
// if(drivetrain.Equipe()){
|
||||||
|
// drivetrain.getPigeon2().setYaw(drivetrain.getPigeon2().getYaw().getValueAsDouble()+180);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
// 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() {
|
||||||
BotPose = limeLight3G.getBotPoseBlue();
|
if(limeLight3G.getV()){
|
||||||
botx = BotPose[0];
|
BotPose = limeLight3G.getBotPoseBlue();
|
||||||
boty = BotPose[1];
|
botx = BotPose[0];
|
||||||
System.out.println(drivetrain.getPigeon2().getYaw().getValueAsDouble());
|
boty = BotPose[1];
|
||||||
if(angle < 0){
|
if(angle < 0){
|
||||||
angle = angle + 360;
|
angle = angle + 360;
|
||||||
}
|
}
|
||||||
if(alliance.get() == Alliance.Red){
|
if(alliance.get() == Alliance.Red){
|
||||||
y = 6.959326;
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
x = 13.57966;
|
System.out.println(pigeonAngle);
|
||||||
angle = 180;
|
y = 5.2;
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() < 190 && drivetrain.getPigeon2().getYaw().getValueAsDouble() > 170){
|
x = 15.6;
|
||||||
drivetrain.setControl(drive.withVelocityY(y-boty).withVelocityX(x-botx));
|
angle = 180;
|
||||||
|
if(pigeonAngle< 190 && pigeonAngle> 170){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp((-(y-boty)*6.5), -2, 2)).withVelocityX(MathUtil.clamp((-(x-botx)*6.5),-2,2)));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-1));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble()+180;
|
||||||
|
System.out.println(pigeonAngle);
|
||||||
|
y = 2.6;
|
||||||
|
x = 1.11;
|
||||||
|
angle = 0;
|
||||||
|
if(pigeonAngle> 358 || pigeonAngle< 2){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp(((y-boty)*5.5), -2, 2)).withVelocityX(MathUtil.clamp(((x-botx)*5.5),-2,2)).withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>0 && pigeonAngle<180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-1));
|
||||||
|
System.out.println("x");
|
||||||
|
}
|
||||||
|
else if(pigeonAngle>180){
|
||||||
|
System.out.println("e");
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0).withRotationalRate(0));
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
y = 5.081328;
|
|
||||||
x = 1.11;
|
|
||||||
angle = 0;
|
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > 350 || drivetrain.getPigeon2().getYaw().getValueAsDouble() < 10){
|
|
||||||
drivetrain.setControl(drive.withVelocityY(y-boty).withVelocityX(x-botx));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@@ -103,6 +119,6 @@ public class GrimperReservoir extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return (y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05);
|
return (y-boty < 0.1 && y-boty >-0.1) && (x-botx < 0.1 && x-botx > -0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,6 +38,7 @@ public class LancerAuto extends Command {
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
pidController = new PIDController(0.0007, 0, 0, 0.001);
|
pidController = new PIDController(0.0007, 0, 0, 0.001);
|
||||||
timer.reset();
|
timer.reset();
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class LimelighterAuto extends Command {
|
|||||||
double boty;
|
double boty;
|
||||||
double angle;
|
double angle;
|
||||||
double calcul;
|
double calcul;
|
||||||
|
double x;
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
@@ -42,7 +43,9 @@ public class LimelighterAuto extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
@@ -50,38 +53,63 @@ public class LimelighterAuto extends Command {
|
|||||||
double[] BotPose = new double[6];
|
double[] BotPose = new double[6];
|
||||||
System.out.println("e");
|
System.out.println("e");
|
||||||
if (limelight3g.getV()) {
|
if (limelight3g.getV()) {
|
||||||
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
|
if (!alliance.isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (alliance.get() == Alliance.Blue) {
|
||||||
|
x = 4.6;
|
||||||
BotPose = limelight3g.getBotPoseBlue();
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
|
}
|
||||||
botx = BotPose[1];
|
else {
|
||||||
boty = BotPose[0];
|
x = 11.915394;
|
||||||
angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
BotPose = limelight3g.getBotPoseRed();
|
||||||
calcul = limelight3g.Calcule(botx, 4, boty, 4.6, angle);
|
}
|
||||||
if(calcul < -5 && calcul > -180){
|
botx = BotPose[0];
|
||||||
|
boty = BotPose[1];
|
||||||
|
angle = BotPose[5];
|
||||||
|
calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
||||||
|
if(calcul > -5 && calcul < 5){
|
||||||
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else if(calcul > 5){
|
||||||
drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
drive.withRotationalRate(0.5*180/Math.PI));
|
drive.withRotationalRate(2));
|
||||||
}
|
}
|
||||||
else if(calcul > 5 && calcul < 180){
|
else if(calcul < -5){
|
||||||
drivetrain.setControl(
|
drivetrain.setControl(drive.withRotationalRate(-2));
|
||||||
drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(calcul >= 180){
|
|
||||||
drivetrain.setControl(
|
|
||||||
drive.withRotationalRate(-0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else if(calcul <= -180){
|
|
||||||
drivetrain.setControl(
|
|
||||||
drive.withRotationalRate(0.5*180/Math.PI));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
drivetrain.setControl(
|
|
||||||
drive.withRotationalRate(0));
|
|
||||||
}
|
|
||||||
drivetrain.setControl(
|
|
||||||
drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
|
||||||
System.out.println(angle);
|
|
||||||
if (calcul < 0.2 && calcul > -0.2) {
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0));
|
|
||||||
}
|
}
|
||||||
|
// botx = BotPose[1];
|
||||||
|
// boty = BotPose[0];
|
||||||
|
// angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
|
// calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
||||||
|
// if(calcul < -5 && calcul > -180){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else if(calcul > 5 && calcul < 180){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else if(calcul < -5){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else if(calcul <= -180){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(0));
|
||||||
|
// }
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
||||||
|
// System.out.println(angle);
|
||||||
|
// if (calcul < 0.2 && calcul > -0.2) {
|
||||||
|
// drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
drivetrain.setControl(drive.withRotationalRate(0));
|
drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
@@ -98,7 +126,7 @@ public class LimelighterAuto extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return calcul < 5 && calcul > -5;
|
return calcul > -5 && calcul < 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ public class TournerVersMur extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ public class TournerVersReservoir extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
@@ -52,13 +54,18 @@ public class TournerVersReservoir extends Command {
|
|||||||
angle = 0;
|
angle = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > angle && drivetrain.getPigeon2().getYaw().getValueAsDouble() < angle + 10){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else{
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
||||||
drivetrain.setControl(drive.withRotationalRate(-force*180/Math.PI));
|
drivetrain.setControl(drive.withRotationalRate(-force*2));
|
||||||
}
|
}
|
||||||
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
||||||
drivetrain.setControl(drive.withRotationalRate(force*180/Math.PI));
|
drivetrain.setControl(drive.withRotationalRate(force*2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
@@ -67,6 +74,6 @@ public class TournerVersReservoir extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return drivetrain.getPigeon2().getYaw().getValueAsDouble() > angle && drivetrain.getPigeon2().getYaw().getValueAsDouble() < angle + 10;
|
return drivetrain.getPigeon2().getYaw().getValueAsDouble() > angle && drivetrain.getPigeon2().getYaw().getValueAsDouble() < angle + 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,6 @@ public class MonterGrimpeur extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return false;
|
return Math.abs(grimpeur.Position()) > grimpeur.PositionFinal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
|||||||
private final SwerveRequest.SysIdSwerveTranslation m_translationCharacterization = new SwerveRequest.SysIdSwerveTranslation();
|
private final SwerveRequest.SysIdSwerveTranslation m_translationCharacterization = new SwerveRequest.SysIdSwerveTranslation();
|
||||||
private final SwerveRequest.SysIdSwerveSteerGains m_steerCharacterization = new SwerveRequest.SysIdSwerveSteerGains();
|
private final SwerveRequest.SysIdSwerveSteerGains m_steerCharacterization = new SwerveRequest.SysIdSwerveSteerGains();
|
||||||
private final SwerveRequest.SysIdSwerveRotation m_rotationCharacterization = new SwerveRequest.SysIdSwerveRotation();
|
private final SwerveRequest.SysIdSwerveRotation m_rotationCharacterization = new SwerveRequest.SysIdSwerveRotation();
|
||||||
|
|
||||||
/* SysId routine for characterizing translation. This is used to find PID gains for the drive motors. */
|
/* SysId routine for characterizing translation. This is used to find PID gains for the drive motors. */
|
||||||
private final SysIdRoutine m_sysIdRoutineTranslation = new SysIdRoutine(
|
private final SysIdRoutine m_sysIdRoutineTranslation = new SysIdRoutine(
|
||||||
new SysIdRoutine.Config(
|
new SysIdRoutine.Config(
|
||||||
@@ -254,7 +253,6 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
|||||||
else if(getPigeon2().getYaw().getValueAsDouble() < 0){
|
else if(getPigeon2().getYaw().getValueAsDouble() < 0){
|
||||||
getPigeon2().setYaw(getPigeon2().getYaw().getValueAsDouble()+360);
|
getPigeon2().setYaw(getPigeon2().getYaw().getValueAsDouble()+360);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Periodically try to apply the operator perspective.
|
* Periodically try to apply the operator perspective.
|
||||||
* If we haven't applied the operator perspective before, then we should apply it regardless of DS state.
|
* If we haven't applied the operator perspective before, then we should apply it regardless of DS state.
|
||||||
|
|||||||
142
src/main/java/frc/robot/subsystems/LEDSubsystem.java
Normal file
142
src/main/java/frc/robot/subsystems/LEDSubsystem.java
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
/* Generated by Phoenix Tuner X */
|
||||||
|
package frc.robot.subsystems;
|
||||||
|
|
||||||
|
import edu.wpi.first.networktables.GenericEntry;
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
|
import edu.wpi.first.wpilibj.Timer;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||||
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
|
|
||||||
|
import com.ctre.phoenix6.CANBus;
|
||||||
|
import com.ctre.phoenix6.controls.SolidColor;
|
||||||
|
import com.ctre.phoenix6.hardware.CANdle;
|
||||||
|
import com.ctre.phoenix6.signals.RGBWColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subsystem that controls an addressable LED strip using a CANdle.
|
||||||
|
*/
|
||||||
|
public class LEDSubsystem extends SubsystemBase {
|
||||||
|
Timer _timer;
|
||||||
|
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
|
private GenericEntry equipe =
|
||||||
|
teb.add("equipe commence (bleu = ouvert, rouge = fermé)", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
|
||||||
|
private final CANBus kCANBus = new CANBus("rio");
|
||||||
|
private final CANdle m_candle = new CANdle(17, kCANBus);
|
||||||
|
public void Bleu(){
|
||||||
|
m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(255, 0, 0, 0)));
|
||||||
|
}
|
||||||
|
public void Rouge(){
|
||||||
|
m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 0, 255, 0)));
|
||||||
|
}
|
||||||
|
public void Vert(){
|
||||||
|
m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 255, 0, 0)));
|
||||||
|
}
|
||||||
|
public void Noir(){
|
||||||
|
|
||||||
|
m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 0, 0, 0)));
|
||||||
|
}
|
||||||
|
public void Flash(boolean couleur){
|
||||||
|
if(_timer.get() <0.5){
|
||||||
|
if(couleur){
|
||||||
|
Bleu();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Rouge();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Noir();
|
||||||
|
_timer.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public LEDSubsystem() {
|
||||||
|
setDefaultCommand(updateLEDs());
|
||||||
|
_timer = new Timer();
|
||||||
|
_timer.reset();
|
||||||
|
_timer.start();
|
||||||
|
}
|
||||||
|
public boolean Equipe(){
|
||||||
|
return equipe.getBoolean(false);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Updates the animations and LEDs of the CANdle.
|
||||||
|
*
|
||||||
|
* @return Command to run
|
||||||
|
*/
|
||||||
|
public Command updateLEDs() {
|
||||||
|
double temps = DriverStation.getMatchTime();
|
||||||
|
System.out.println(temps);
|
||||||
|
return run(() -> {
|
||||||
|
if(Equipe()){
|
||||||
|
if(temps > 110){
|
||||||
|
Vert();
|
||||||
|
}
|
||||||
|
else if(temps > 88){
|
||||||
|
|
||||||
|
Bleu();
|
||||||
|
}
|
||||||
|
else if(temps > 85){
|
||||||
|
Flash(true);
|
||||||
|
}
|
||||||
|
else if(temps > 63){
|
||||||
|
Rouge();
|
||||||
|
}
|
||||||
|
else if(temps > 60){
|
||||||
|
Flash(false);
|
||||||
|
}
|
||||||
|
else if(temps > 33){
|
||||||
|
Bleu();
|
||||||
|
}
|
||||||
|
else if(temps > 30){
|
||||||
|
Flash(true);
|
||||||
|
}
|
||||||
|
else if(temps > 13){
|
||||||
|
Rouge();
|
||||||
|
}
|
||||||
|
else if(temps > 10){
|
||||||
|
Flash(false);
|
||||||
|
}
|
||||||
|
else if(temps < 10){
|
||||||
|
Vert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(temps > 110){
|
||||||
|
Vert();
|
||||||
|
}
|
||||||
|
else if(temps > 88){
|
||||||
|
|
||||||
|
Rouge();
|
||||||
|
}
|
||||||
|
else if(temps > 85){
|
||||||
|
Flash(false);
|
||||||
|
}
|
||||||
|
else if(temps > 63){
|
||||||
|
Bleu();
|
||||||
|
}
|
||||||
|
else if(temps > 60){
|
||||||
|
Flash(true);
|
||||||
|
}
|
||||||
|
else if(temps > 33){
|
||||||
|
Rouge();
|
||||||
|
}
|
||||||
|
else if(temps > 30){
|
||||||
|
Flash(false);
|
||||||
|
}
|
||||||
|
else if(temps > 13){
|
||||||
|
Bleu();
|
||||||
|
}
|
||||||
|
else if(temps > 10){
|
||||||
|
Flash(true);
|
||||||
|
}
|
||||||
|
else if(temps < 10){
|
||||||
|
Vert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
// 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.RainbowAnimation;
|
|
||||||
|
|
||||||
import edu.wpi.first.networktables.GenericEntry;
|
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
|
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
|
||||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|
||||||
|
|
||||||
public class Led extends SubsystemBase {
|
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
|
||||||
private GenericEntry equipe =
|
|
||||||
teb.add("equipe commence (bleu = ouvert, rouge = fermé)", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
CANdle CANDle = new CANdle(17);
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
RainbowAnimation rainbowAnim = new RainbowAnimation();
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void bleu(){
|
|
||||||
CANDle.setLEDs(0, 0, 255,0,0,8);
|
|
||||||
CANDle.setLEDs(0, 0, 255,0,16,8);
|
|
||||||
CANDle.setLEDs(0, 0, 255,0,32,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,56,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,72,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,88,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,104,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,120,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,136,8);
|
|
||||||
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void Vert1(){
|
|
||||||
CANDle.setLEDs(0, 255, 0,0,0,8);
|
|
||||||
CANDle.setLEDs(0, 255, 0,0,16,8);
|
|
||||||
CANDle.setLEDs(0, 255, 0,0,32,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,56,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,72,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,88,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,104,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,120,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,136,8);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void Rouge(){
|
|
||||||
CANDle.setLEDs(255, 0, 0,0,0,8);
|
|
||||||
CANDle.setLEDs(255, 0, 0,0,16,8);
|
|
||||||
CANDle.setLEDs(255, 0, 0,0,32,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,48,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,64,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,80,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,96,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,112,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,128,8);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void Jaune2(){
|
|
||||||
CANDle.setLEDs(255, 255, 0,0,8,8);
|
|
||||||
CANDle.setLEDs(255, 255, 0,0,24,8);
|
|
||||||
CANDle.setLEDs(255, 255, 0,0,40,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,56,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,72,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,88,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,104,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,120,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,136,8);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void Rouge2(){
|
|
||||||
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);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,72,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,88,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,104,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,120,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,136,8);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void RainBow(){
|
|
||||||
CANDle.animate(rainbowAnim);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void RainBowStop(){
|
|
||||||
CANDle.animate(null);
|
|
||||||
}
|
|
||||||
public boolean Equipe(){
|
|
||||||
return equipe.getBoolean(true);
|
|
||||||
}
|
|
||||||
/** Creates a new Led. */
|
|
||||||
public Led() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void periodic() {
|
|
||||||
|
|
||||||
double temps = DriverStation.getMatchTime();
|
|
||||||
if(temps > 20 && temps < 30){
|
|
||||||
Vert1();
|
|
||||||
}
|
|
||||||
if(Equipe()){
|
|
||||||
if(temps > 30 && temps < 55){
|
|
||||||
bleu();
|
|
||||||
}
|
|
||||||
else if(temps > 30 && temps < 80){
|
|
||||||
Rouge();
|
|
||||||
}
|
|
||||||
else if(temps > 80 && temps < 105){
|
|
||||||
bleu();
|
|
||||||
}
|
|
||||||
else if(temps > 105 && temps < 130){
|
|
||||||
Rouge();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
RainBow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(temps > 30 && temps < 55){
|
|
||||||
Rouge();
|
|
||||||
}
|
|
||||||
else if(temps > 30 && temps < 80){
|
|
||||||
bleu();
|
|
||||||
}
|
|
||||||
else if(temps > 80 && temps < 105){
|
|
||||||
Rouge();
|
|
||||||
}
|
|
||||||
else if(temps > 105 && temps < 130){
|
|
||||||
bleu();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
RainBow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// This method will be called once per scheduler run
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -52,22 +52,28 @@ NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight-tag")
|
|||||||
}
|
}
|
||||||
public double Calcule(double x1, double x2, double y1, double y2, double angle)
|
public double Calcule(double x1, double x2, double y1, double y2, double angle)
|
||||||
{
|
{
|
||||||
if(x1 > x2){
|
// if(x1 > x2){
|
||||||
if(y1 > y2){
|
// if(y1 > y2){
|
||||||
return Math.atan(90-((x2 - x1) / (y2 - y1))) * (180 / Math.PI) - angle;
|
// return Math.atan(90-((x2 - x1) / (y2 - y1))) * (180 / Math.PI) - angle;
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// return Math.atan((x2 - x1) / (y2 - y1)) * (180 / Math.PI)+90 - angle;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// if(y1 > y2){
|
||||||
|
// return Math.atan((x2 - x1) / (y2 - y1))* (180 / Math.PI)+270 - angle;
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// return Math.atan(90-((x2 - x1) / (y2 - y1))) * (180 / Math.PI)+180 - angle;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
if(y1 > y2){
|
||||||
|
return Math.atan((x2 - x1) / (y2 - y1)) * (180 / Math.PI) - angle;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return Math.atan((x2 - x1) / (y2 - y1)) * (180 / Math.PI)+90 - angle;
|
return -Math.atan((x2 - x1) / (y2 - y1)) * (180 / Math.PI) - angle;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(y1 > y2){
|
|
||||||
return Math.atan(90-((x2 - x1) / (y2 - y1)))* (180 / Math.PI)+270 - angle;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return Math.atan((x2 - x1) / (y2 - y1)) * (180 / Math.PI)+180 - angle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void periodic() {
|
public void periodic() {
|
||||||
|
|||||||
Reference in New Issue
Block a user