Compare commits
9 Commits
coaching
...
52c72e9a61
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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": {
|
||||||
@@ -72,9 +78,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": {
|
||||||
@@ -72,9 +78,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;
|
||||||
@@ -73,6 +76,8 @@ public class RobotContainer {
|
|||||||
|
|
||||||
|
|
||||||
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));
|
||||||
@@ -126,6 +131,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() {
|
||||||
|
|||||||
42
src/main/java/frc/robot/commands/Inverser.java
Normal file
42
src/main/java/frc/robot/commands/Inverser.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
// 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;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
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 Inverser extends Command {
|
||||||
|
CommandSwerveDrivetrain drivetrain;
|
||||||
|
boolean inverse = false;
|
||||||
|
/** Creates a new Inverser. */
|
||||||
|
public Inverser(CommandSwerveDrivetrain drivetrain) {
|
||||||
|
addRequirements(drivetrain);
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
if(!inverse){
|
||||||
|
drivetrain.getPigeon2().setYaw(drivetrain.getPigeon2().getYaw().getValueAsDouble()+180);
|
||||||
|
inverse = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.
|
||||||
|
|||||||
@@ -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,62 @@ 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];
|
||||||
|
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(-0.5*(2*Math.PI)));
|
||||||
}
|
}
|
||||||
else if(calcul > 5 && calcul < 180){
|
else if(calcul < -5){
|
||||||
drivetrain.setControl(
|
drivetrain.setControl(drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
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,79 @@
|
|||||||
|
// 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(alliance.get() == Alliance.Blue){
|
||||||
|
if(timer.get() < 0.75){
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,7 +47,12 @@ 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
|
||||||
@@ -60,7 +65,7 @@ public class GrimperMur extends Command {
|
|||||||
angle = angle + 360;
|
angle = angle + 360;
|
||||||
}
|
}
|
||||||
if(alliance.get() == Alliance.Blue){
|
if(alliance.get() == Alliance.Blue){
|
||||||
y = 2.961328;
|
y = 5;
|
||||||
x = 1.11;
|
x = 1.11;
|
||||||
angle = 0;
|
angle = 0;
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > 350 || drivetrain.getPigeon2().getYaw().getValueAsDouble() < 10){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > 350 || drivetrain.getPigeon2().getYaw().getValueAsDouble() < 10){
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -47,51 +48,63 @@ 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];
|
|
||||||
boty = BotPose[1];
|
|
||||||
System.out.println(drivetrain.getPigeon2().getYaw().getValueAsDouble());
|
|
||||||
if(angle < 0){
|
|
||||||
angle = angle + 360;
|
|
||||||
}
|
|
||||||
if(alliance.get() == Alliance.Red){
|
|
||||||
y = 6.959326;
|
|
||||||
x = 13.57966;
|
|
||||||
angle = 180;
|
|
||||||
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() < 190 && drivetrain.getPigeon2().getYaw().getValueAsDouble() > 170){
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
BotPose = limeLight3G.getBotPoseBlue();
|
||||||
|
botx = BotPose[0];
|
||||||
|
boty = BotPose[1];
|
||||||
|
System.out.println(drivetrain.getPigeon2().getYaw().getValueAsDouble());
|
||||||
|
if(angle < 0){
|
||||||
|
angle = angle + 360;
|
||||||
|
}
|
||||||
|
if(alliance.get() == Alliance.Red){
|
||||||
|
y = 6.959326;
|
||||||
|
x = 13.57966;
|
||||||
|
angle = 180;
|
||||||
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() < 190 && drivetrain.getPigeon2().getYaw().getValueAsDouble() > 170){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp(((y-boty)*5), -2, 2)).withVelocityX(MathUtil.clamp(((x-botx)*5),-2,2)));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(1));
|
||||||
|
}
|
||||||
|
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
y = 2.6;
|
||||||
|
x = 1.11;
|
||||||
|
angle = 0;
|
||||||
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > 358 || drivetrain.getPigeon2().getYaw().getValueAsDouble() < 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(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-1));
|
||||||
|
System.out.println("x");
|
||||||
|
}
|
||||||
|
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
||||||
|
System.out.println("e");
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0).withRotationalRate(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@@ -103,6 +116,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();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x = 11.915394;
|
||||||
|
BotPose = limelight3g.getBotPoseRed();
|
||||||
|
}
|
||||||
botx = BotPose[1];
|
botx = BotPose[1];
|
||||||
boty = BotPose[0];
|
boty = BotPose[0];
|
||||||
angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
calcul = limelight3g.Calcule(botx, 4, boty, 4.6, angle);
|
calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
||||||
if(calcul < -5 && calcul > -180){
|
if(angle > 180){
|
||||||
|
angle -= 360;
|
||||||
|
}
|
||||||
|
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(0.5*(2*Math.PI)));
|
||||||
}
|
}
|
||||||
else if(calcul > 5 && calcul < 180){
|
else if(calcul < -5){
|
||||||
drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
drive.withRotationalRate(-0.5*180/Math.PI));
|
drive.withRotationalRate(-0.5*(2*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));
|
|
||||||
}
|
}
|
||||||
|
// 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 >= 180){
|
||||||
|
// 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,6 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,14 @@ import edu.wpi.first.math.geometry.Rotation2d;
|
|||||||
import edu.wpi.first.math.kinematics.ChassisSpeeds;
|
import edu.wpi.first.math.kinematics.ChassisSpeeds;
|
||||||
import edu.wpi.first.math.numbers.N1;
|
import edu.wpi.first.math.numbers.N1;
|
||||||
import edu.wpi.first.math.numbers.N3;
|
import edu.wpi.first.math.numbers.N3;
|
||||||
|
import edu.wpi.first.networktables.GenericEntry;
|
||||||
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.wpilibj.Notifier;
|
import edu.wpi.first.wpilibj.Notifier;
|
||||||
import edu.wpi.first.wpilibj.RobotController;
|
import edu.wpi.first.wpilibj.RobotController;
|
||||||
|
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.Command;
|
||||||
import edu.wpi.first.wpilibj2.command.Subsystem;
|
import edu.wpi.first.wpilibj2.command.Subsystem;
|
||||||
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
|
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
|
||||||
@@ -54,8 +58,10 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
|||||||
/* Swerve requests to apply during SysId characterization */
|
/* Swerve requests to apply during SysId characterization */
|
||||||
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();
|
||||||
|
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
private final SwerveRequest.SysIdSwerveRotation m_rotationCharacterization = new SwerveRequest.SysIdSwerveRotation();
|
private final SwerveRequest.SysIdSwerveRotation m_rotationCharacterization = new SwerveRequest.SysIdSwerveRotation();
|
||||||
|
private GenericEntry equipe =
|
||||||
|
teb.add("equipe commence (bleu = ouvert, rouge = fermé)", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
|
||||||
/* 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(
|
||||||
@@ -221,7 +227,9 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
|||||||
}
|
}
|
||||||
configureAutoBuilder();
|
configureAutoBuilder();
|
||||||
}
|
}
|
||||||
|
public boolean Equipe(){
|
||||||
|
return equipe.getBoolean(false);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns a command that applies the specified control request to this swerve drivetrain.
|
* Returns a command that applies the specified control request to this swerve drivetrain.
|
||||||
*
|
*
|
||||||
@@ -254,7 +262,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.
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|||||||
|
|
||||||
public class Led extends SubsystemBase {
|
public class Led extends SubsystemBase {
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
private GenericEntry equipe =
|
|
||||||
teb.add("equipe commence (bleu = ouvert, rouge = fermé)", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
|
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
CANdle CANDle = new CANdle(17);
|
CANdle CANDle = new CANdle(17);
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
@@ -91,9 +89,6 @@ public class Led extends SubsystemBase {
|
|||||||
public void RainBowStop(){
|
public void RainBowStop(){
|
||||||
CANDle.animate(null);
|
CANDle.animate(null);
|
||||||
}
|
}
|
||||||
public boolean Equipe(){
|
|
||||||
return equipe.getBoolean(true);
|
|
||||||
}
|
|
||||||
/** Creates a new Led. */
|
/** Creates a new Led. */
|
||||||
public Led() {}
|
public Led() {}
|
||||||
|
|
||||||
@@ -104,7 +99,7 @@ public class Led extends SubsystemBase {
|
|||||||
if(temps > 20 && temps < 30){
|
if(temps > 20 && temps < 30){
|
||||||
Vert1();
|
Vert1();
|
||||||
}
|
}
|
||||||
if(Equipe()){
|
// if(Equipe()){
|
||||||
if(temps > 30 && temps < 55){
|
if(temps > 30 && temps < 55){
|
||||||
bleu();
|
bleu();
|
||||||
}
|
}
|
||||||
@@ -120,8 +115,8 @@ public class Led extends SubsystemBase {
|
|||||||
else{
|
else{
|
||||||
RainBow();
|
RainBow();
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
else{
|
// else{
|
||||||
if(temps > 30 && temps < 55){
|
if(temps > 30 && temps < 55){
|
||||||
Rouge();
|
Rouge();
|
||||||
}
|
}
|
||||||
@@ -140,6 +135,6 @@ public class Led extends SubsystemBase {
|
|||||||
}
|
}
|
||||||
// This method will be called once per scheduler run
|
// 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