This commit is contained in:
EdwardFaucher 2025-03-06 15:47:09 -05:00
commit 63313b3b7a
15 changed files with 147 additions and 332 deletions

File diff suppressed because one or more lines are too long

View File

@ -35,8 +35,8 @@
"globalConstraints": { "globalConstraints": {
"maxVelocity": 3.0, "maxVelocity": 3.0,
"maxAcceleration": 3.0, "maxAcceleration": 3.0,
"maxAngularVelocity": 540.0, "maxAngularVelocity": 0.1,
"maxAngularAcceleration": 720.0, "maxAngularAcceleration": 0.1,
"nominalVoltage": 12.0, "nominalVoltage": 12.0,
"unlimited": false "unlimited": false
}, },

View File

@ -5,27 +5,21 @@
package frc.robot; package frc.robot;
import static edu.wpi.first.units.Units.*; import static edu.wpi.first.units.Units.*;
import java.util.Map;
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType; import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
import com.ctre.phoenix6.hardware.Pigeon2; import com.ctre.phoenix6.hardware.Pigeon2;
import com.ctre.phoenix6.swerve.SwerveRequest; import com.ctre.phoenix6.swerve.SwerveRequest;
import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.auto.NamedCommands;
import com.pathplanner.lib.commands.PathPlannerAuto;
import com.pathplanner.lib.util.FlippingUtil;
import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.math.MathUtil; import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.networktables.GenericEntry; import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import edu.wpi.first.wpilibj.DriverStation.Alliance; import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
@ -47,9 +41,6 @@ import frc.robot.commands.Pince.CorailAspir;
import frc.robot.commands.Pince.CoralAlgueInspire; import frc.robot.commands.Pince.CoralAlgueInspire;
import frc.robot.commands.Pince.CoralExpire; import frc.robot.commands.Pince.CoralExpire;
import frc.robot.commands.Pince.PinceManuel; import frc.robot.commands.Pince.PinceManuel;
import frc.robot.commands.grimpeur.GrimperHaut;
import frc.robot.commands.grimpeur.GrimpeurBas;
import frc.robot.commands.grimpeur.GrimpeurManuelhaut;
import frc.robot.commands.requin.BalayeuseAlgue; import frc.robot.commands.requin.BalayeuseAlgue;
import frc.robot.commands.requin.BalayeuseCoral; import frc.robot.commands.requin.BalayeuseCoral;
import frc.robot.commands.requin.BalayeuseHaut; import frc.robot.commands.requin.BalayeuseHaut;
@ -58,7 +49,6 @@ import frc.robot.commands.requin.L1Requin;
import frc.robot.subsystems.Bougie; import frc.robot.subsystems.Bougie;
import frc.robot.subsystems.CommandSwerveDrivetrain; import frc.robot.subsystems.CommandSwerveDrivetrain;
import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Elevateur;
import frc.robot.subsystems.Grimpeur;
import frc.robot.subsystems.Limelight3; import frc.robot.subsystems.Limelight3;
import frc.robot.subsystems.Limelight3G; import frc.robot.subsystems.Limelight3G;
import frc.robot.subsystems.Pince; import frc.robot.subsystems.Pince;
@ -69,6 +59,12 @@ import frc.robot.commands.Elevateur.balonL2;
import frc.robot.commands.Elevateur.balonL3; import frc.robot.commands.Elevateur.balonL3;
public class RobotContainer { public class RobotContainer {
ShuffleboardLayout layoutauto = Shuffleboard.getTab("teb").getLayout("auto", BuiltInLayouts.kList)
.withSize(2, 2).withProperties(Map.of("Label position", "LEFT"));
GenericEntry L1 = layoutauto.add("choix L1",false).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
GenericEntry sortirAngle = layoutauto.add("Cote?",false).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
GenericEntry Reculer = layoutauto.add("Reculer",false).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
GenericEntry L4 = layoutauto.add("L4",false).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond); // 3/4 of a rotation per second max angular velocity private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond); // 3/4 of a rotation per second max angular velocity
@ -83,7 +79,6 @@ public class RobotContainer {
private final CommandXboxController manette2 = new CommandXboxController(1); private final CommandXboxController manette2 = new CommandXboxController(1);
private final Pigeon2 gyro = new Pigeon2(13); // ID du Pigeon 2 private final Pigeon2 gyro = new Pigeon2(13); // ID du Pigeon 2
public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain(); public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();
private final SendableChooser<Command> autoChooser;
public double getAngle() { public double getAngle() {
return gyro.getYaw().getValueAsDouble(); // Retourne l'angle actuel du robot return gyro.getYaw().getValueAsDouble(); // Retourne l'angle actuel du robot
} }
@ -96,22 +91,11 @@ public class RobotContainer {
Limelight3G limelight3g = new Limelight3G(); Limelight3G limelight3g = new Limelight3G();
Limelight3 limelight3 = new Limelight3(); Limelight3 limelight3 = new Limelight3();
Pose2d pose = new Pose2d(); Pose2d pose = new Pose2d();
Grimpeur Grimpeur = new Grimpeur();
Requin requin = new Requin(); Requin requin = new Requin();
CorailAspir corailAspir = new CorailAspir(pince, bougie); CorailAspir corailAspir = new CorailAspir(pince, bougie);
public RobotContainer() { public RobotContainer() {
CameraServer.startAutomaticCapture(); CameraServer.startAutomaticCapture();
configureBindings(); configureBindings();
NamedCommands.registerCommand("AprilTag", new AprilTag3G(limelight3g, drivetrain, null, null));
NamedCommands.registerCommand("Station",new StationPince(pince, elevateur,bougie));
NamedCommands.registerCommand("L4", new L4(elevateur, pince));
NamedCommands.registerCommand("L3", new L3(elevateur, pince));
NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince,bougie));
NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince,bougie));
NamedCommands.registerCommand("baleeuse",new L1Requin(requin, bougie));
NamedCommands.registerCommand("baleeuse sort", new ExpireCorail(requin, bougie));
autoChooser = AutoBuilder.buildAutoChooser("New Auto");
SmartDashboard.putData("Auto Mode", autoChooser);
} }
private void configureBindings() { private void configureBindings() {
@ -156,11 +140,6 @@ public class RobotContainer {
//limelight //limelight
manette2.a().whileTrue(new Forme3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY)); manette2.a().whileTrue(new Forme3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY));
manette2.b().whileTrue(new AprilTag3(limelight3, drivetrain, manette1::getLeftX, manette1::getLeftY)); manette2.b().whileTrue(new AprilTag3(limelight3, drivetrain, manette1::getLeftX, manette1::getLeftY));
//grimpeur
manette2.povDown().whileTrue(new GrimpeurManuelhaut(Grimpeur, bougie));
manette2.povLeft().whileTrue(new GrimperHaut(Grimpeur, bougie));
manette2.povRight().whileTrue(new GrimpeurBas(Grimpeur));
//Pince manuel //Pince manuel
pince.setDefaultCommand(new RunCommand(()->{ pince.setDefaultCommand(new RunCommand(()->{
@ -177,14 +156,35 @@ public class RobotContainer {
} }
public Command getAutonomousCommand() { public Command getAutonomousCommand() {
return new SequentialCommandGroup(Commands.runOnce(()->{ return new SequentialCommandGroup(
boolean flip = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red; drivetrain.applyRequest(()->
if(flip){ drive.withVelocityX(-0.1*MaxSpeed)
drivetrain.resetPose(FlippingUtil.flipFieldPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose())); .withVelocityY(0)
} .withRotationalRate(0)).unless(()->!Reculer.getBoolean(true)).withTimeout(3.5),
else{ drivetrain.applyRequest(()->
drivetrain.resetPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose()); drive.withVelocityX(0.1*MaxSpeed)
} .withVelocityY(0)
}),autoChooser.getSelected(), new RainBow(bougie)); .withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(3.5),
drivetrain.applyRequest(()->
drive.withVelocityX(-0.1*MaxSpeed)
.withVelocityY(0)
.withRotationalRate(0)).unless(()->!sortirAngle.getBoolean(true)).withTimeout(3),
drivetrain.applyRequest(()->
drive.withVelocityX(0)
.withVelocityY(0)
.withRotationalRate(0)).withTimeout(0.1),
new L4(elevateur, pince).unless(()->!L4.getBoolean(true)).withTimeout(4),
drivetrain.applyRequest(()->
drive.withVelocityX(0.1*MaxSpeed)
.withVelocityY(0)
.withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(0.25),
drivetrain.applyRequest(()->
drive.withVelocityX(0*MaxSpeed)
.withVelocityY(0)
.withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(2),
new CoralExpire(pince, bougie).unless(()->!L4.getBoolean(true)).withTimeout(2),
new L1Requin(requin, bougie).unless(()-> !L1.getBoolean(true)).withTimeout(2),
new ExpireCorail(requin, bougie).unless(()->!L1.getBoolean(true)).withTimeout(2),
new RainBow(bougie));
} }
} }

View File

@ -0,0 +1,54 @@
// 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 static edu.wpi.first.units.Units.*;
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
import com.ctre.phoenix6.swerve.SwerveRequest;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.TunerConstants.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 AvancerAuto extends Command {
private CommandSwerveDrivetrain commandSwerveDrivetrain = TunerConstants.createDrivetrain();
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond); // 3/4 of
private final SwerveRequest.RobotCentric drive = new SwerveRequest.RobotCentric()
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
/** Creates a new AvancerAuto. */
public AvancerAuto(SwerveRequest.RobotCentric drive, CommandSwerveDrivetrain commandSwerveDrivetrain) {
// 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() {
commandSwerveDrivetrain.applyRequest(()->
drive.withVelocityY(0.5*MaxSpeed)
.withVelocityX(0)
.withRotationalRate(0));
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
drive.withVelocityY(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -26,10 +26,10 @@ public class L2 extends Command {
// 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() {
if(pince.encodeurpivot()>=14 && pince.encodeurpivot()<=15){ if(pince.encodeurpivot()>=15 && pince.encodeurpivot()<=16.5){
pince.pivote(0); pince.pivote(0);
} }
else if(pince.encodeurpivot()>=14){ else if(pince.encodeurpivot()>=15){
pince.pivote(-0.2); pince.pivote(-0.2);
} }
else{ else{

View File

@ -1,56 +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.commands.grimpeur;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Bougie;
import frc.robot.subsystems.Grimpeur;
/* 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 GrimperHaut extends Command {
private Grimpeur grimpeur;
private Bougie bougie;
/** Creates a new Grimper. */
public GrimperHaut(Grimpeur grimpeur, Bougie bougie) {
this.grimpeur = grimpeur;
this.bougie = bougie;
addRequirements(grimpeur,bougie);
// 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(grimpeur.stop()==true){
grimpeur.grimpe(0);
grimpeur.reset();
bougie.RainBow();
}
else{
grimpeur.grimpe(0.5);
bougie.RainBowStop();
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
grimpeur.grimpe(0);
if(grimpeur.stop()){
bougie.RainBow();
}
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return grimpeur.stop()==true;
}
}

View File

@ -1,47 +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.commands.grimpeur;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Grimpeur;
/* 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 GrimpeurBas extends Command {
private Grimpeur grimpeur;
/** Creates a new GrimpeurBas. */
public GrimpeurBas(Grimpeur grimpeur) {
this.grimpeur = grimpeur;
addRequirements(grimpeur);
// 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(grimpeur.encodeur()>=-43.3 && grimpeur.encodeur()<=-42.5){
grimpeur.grimpe(0);
}
else if(grimpeur.encodeur()>=-43.3){
grimpeur.grimpe(-0.5);
}
else{grimpeur.grimpe(0.5);
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
grimpeur.grimpe(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -1,59 +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.commands.grimpeur;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Bougie;
import frc.robot.subsystems.Grimpeur;
/* 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 GrimpeurManuelhaut extends Command {
private Grimpeur grimpeur;
private Bougie bougie;
/** Creates a new GrimpeurManuel. */
public GrimpeurManuelhaut(Grimpeur grimpeur,Bougie bougie) {
this.grimpeur = grimpeur;
this.bougie = bougie;
addRequirements(grimpeur, bougie);
// 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(grimpeur.stop()){
bougie.RainBow();
grimpeur.grimpe(-0.5);
}
else{
bougie.RainBowStop();
grimpeur.grimpe(-0.5);
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
grimpeur.grimpe(0);
if(grimpeur.stop()){
bougie.RainBow();
}
else{bougie.RainBowStop();}
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -1,39 +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.commands.grimpeur;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Grimpeur;
/* 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 ResetGrimpeur extends Command {
private Grimpeur grimpeur;
/** Creates a new ResetGrimpeur. */
public ResetGrimpeur(Grimpeur grimpeur) {
this.grimpeur = grimpeur;
addRequirements(grimpeur);
// 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() {
grimpeur.reset();
}
// 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;
}
}

View File

@ -27,8 +27,8 @@ public class BalayeuseAlgue extends Command {
// 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() {
double cibleMin = 700; double cibleMin = 550;
double cibleMax = 900; double cibleMax = 650;
if(requin.amp()>=78.2){ if(requin.amp()>=78.2){
requin.xRequin = true; requin.xRequin = true;

View File

@ -28,12 +28,12 @@ public class ExpireCorail extends Command {
@Override @Override
public void execute() { public void execute() {
if(requin.amp()> 60){ if(requin.amp()> 60){
requin.balaye(-0.4); requin.balaye(-0.2);
} }
else else
{ {
bougie.Rouge(); bougie.Rouge();
requin.balaye(-0.4); requin.balaye(-0.2);
} }
} }

View File

@ -27,11 +27,10 @@ public class L1Requin extends Command {
// 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() {
bougie.Bleu(); if(requin.encodeur()<=485 && requin.encodeur()>=385){
if(requin.encodeur()<=530 && requin.encodeur()>=430){
requin.rotationer(0); requin.rotationer(0);
} }
else if(requin.encodeur()>=530){ else if(requin.encodeur()>=485){
requin.rotationer(-0.5); requin.rotationer(-0.5);
} }
else{ else{

View File

@ -13,7 +13,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Bougie extends SubsystemBase { public class Bougie extends SubsystemBase {
CANdle candle = new CANdle(23); CANdle candle = new CANdle(23);
CANdleConfiguration config = new CANdleConfiguration(); CANdleConfiguration config = new CANdleConfiguration();
RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 64); RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 68);
/** Creates a new Bougie. */ /** Creates a new Bougie. */
public Bougie() { public Bougie() {
config.brightnessScalar = 0.5; config.brightnessScalar = 0.5;

View File

@ -45,39 +45,42 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
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();
private void configureAutoBuilder() { // private void configureAutoBuilder() {
try { // try {
var config = RobotConfig.fromGUISettings(); // var config = RobotConfig.fromGUISettings();
AutoBuilder.configure( // AutoBuilder.configure(
() -> getState().Pose, // Supplier of current robot pose
this::resetPose, // Consumer for seeding pose against auto // () -> getState().Pose, // Supplier of current robot pose
() -> getState().Speeds, // Supplier of current robot speeds // this::resetPose, // Consumer for seeding pose against auto
// Consumer of ChassisSpeeds and feedforwards to drive the robot // () -> getState().Speeds, // Supplier of current robot speeds
(speeds, feedforwards) -> setControl(
m_pathApplyRobotSpeeds.withSpeeds(speeds) // // Consumer of ChassisSpeeds and feedforwards to drive the robot
.withWheelForceFeedforwardsX(feedforwards.robotRelativeForcesXNewtons()) // (speeds, feedforwards) -> setControl(
.withWheelForceFeedforwardsY(feedforwards.robotRelativeForcesYNewtons()) // m_pathApplyRobotSpeeds.withSpeeds(speeds)
), // .withWheelForceFeedforwardsY(feedforwards.robotRelativeForcesXNewtons())
new PPHolonomicDriveController( // .withWheelForceFeedforwardsX(feedforwards.robotRelativeForcesYNewtons())
// PID constants for translation // ),
new PIDConstants(63.167, 0, 0.54521), // new PPHolonomicDriveController(
// // PID constants for rotation // // PID constants for translation
// new PIDConstants(7.9735, 0, 0.038499) // new PIDConstants(63.167, 0, 0.54521),
// PID constants for rotation // // // PID constants for rotation
new PIDConstants(43.502,0,2.7353) // // new PIDConstants(7.9735, 0, 0.038499)
), // // PID constants for rotation
config, // new PIDConstants(43.502,0,2.7353)
// Assume the path needs to be flipped for Red vs Blue, this is normally the case // ),
() -> DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red, // config,
this // Subsystem for requirements // // Assume the path needs to be flipped for Red vs Blue, this is normally the case
); // () -> DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red,
} catch (Exception ex) { // this // Subsystem for requirements
DriverStation.reportError("Failed to load PathPlanner config and configure AutoBuilder", ex.getStackTrace());
} // );
PPHolonomicDriveController.overrideRotationFeedback(()->{ // } catch (Exception ex) {
return 0; // DriverStation.reportError("Failed to load PathPlanner config and configure AutoBuilder", ex.getStackTrace());
}); // }
} // PPHolonomicDriveController.overrideRotationFeedback(()->{
// return 0;
// });
// }
/** /**
* Constructs a CTRE SwerveDrivetrain using the specified constants. * Constructs a CTRE SwerveDrivetrain using the specified constants.
@ -97,7 +100,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
if (Utils.isSimulation()) { if (Utils.isSimulation()) {
startSimThread(); startSimThread();
} }
configureAutoBuilder(); //configureAutoBuilder();
} }
/** /**
@ -122,7 +125,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
if (Utils.isSimulation()) { if (Utils.isSimulation()) {
startSimThread(); startSimThread();
} }
configureAutoBuilder(); // configureAutoBuilder();
} }
/** /**
@ -155,7 +158,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
if (Utils.isSimulation()) { if (Utils.isSimulation()) {
startSimThread(); startSimThread();
} }
configureAutoBuilder(); //configureAutoBuilder();
} }

View File

@ -1,40 +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.revrobotics.spark.SparkMax;
import com.revrobotics.spark.SparkLowLevel.MotorType;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Grimpeur extends SubsystemBase {
/** Creates a new Grimpeur. */
ShuffleboardTab teb = Shuffleboard.getTab("teb");
public Grimpeur() {
teb.addBoolean("limit grimpeur", this::stop);
teb.addDouble("encodeur grimpeur", this::encodeur);
}
final SparkMax grimpeur = new SparkMax(21,MotorType.kBrushless);
final DigitalInput limit1 = new DigitalInput(2);
public void grimpe(double vitesse){
grimpeur.set(vitesse);
}
public boolean stop(){
return limit1.get();
}
public double encodeur(){
return grimpeur.getEncoder().getPosition();
}
public void reset(){
grimpeur.getEncoder().setPosition(135.11);
}
@Override
public void periodic() {
// This method will be called once per scheduler run
}
}