From b1124bd3f0801f530c6033270fb2f60b397224da Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 09:34:50 -0500 Subject: [PATCH 01/11] mode auto manuel --- src/main/deploy/pathplanner/navgrid.json | 2 +- .../deploy/pathplanner/paths/New Path.path | 4 +- src/main/java/frc/robot/RobotContainer.java | 25 ++++++---- .../java/frc/robot/commands/AvancerAuto.java | 46 +++++++++++++++++++ .../subsystems/CommandSwerveDrivetrain.java | 7 ++- 5 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 src/main/java/frc/robot/commands/AvancerAuto.java diff --git a/src/main/deploy/pathplanner/navgrid.json b/src/main/deploy/pathplanner/navgrid.json index 239a79b..0aee245 100644 --- a/src/main/deploy/pathplanner/navgrid.json +++ b/src/main/deploy/pathplanner/navgrid.json @@ -1 +1 @@ -{"field_size":{"x":17.548,"y":8.052},"nodeSizeMeters":0.3,"grid":[[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true],[true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true],[true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true]]} \ No newline at end of file +{"field_size":{"x":17.548,"y":8.052},"nodeSizeMeters":0.3,"grid":[[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true],[true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true],[true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true]]} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/New Path.path b/src/main/deploy/pathplanner/paths/New Path.path index 809037b..b6f4c74 100644 --- a/src/main/deploy/pathplanner/paths/New Path.path +++ b/src/main/deploy/pathplanner/paths/New Path.path @@ -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 }, diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 05d146d..eba36bf 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -28,8 +28,10 @@ import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; +import edu.wpi.first.wpilibj2.command.WaitUntilCommand; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import frc.robot.TunerConstants.TunerConstants; +import frc.robot.commands.AvancerAuto; import frc.robot.commands.RainBow; import frc.robot.commands.reset; import frc.robot.commands.Elevateur.Depart; @@ -177,14 +179,19 @@ 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( + new AvancerAuto(drive).withTimeout(2), + new L1Requin(requin, bougie).withTimeout(2), + new ExpireCorail(requin, bougie).withTimeout(2), + new RainBow(bougie)); + // 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)); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/AvancerAuto.java b/src/main/java/frc/robot/commands/AvancerAuto.java new file mode 100644 index 0000000..de51667 --- /dev/null +++ b/src/main/java/frc/robot/commands/AvancerAuto.java @@ -0,0 +1,46 @@ +// 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.SwerveRequest; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.TunerConstants.TunerConstants; + +/* 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 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); + /** Creates a new AvancerAuto. */ + public AvancerAuto(SwerveRequest.RobotCentric drive) { + // 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() { + drive.withVelocityX(0.2); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + drive.withVelocityX(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java b/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java index 8016a25..4a103a9 100644 --- a/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java +++ b/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java @@ -49,14 +49,16 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su 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()) + .withWheelForceFeedforwardsY(feedforwards.robotRelativeForcesXNewtons()) + .withWheelForceFeedforwardsX(feedforwards.robotRelativeForcesYNewtons()) ), new PPHolonomicDriveController( // PID constants for translation @@ -70,6 +72,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su // 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()); From a420d3ff2f9acebacd32a6e3b882a7859fcaaf2d Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 10:06:12 -0500 Subject: [PATCH 02/11] mode auto --- src/main/java/frc/robot/RobotContainer.java | 22 +++++++++---------- .../java/frc/robot/commands/AvancerAuto.java | 6 +++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index eba36bf..93e0d5c 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -85,7 +85,7 @@ 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 autoChooser; + //private final SendableChooser autoChooser; public double getAngle() { return gyro.getYaw().getValueAsDouble(); // Retourne l'angle actuel du robot } @@ -104,16 +104,16 @@ public class RobotContainer { 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); + // 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() { diff --git a/src/main/java/frc/robot/commands/AvancerAuto.java b/src/main/java/frc/robot/commands/AvancerAuto.java index de51667..50e95ec 100644 --- a/src/main/java/frc/robot/commands/AvancerAuto.java +++ b/src/main/java/frc/robot/commands/AvancerAuto.java @@ -6,6 +6,7 @@ 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; @@ -16,7 +17,8 @@ public class AvancerAuto extends Command { 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); + .withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1) + .withDriveRequestType(DriveRequestType.OpenLoopVoltage); /** Creates a new AvancerAuto. */ public AvancerAuto(SwerveRequest.RobotCentric drive) { // Use addRequirements() here to declare subsystem dependencies. @@ -29,7 +31,7 @@ public class AvancerAuto extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - drive.withVelocityX(0.2); + drive.withVelocityX(0.2*MaxSpeed); } // Called once the command ends or is interrupted. From 9ce0d79903e3e22eb6a2c7156bc5dc551ba2921d Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 10:23:54 -0500 Subject: [PATCH 03/11] mode auto --- src/main/java/frc/robot/commands/AvancerAuto.java | 4 ++-- src/main/java/frc/robot/commands/requin/L1Requin.java | 1 - src/main/java/frc/robot/subsystems/Bougie.java | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/commands/AvancerAuto.java b/src/main/java/frc/robot/commands/AvancerAuto.java index 50e95ec..e8f4cd0 100644 --- a/src/main/java/frc/robot/commands/AvancerAuto.java +++ b/src/main/java/frc/robot/commands/AvancerAuto.java @@ -31,13 +31,13 @@ public class AvancerAuto extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - drive.withVelocityX(0.2*MaxSpeed); + drive.withVelocityY(0.2*MaxSpeed); } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - drive.withVelocityX(0); + drive.withVelocityY(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/commands/requin/L1Requin.java b/src/main/java/frc/robot/commands/requin/L1Requin.java index 8087309..dc6b86f 100644 --- a/src/main/java/frc/robot/commands/requin/L1Requin.java +++ b/src/main/java/frc/robot/commands/requin/L1Requin.java @@ -27,7 +27,6 @@ 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){ requin.rotationer(0); } diff --git a/src/main/java/frc/robot/subsystems/Bougie.java b/src/main/java/frc/robot/subsystems/Bougie.java index cc5a16f..d56a9e0 100644 --- a/src/main/java/frc/robot/subsystems/Bougie.java +++ b/src/main/java/frc/robot/subsystems/Bougie.java @@ -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; From 8852d0a1b6946047a7ccf4916e83380c9d615caf Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 11:41:46 -0500 Subject: [PATCH 04/11] mode auto --- src/main/java/frc/robot/RobotContainer.java | 5 ++++- src/main/java/frc/robot/commands/AvancerAuto.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 93e0d5c..fda0dd4 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -180,7 +180,10 @@ public class RobotContainer { public Command getAutonomousCommand() { return new SequentialCommandGroup( - new AvancerAuto(drive).withTimeout(2), + drivetrain.applyRequest(()-> + drive.withVelocityX(0.5*MaxSpeed) + .withVelocityY(0) + .withRotationalRate(0)).withTimeout(2), new L1Requin(requin, bougie).withTimeout(2), new ExpireCorail(requin, bougie).withTimeout(2), new RainBow(bougie)); diff --git a/src/main/java/frc/robot/commands/AvancerAuto.java b/src/main/java/frc/robot/commands/AvancerAuto.java index e8f4cd0..0f8d479 100644 --- a/src/main/java/frc/robot/commands/AvancerAuto.java +++ b/src/main/java/frc/robot/commands/AvancerAuto.java @@ -11,16 +11,18 @@ 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) { + public AvancerAuto(SwerveRequest.RobotCentric drive, CommandSwerveDrivetrain commandSwerveDrivetrain) { // Use addRequirements() here to declare subsystem dependencies. } @@ -31,7 +33,11 @@ public class AvancerAuto extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - drive.withVelocityY(0.2*MaxSpeed); + commandSwerveDrivetrain.applyRequest(()-> + drive.withVelocityY(0.5*MaxSpeed) + .withVelocityX(0) + .withRotationalRate(0)); + } // Called once the command ends or is interrupted. From b3c699ccf95430ba7207c57f3018403df96d1230 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 11:44:01 -0500 Subject: [PATCH 05/11] mode auto --- src/main/java/frc/robot/RobotContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index fda0dd4..6cd086f 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -181,7 +181,7 @@ public class RobotContainer { public Command getAutonomousCommand() { return new SequentialCommandGroup( drivetrain.applyRequest(()-> - drive.withVelocityX(0.5*MaxSpeed) + drive.withVelocityX(-0.5*MaxSpeed) .withVelocityY(0) .withRotationalRate(0)).withTimeout(2), new L1Requin(requin, bougie).withTimeout(2), From 41e7d8991949e685487ec50e41aadbbce7b75adf Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 11:59:17 -0500 Subject: [PATCH 06/11] mode auto fonctionnel --- src/main/java/frc/robot/RobotContainer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 6cd086f..864b54a 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -184,6 +184,10 @@ public class RobotContainer { drive.withVelocityX(-0.5*MaxSpeed) .withVelocityY(0) .withRotationalRate(0)).withTimeout(2), + drivetrain.applyRequest(()-> + drive.withVelocityX(0) + .withVelocityY(0) + .withRotationalRate(0)).withTimeout(0.1), new L1Requin(requin, bougie).withTimeout(2), new ExpireCorail(requin, bougie).withTimeout(2), new RainBow(bougie)); From 5009a1c928a2e6f82ccbfcb0548da9f7e4cd1128 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 12:23:57 -0500 Subject: [PATCH 07/11] enlever truc inutil + toggle pour auto --- src/main/java/frc/robot/RobotContainer.java | 55 ++++------------- .../robot/commands/grimpeur/GrimperHaut.java | 56 ------------------ .../robot/commands/grimpeur/GrimpeurBas.java | 47 --------------- .../commands/grimpeur/GrimpeurManuelhaut.java | 59 ------------------- .../commands/grimpeur/ResetGrimpeur.java | 39 ------------ .../java/frc/robot/subsystems/Grimpeur.java | 40 ------------- 6 files changed, 10 insertions(+), 286 deletions(-) delete mode 100644 src/main/java/frc/robot/commands/grimpeur/GrimperHaut.java delete mode 100644 src/main/java/frc/robot/commands/grimpeur/GrimpeurBas.java delete mode 100644 src/main/java/frc/robot/commands/grimpeur/GrimpeurManuelhaut.java delete mode 100644 src/main/java/frc/robot/commands/grimpeur/ResetGrimpeur.java delete mode 100644 src/main/java/frc/robot/subsystems/Grimpeur.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 864b54a..8007c00 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -5,33 +5,24 @@ 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.RunCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; -import edu.wpi.first.wpilibj2.command.WaitUntilCommand; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import frc.robot.TunerConstants.TunerConstants; -import frc.robot.commands.AvancerAuto; import frc.robot.commands.RainBow; import frc.robot.commands.reset; import frc.robot.commands.Elevateur.Depart; @@ -49,9 +40,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; @@ -60,7 +48,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; @@ -71,6 +58,9 @@ 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",true).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 @@ -98,22 +88,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() { @@ -158,11 +137,6 @@ public class RobotContainer { //limelight 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(()->{ @@ -188,17 +162,8 @@ public class RobotContainer { drive.withVelocityX(0) .withVelocityY(0) .withRotationalRate(0)).withTimeout(0.1), - new L1Requin(requin, bougie).withTimeout(2), - new ExpireCorail(requin, bougie).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)); - // 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)); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/grimpeur/GrimperHaut.java b/src/main/java/frc/robot/commands/grimpeur/GrimperHaut.java deleted file mode 100644 index ce3f65a..0000000 --- a/src/main/java/frc/robot/commands/grimpeur/GrimperHaut.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/frc/robot/commands/grimpeur/GrimpeurBas.java b/src/main/java/frc/robot/commands/grimpeur/GrimpeurBas.java deleted file mode 100644 index 8455d38..0000000 --- a/src/main/java/frc/robot/commands/grimpeur/GrimpeurBas.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/frc/robot/commands/grimpeur/GrimpeurManuelhaut.java b/src/main/java/frc/robot/commands/grimpeur/GrimpeurManuelhaut.java deleted file mode 100644 index dd5bd9b..0000000 --- a/src/main/java/frc/robot/commands/grimpeur/GrimpeurManuelhaut.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/frc/robot/commands/grimpeur/ResetGrimpeur.java b/src/main/java/frc/robot/commands/grimpeur/ResetGrimpeur.java deleted file mode 100644 index 5bf0bea..0000000 --- a/src/main/java/frc/robot/commands/grimpeur/ResetGrimpeur.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/frc/robot/subsystems/Grimpeur.java b/src/main/java/frc/robot/subsystems/Grimpeur.java deleted file mode 100644 index 1f94b20..0000000 --- a/src/main/java/frc/robot/subsystems/Grimpeur.java +++ /dev/null @@ -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 - } -} From 28d5118c1f6c9cdffbb3190bdb72043fa272bc53 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 12:52:13 -0500 Subject: [PATCH 08/11] mode auto --- src/main/java/frc/robot/RobotContainer.java | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 8007c00..4945b80 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -61,6 +61,9 @@ 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",true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); + GenericEntry sortirAngle = layoutauto.add("Cote?",true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); + GenericEntry Reculer = layoutauto.add("Reculer",true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); + GenericEntry L4 = layoutauto.add("L4",true).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 @@ -157,11 +160,29 @@ public class RobotContainer { drivetrain.applyRequest(()-> drive.withVelocityX(-0.5*MaxSpeed) .withVelocityY(0) - .withRotationalRate(0)).withTimeout(2), + .withRotationalRate(0)).unless(()->!Reculer.getBoolean(true)).withTimeout(2), + drivetrain.applyRequest(()-> + drive.withVelocityX(0.5*MaxSpeed) + .withVelocityY(0) + .withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(2), + drivetrain.applyRequest(()-> + drive.withVelocityX(-0.5*MaxSpeed) + .withVelocityY(0) + .withRotationalRate(0)).unless(()->!sortirAngle.getBoolean(true)).withTimeout(2), 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.2*MaxSpeed) + .withVelocityY(0) + .withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(0.5), + 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)); From 0d63654df8335838a2a87cb3a193096b7c69f7fc Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 13:07:57 -0500 Subject: [PATCH 09/11] mode auto --- src/main/java/frc/robot/RobotContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 4945b80..bf684cc 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -158,7 +158,7 @@ public class RobotContainer { public Command getAutonomousCommand() { return new SequentialCommandGroup( drivetrain.applyRequest(()-> - drive.withVelocityX(-0.5*MaxSpeed) + drive.withVelocityX(-0.1*MaxSpeed) .withVelocityY(0) .withRotationalRate(0)).unless(()->!Reculer.getBoolean(true)).withTimeout(2), drivetrain.applyRequest(()-> From 004890fd7b42e641aec59f880fda4c7376de9595 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 17:37:01 -0500 Subject: [PATCH 10/11] mode auto --- src/main/java/frc/robot/RobotContainer.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index bf684cc..cdb8827 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -60,10 +60,10 @@ 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",true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); - GenericEntry sortirAngle = layoutauto.add("Cote?",true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); - GenericEntry Reculer = layoutauto.add("Reculer",true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); - GenericEntry L4 = layoutauto.add("L4",true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); + 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 @@ -160,11 +160,11 @@ public class RobotContainer { drivetrain.applyRequest(()-> drive.withVelocityX(-0.1*MaxSpeed) .withVelocityY(0) - .withRotationalRate(0)).unless(()->!Reculer.getBoolean(true)).withTimeout(2), + .withRotationalRate(0)).unless(()->!Reculer.getBoolean(true)).withTimeout(3), drivetrain.applyRequest(()-> drive.withVelocityX(0.5*MaxSpeed) .withVelocityY(0) - .withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(2), + .withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(3), drivetrain.applyRequest(()-> drive.withVelocityX(-0.5*MaxSpeed) .withVelocityY(0) From c0e7985ab7ef30fb4cf683ce5960f6ed9310048e Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 4 Mar 2025 17:37:15 -0500 Subject: [PATCH 11/11] mode auto --- src/main/java/frc/robot/RobotContainer.java | 20 +++--- .../java/frc/robot/commands/Elevateur/L2.java | 4 +- .../robot/commands/requin/BalayeuseAlgue.java | 4 +- .../robot/commands/requin/ExpireCorail.java | 4 +- .../frc/robot/commands/requin/L1Requin.java | 4 +- .../subsystems/CommandSwerveDrivetrain.java | 72 +++++++++---------- 6 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index cdb8827..24ba9d7 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -19,6 +19,7 @@ import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; import edu.wpi.first.wpilibj2.command.Command; +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; @@ -78,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 autoChooser; public double getAngle() { return gyro.getYaw().getValueAsDouble(); // Retourne l'angle actuel du robot } @@ -160,24 +160,24 @@ public class RobotContainer { drivetrain.applyRequest(()-> drive.withVelocityX(-0.1*MaxSpeed) .withVelocityY(0) - .withRotationalRate(0)).unless(()->!Reculer.getBoolean(true)).withTimeout(3), - drivetrain.applyRequest(()-> - drive.withVelocityX(0.5*MaxSpeed) - .withVelocityY(0) - .withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(3), + .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.5*MaxSpeed) + drive.withVelocityX(-0.1*MaxSpeed) .withVelocityY(0) - .withRotationalRate(0)).unless(()->!sortirAngle.getBoolean(true)).withTimeout(2), + .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.2*MaxSpeed) + drive.withVelocityX(0.1*MaxSpeed) .withVelocityY(0) - .withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(0.5), + .withRotationalRate(0)).unless(()->!L4.getBoolean(true)).withTimeout(0.25), drivetrain.applyRequest(()-> drive.withVelocityX(0*MaxSpeed) .withVelocityY(0) diff --git a/src/main/java/frc/robot/commands/Elevateur/L2.java b/src/main/java/frc/robot/commands/Elevateur/L2.java index 99b1a3a..9b60cea 100644 --- a/src/main/java/frc/robot/commands/Elevateur/L2.java +++ b/src/main/java/frc/robot/commands/Elevateur/L2.java @@ -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{ diff --git a/src/main/java/frc/robot/commands/requin/BalayeuseAlgue.java b/src/main/java/frc/robot/commands/requin/BalayeuseAlgue.java index f6130df..1a2216d 100644 --- a/src/main/java/frc/robot/commands/requin/BalayeuseAlgue.java +++ b/src/main/java/frc/robot/commands/requin/BalayeuseAlgue.java @@ -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; diff --git a/src/main/java/frc/robot/commands/requin/ExpireCorail.java b/src/main/java/frc/robot/commands/requin/ExpireCorail.java index 3dd81c1..ba8f98b 100644 --- a/src/main/java/frc/robot/commands/requin/ExpireCorail.java +++ b/src/main/java/frc/robot/commands/requin/ExpireCorail.java @@ -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); } } diff --git a/src/main/java/frc/robot/commands/requin/L1Requin.java b/src/main/java/frc/robot/commands/requin/L1Requin.java index dc6b86f..bbae1d4 100644 --- a/src/main/java/frc/robot/commands/requin/L1Requin.java +++ b/src/main/java/frc/robot/commands/requin/L1Requin.java @@ -27,10 +27,10 @@ public class L1Requin extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - 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{ diff --git a/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java b/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java index 4a103a9..9d3b2e0 100644 --- a/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java +++ b/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java @@ -45,42 +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( + // 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 + // () -> 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 + // // 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; - }); - } + // ); + // } 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. @@ -100,7 +100,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su if (Utils.isSimulation()) { startSimThread(); } - configureAutoBuilder(); + //configureAutoBuilder(); } /** @@ -125,7 +125,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su if (Utils.isSimulation()) { startSimThread(); } - configureAutoBuilder(); + // configureAutoBuilder(); } /** @@ -158,7 +158,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su if (Utils.isSimulation()) { startSimThread(); } - configureAutoBuilder(); + //configureAutoBuilder(); }