Skip to content

Commit

Permalink
fix code crash
Browse files Browse the repository at this point in the history
  • Loading branch information
reediculous456 committed Feb 19, 2025
1 parent f145057 commit 7e83035
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
29 changes: 15 additions & 14 deletions src/main/java/frc/robot/DriverJoystick.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,21 @@ private DriverJoystick() {

// Lock the wheels into an X formation
super.xButton.whileTrue(this.driveTrain.setX());
super.aButton.whileTrue(
new InstantCommand(() -> {
this.currentPose = this.driveTrain.getState().Pose;
}).andThen(AutoBuilder.followPath(new PathPlannerPath(
PathPlannerPath.waypointsFromPoses(this.currentPose, DriveWaypoints.Algae23.getEndpoint()),
new PathConstraints(
DriveConstants.MaxSpeed,
AutoConstants.kMaxAccelerationMetersPerSecondSquared,
AutoConstants.kMaxAngularSpeedRadiansPerSecond,
AutoConstants.kMaxAngularSpeedRadiansPerSecondSquared),
new IdealStartingState(
driveTrain.getState().Speeds.vxMetersPerSecond,
driveTrain.getState().Pose.getRotation()),
new GoalEndState(0, Rotation2d.kZero)))));
// super.aButton.whileTrue(
// new InstantCommand(() -> {
// this.currentPose = this.driveTrain.getState().Pose;
// }).andThen(AutoBuilder.followPath(new PathPlannerPath(
// PathPlannerPath.waypointsFromPoses(this.currentPose,
// DriveWaypoints.Algae23.getEndpoint()),
// new PathConstraints(
// DriveConstants.MaxSpeed,
// AutoConstants.kMaxAccelerationMetersPerSecondSquared,
// AutoConstants.kMaxAngularSpeedRadiansPerSecond,
// AutoConstants.kMaxAngularSpeedRadiansPerSecondSquared),
// new IdealStartingState(
// driveTrain.getState().Speeds.vxMetersPerSecond,
// driveTrain.getState().Pose.getRotation()),
// new GoalEndState(0, Rotation2d.kZero)))));
}

/**
Expand Down
38 changes: 20 additions & 18 deletions src/main/java/frc/robot/subsystems/DriveTrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,26 @@ private DriveTrain() {
SwerveConstants.FrontRight,
SwerveConstants.BackLeft,
SwerveConstants.FrontRight);
AutoBuilder.configure(
() -> this.getState().Pose,
this::resetPose,
() -> this.getState().Speeds,
(ChassisSpeeds speeds, DriveFeedforwards feedForwards) -> {
this.setControl(
new SwerveRequest.ApplyRobotSpeeds().withSpeeds(speeds)
.withWheelForceFeedforwardsX(feedForwards.robotRelativeForcesXNewtons())
.withWheelForceFeedforwardsY(feedForwards.robotRelativeForcesYNewtons()));
},
new PPHolonomicDriveController(
new PIDConstants(AutoConstants.kPXController, AutoConstants.kIXController,
AutoConstants.kDController),
new PIDConstants(AutoConstants.kPThetaController, AutoConstants.kIThetaController,
AutoConstants.kDThetaController)),
AutoConstants.kRobotConfig.get(),
() -> DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red,
this);
if (AutoConstants.kRobotConfig.isPresent()) {
AutoBuilder.configure(
() -> this.getState().Pose,
this::resetPose,
() -> this.getState().Speeds,
(ChassisSpeeds speeds, DriveFeedforwards feedForwards) -> {
this.setControl(
new SwerveRequest.ApplyRobotSpeeds().withSpeeds(speeds)
.withWheelForceFeedforwardsX(feedForwards.robotRelativeForcesXNewtons())
.withWheelForceFeedforwardsY(feedForwards.robotRelativeForcesYNewtons()));
},
new PPHolonomicDriveController(
new PIDConstants(AutoConstants.kPXController, AutoConstants.kIXController,
AutoConstants.kDController),
new PIDConstants(AutoConstants.kPThetaController, AutoConstants.kIThetaController,
AutoConstants.kDThetaController)),
AutoConstants.kRobotConfig.get(),
() -> DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red,
this);
}
if (Utils.isSimulation()) {
startSimThread();
}
Expand Down

0 comments on commit 7e83035

Please sign in to comment.