Merge branch 'main' of https://git.demerso.net/PLS5618/Reefscape-2025
This commit is contained in:
commit
63313b3b7a
File diff suppressed because one or more lines are too long
@ -35,8 +35,8 @@
|
||||
"globalConstraints": {
|
||||
"maxVelocity": 3.0,
|
||||
"maxAcceleration": 3.0,
|
||||
"maxAngularVelocity": 540.0,
|
||||
"maxAngularAcceleration": 720.0,
|
||||
"maxAngularVelocity": 0.1,
|
||||
"maxAngularAcceleration": 0.1,
|
||||
"nominalVoltage": 12.0,
|
||||
"unlimited": false
|
||||
},
|
||||
|
@ -5,27 +5,21 @@
|
||||
package frc.robot;
|
||||
|
||||
import static edu.wpi.first.units.Units.*;
|
||||
|
||||
import java.util.Map;
|
||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||
import com.ctre.phoenix6.hardware.Pigeon2;
|
||||
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.math.MathUtil;
|
||||
import edu.wpi.first.math.geometry.Pose2d;
|
||||
import edu.wpi.first.networktables.GenericEntry;
|
||||
import edu.wpi.first.wpilibj.DriverStation;
|
||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
|
||||
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.wpilibj.smartdashboard.SendableChooser;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.Commands;
|
||||
import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
|
||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||
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.CoralExpire;
|
||||
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.BalayeuseCoral;
|
||||
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.CommandSwerveDrivetrain;
|
||||
import frc.robot.subsystems.Elevateur;
|
||||
import frc.robot.subsystems.Grimpeur;
|
||||
import frc.robot.subsystems.Limelight3;
|
||||
import frc.robot.subsystems.Limelight3G;
|
||||
import frc.robot.subsystems.Pince;
|
||||
@ -69,6 +59,12 @@ import frc.robot.commands.Elevateur.balonL2;
|
||||
import frc.robot.commands.Elevateur.balonL3;
|
||||
|
||||
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 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 Pigeon2 gyro = new Pigeon2(13); // ID du Pigeon 2
|
||||
public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();
|
||||
private final SendableChooser<Command> autoChooser;
|
||||
public double getAngle() {
|
||||
return gyro.getYaw().getValueAsDouble(); // Retourne l'angle actuel du robot
|
||||
}
|
||||
@ -96,22 +91,11 @@ public class RobotContainer {
|
||||
Limelight3G limelight3g = new Limelight3G();
|
||||
Limelight3 limelight3 = new Limelight3();
|
||||
Pose2d pose = new Pose2d();
|
||||
Grimpeur Grimpeur = new Grimpeur();
|
||||
Requin requin = new Requin();
|
||||
CorailAspir corailAspir = new CorailAspir(pince, bougie);
|
||||
public RobotContainer() {
|
||||
CameraServer.startAutomaticCapture();
|
||||
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() {
|
||||
@ -157,11 +141,6 @@ public class RobotContainer {
|
||||
manette2.a().whileTrue(new Forme3(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.setDefaultCommand(new RunCommand(()->{
|
||||
pince.pivote(MathUtil.applyDeadband((manette2.getRightY()*manette2.getRightY()*manette2.getRightY())/3, 0.05));
|
||||
@ -177,14 +156,35 @@ public class RobotContainer {
|
||||
}
|
||||
|
||||
public Command getAutonomousCommand() {
|
||||
return new SequentialCommandGroup(Commands.runOnce(()->{
|
||||
boolean flip = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red;
|
||||
if(flip){
|
||||
drivetrain.resetPose(FlippingUtil.flipFieldPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose()));
|
||||
}
|
||||
else{
|
||||
drivetrain.resetPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose());
|
||||
}
|
||||
}),autoChooser.getSelected(), new RainBow(bougie));
|
||||
return new SequentialCommandGroup(
|
||||
drivetrain.applyRequest(()->
|
||||
drive.withVelocityX(-0.1*MaxSpeed)
|
||||
.withVelocityY(0)
|
||||
.withRotationalRate(0)).unless(()->!Reculer.getBoolean(true)).withTimeout(3.5),
|
||||
drivetrain.applyRequest(()->
|
||||
drive.withVelocityX(0.1*MaxSpeed)
|
||||
.withVelocityY(0)
|
||||
.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));
|
||||
}
|
||||
}
|
54
src/main/java/frc/robot/commands/AvancerAuto.java
Normal file
54
src/main/java/frc/robot/commands/AvancerAuto.java
Normal 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;
|
||||
}
|
||||
}
|
@ -26,10 +26,10 @@ public class L2 extends Command {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
if(pince.encodeurpivot()>=14 && pince.encodeurpivot()<=15){
|
||||
if(pince.encodeurpivot()>=15 && pince.encodeurpivot()<=16.5){
|
||||
pince.pivote(0);
|
||||
}
|
||||
else if(pince.encodeurpivot()>=14){
|
||||
else if(pince.encodeurpivot()>=15){
|
||||
pince.pivote(-0.2);
|
||||
}
|
||||
else{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -27,8 +27,8 @@ public class BalayeuseAlgue extends Command {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
double cibleMin = 700;
|
||||
double cibleMax = 900;
|
||||
double cibleMin = 550;
|
||||
double cibleMax = 650;
|
||||
|
||||
if(requin.amp()>=78.2){
|
||||
requin.xRequin = true;
|
||||
|
@ -28,12 +28,12 @@ public class ExpireCorail extends Command {
|
||||
@Override
|
||||
public void execute() {
|
||||
if(requin.amp()> 60){
|
||||
requin.balaye(-0.4);
|
||||
requin.balaye(-0.2);
|
||||
}
|
||||
else
|
||||
{
|
||||
bougie.Rouge();
|
||||
requin.balaye(-0.4);
|
||||
requin.balaye(-0.2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,10 @@ public class L1Requin extends Command {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
bougie.Bleu();
|
||||
if(requin.encodeur()<=530 && requin.encodeur()>=430){
|
||||
if(requin.encodeur()<=485 && requin.encodeur()>=385){
|
||||
requin.rotationer(0);
|
||||
}
|
||||
else if(requin.encodeur()>=530){
|
||||
else if(requin.encodeur()>=485){
|
||||
requin.rotationer(-0.5);
|
||||
}
|
||||
else{
|
||||
|
@ -13,7 +13,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
public class Bougie extends SubsystemBase {
|
||||
CANdle candle = new CANdle(23);
|
||||
CANdleConfiguration config = new CANdleConfiguration();
|
||||
RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 64);
|
||||
RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 68);
|
||||
/** Creates a new Bougie. */
|
||||
public Bougie() {
|
||||
config.brightnessScalar = 0.5;
|
||||
|
@ -45,39 +45,42 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
||||
private final SwerveRequest.SysIdSwerveSteerGains m_steerCharacterization = new SwerveRequest.SysIdSwerveSteerGains();
|
||||
private final SwerveRequest.SysIdSwerveRotation m_rotationCharacterization = new SwerveRequest.SysIdSwerveRotation();
|
||||
|
||||
private void configureAutoBuilder() {
|
||||
try {
|
||||
var config = RobotConfig.fromGUISettings();
|
||||
AutoBuilder.configure(
|
||||
() -> getState().Pose, // Supplier of current robot pose
|
||||
this::resetPose, // Consumer for seeding pose against auto
|
||||
() -> getState().Speeds, // Supplier of current robot speeds
|
||||
// Consumer of ChassisSpeeds and feedforwards to drive the robot
|
||||
(speeds, feedforwards) -> setControl(
|
||||
m_pathApplyRobotSpeeds.withSpeeds(speeds)
|
||||
.withWheelForceFeedforwardsX(feedforwards.robotRelativeForcesXNewtons())
|
||||
.withWheelForceFeedforwardsY(feedforwards.robotRelativeForcesYNewtons())
|
||||
),
|
||||
new PPHolonomicDriveController(
|
||||
// PID constants for translation
|
||||
new PIDConstants(63.167, 0, 0.54521),
|
||||
// // PID constants for rotation
|
||||
// new PIDConstants(7.9735, 0, 0.038499)
|
||||
// PID constants for rotation
|
||||
new PIDConstants(43.502,0,2.7353)
|
||||
),
|
||||
config,
|
||||
// Assume the path needs to be flipped for Red vs Blue, this is normally the case
|
||||
() -> DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red,
|
||||
this // Subsystem for requirements
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
DriverStation.reportError("Failed to load PathPlanner config and configure AutoBuilder", ex.getStackTrace());
|
||||
}
|
||||
PPHolonomicDriveController.overrideRotationFeedback(()->{
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
// private void configureAutoBuilder() {
|
||||
// try {
|
||||
// var config = RobotConfig.fromGUISettings();
|
||||
// AutoBuilder.configure(
|
||||
|
||||
// () -> getState().Pose, // Supplier of current robot pose
|
||||
// this::resetPose, // Consumer for seeding pose against auto
|
||||
// () -> getState().Speeds, // Supplier of current robot speeds
|
||||
|
||||
// // Consumer of ChassisSpeeds and feedforwards to drive the robot
|
||||
// (speeds, feedforwards) -> setControl(
|
||||
// m_pathApplyRobotSpeeds.withSpeeds(speeds)
|
||||
// .withWheelForceFeedforwardsY(feedforwards.robotRelativeForcesXNewtons())
|
||||
// .withWheelForceFeedforwardsX(feedforwards.robotRelativeForcesYNewtons())
|
||||
// ),
|
||||
// new PPHolonomicDriveController(
|
||||
// // PID constants for translation
|
||||
// new PIDConstants(63.167, 0, 0.54521),
|
||||
// // // PID constants for rotation
|
||||
// // new PIDConstants(7.9735, 0, 0.038499)
|
||||
// // PID constants for rotation
|
||||
// new PIDConstants(43.502,0,2.7353)
|
||||
// ),
|
||||
// config,
|
||||
// // Assume the path needs to be flipped for Red vs Blue, this is normally the case
|
||||
// () -> DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red,
|
||||
// this // Subsystem for requirements
|
||||
|
||||
// );
|
||||
// } catch (Exception ex) {
|
||||
// DriverStation.reportError("Failed to load PathPlanner config and configure AutoBuilder", ex.getStackTrace());
|
||||
// }
|
||||
// PPHolonomicDriveController.overrideRotationFeedback(()->{
|
||||
// return 0;
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Constructs a CTRE SwerveDrivetrain using the specified constants.
|
||||
@ -97,7 +100,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
||||
if (Utils.isSimulation()) {
|
||||
startSimThread();
|
||||
}
|
||||
configureAutoBuilder();
|
||||
//configureAutoBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +125,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
||||
if (Utils.isSimulation()) {
|
||||
startSimThread();
|
||||
}
|
||||
configureAutoBuilder();
|
||||
// configureAutoBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,7 +158,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
||||
if (Utils.isSimulation()) {
|
||||
startSimThread();
|
||||
}
|
||||
configureAutoBuilder();
|
||||
//configureAutoBuilder();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user