changement limelight

This commit is contained in:
Antoine PerreaultE 2025-02-18 18:47:13 -05:00
parent 7cf7483498
commit 6ccef6bad9
4 changed files with 19 additions and 36 deletions

View File

@ -5,7 +5,7 @@
"data": { "data": {
"commands": [ "commands": [
{ {
"type": "sequential", "type": "parallel",
"data": { "data": {
"commands": [ "commands": [
{ {

View File

@ -9,12 +9,12 @@
"defaultMaxAngVel": 540.0, "defaultMaxAngVel": 540.0,
"defaultMaxAngAccel": 720.0, "defaultMaxAngAccel": 720.0,
"defaultNominalVoltage": 12.0, "defaultNominalVoltage": 12.0,
"robotMass": 74.088, "robotMass": 45.3592,
"robotMOI": 6.883, "robotMOI": 6.883,
"robotTrackwidth": 0.546, "robotTrackwidth": 0.546,
"driveWheelRadius": 0.048, "driveWheelRadius": 0.048,
"driveGearing": 5.143, "driveGearing": 5.143,
"maxDriveSpeed": 5.0, "maxDriveSpeed": 5.261,
"driveMotorType": "krakenX60", "driveMotorType": "krakenX60",
"driveCurrentLimit": 60.0, "driveCurrentLimit": 60.0,
"wheelCOF": 1.2, "wheelCOF": 1.2,

View File

@ -5,33 +5,23 @@
package frc.robot; package frc.robot;
import static edu.wpi.first.units.Units.*; import static edu.wpi.first.units.Units.*;
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType; import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
import com.ctre.phoenix6.hardware.Pigeon2; import com.ctre.phoenix6.hardware.Pigeon2;
import com.ctre.phoenix6.mechanisms.swerve.LegacySwerveRequest.PointWheelsAt;
import com.ctre.phoenix6.swerve.SwerveRequest; import com.ctre.phoenix6.swerve.SwerveRequest;
import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.auto.NamedCommands; import com.pathplanner.lib.auto.NamedCommands;
import com.pathplanner.lib.commands.PathPlannerAuto; import com.pathplanner.lib.commands.PathPlannerAuto;
import com.pathplanner.lib.util.FlippingUtil; import com.pathplanner.lib.util.FlippingUtil;
import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.math.MathUtil; import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DriverStation.Alliance; import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction;
import frc.robot.TunerConstants.TunerConstants; import frc.robot.TunerConstants.TunerConstants;
import frc.robot.commands.AprilTag3; import frc.robot.commands.AprilTag3;
import frc.robot.commands.AprilTag3G; import frc.robot.commands.AprilTag3G;
@ -39,11 +29,9 @@ import frc.robot.commands.Forme3;
import frc.robot.commands.RainBow; import frc.robot.commands.RainBow;
import frc.robot.subsystems.Bougie; import frc.robot.subsystems.Bougie;
import frc.robot.subsystems.CommandSwerveDrivetrain; import frc.robot.subsystems.CommandSwerveDrivetrain;
import frc.robot.subsystems.Grimpeur;
import frc.robot.subsystems.Limelight3; import frc.robot.subsystems.Limelight3;
import frc.robot.subsystems.Limelight3G; import frc.robot.subsystems.Limelight3G;
public class RobotContainer { public class RobotContainer {
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond); // 3/4 of a rotation per second max angular velocity private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond); // 3/4 of a rotation per second max angular velocity
@ -88,7 +76,6 @@ public class RobotContainer {
) )
); );
// reset the field-centric heading on left bumper press // reset the field-centric heading on left bumper press
manette1.start().onTrue(drivetrain.runOnce(() -> drivetrain.seedFieldCentric())); manette1.start().onTrue(drivetrain.runOnce(() -> drivetrain.seedFieldCentric()));
manette1.leftTrigger().whileTrue(new AprilTag3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY)); manette1.leftTrigger().whileTrue(new AprilTag3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY));
@ -97,19 +84,16 @@ public class RobotContainer {
drivetrain.registerTelemetry(logger::telemeterize); drivetrain.registerTelemetry(logger::telemeterize);
} }
public Command getAutonomousCommand() {
public Command getAutonomousCommand() { return new SequentialCommandGroup(Commands.runOnce(()->{
return new SequentialCommandGroup(Commands.runOnce(()->{ boolean flip = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red;
boolean flip = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red; if(flip){
if(flip){ drivetrain.resetPose(FlippingUtil.flipFieldPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose()));
drivetrain.resetPose(FlippingUtil.flipFieldPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose())); }
} else{
else{ drivetrain.resetPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose());
drivetrain.resetPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose()); }
} }),autoChooser.getSelected(), new RainBow(bougie));
}),autoChooser.getSelected(), new RainBow(bougie));
} }
} }

View File

@ -3,19 +3,15 @@ package frc.robot.subsystems;
import static edu.wpi.first.units.Units.*; import static edu.wpi.first.units.Units.*;
import java.util.function.Supplier; import java.util.function.Supplier;
import com.ctre.phoenix6.SignalLogger; import com.ctre.phoenix6.SignalLogger;
import com.ctre.phoenix6.Utils; import com.ctre.phoenix6.Utils;
import com.ctre.phoenix6.hardware.Pigeon2;
import com.ctre.phoenix6.swerve.SwerveDrivetrainConstants; import com.ctre.phoenix6.swerve.SwerveDrivetrainConstants;
import com.ctre.phoenix6.swerve.SwerveModuleConstants; import com.ctre.phoenix6.swerve.SwerveModuleConstants;
import com.ctre.phoenix6.swerve.SwerveRequest; import com.ctre.phoenix6.swerve.SwerveRequest;
import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.config.PIDConstants; import com.pathplanner.lib.config.PIDConstants;
import com.pathplanner.lib.config.RobotConfig; import com.pathplanner.lib.config.RobotConfig;
import com.pathplanner.lib.controllers.PPHolonomicDriveController; import com.pathplanner.lib.controllers.PPHolonomicDriveController;
import edu.wpi.first.math.Matrix; import edu.wpi.first.math.Matrix;
import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.numbers.N1; import edu.wpi.first.math.numbers.N1;
@ -140,8 +136,11 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
} catch (Exception ex) { } catch (Exception ex) {
DriverStation.reportError("Failed to load PathPlanner config and configure AutoBuilder", ex.getStackTrace()); DriverStation.reportError("Failed to load PathPlanner config and configure AutoBuilder", ex.getStackTrace());
} }
} PPHolonomicDriveController.overrideRotationFeedback(()->{
return 0;
});
}
/* The SysId routine to test */ /* The SysId routine to test */
private SysIdRoutine m_sysIdRoutineToApply = m_sysIdRoutineTranslation; private SysIdRoutine m_sysIdRoutineToApply = m_sysIdRoutineTranslation;