Skip to content

Commit

Permalink
Use different drive constraints for OTF pathfinding
Browse files Browse the repository at this point in the history
  • Loading branch information
programming353 committed Jan 29, 2024
1 parent 9c1bd12 commit 863ed54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ public static final class SwerveConstants {
public static final class AutoConstants {
public static final PIDConstants translationConstants = new PIDConstants(5.0, 0.0, 0.0);
public static final PIDConstants rotationConstants = new PIDConstants(4.5, 0.0, 0.0);

public static final double pathfindingMaxVelocity = Units.feetToMeters(13.0);
public static final double pathfindingMaxAcceleration = Units.feetToMeters(20.0);
public static final double pathfindingMaxAngularVelocity = Units.degreesToRadians(180.0);
public static final double pathfindingMaxAngularAcceleration = Units.degreesToRadians(180.0);
}

public static final class FrontLeftModule {
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import frc.lib.controllers.VirtualJoystick;
import frc.lib.controllers.VirtualXboxController;
import frc.robot.Constants.ArmConstants;
import frc.robot.Constants.AutoConstants;
import frc.robot.Constants.FieldConstants;
import frc.robot.Constants.OperatorConstants;
import frc.robot.Constants.ShooterConstants;
Expand Down Expand Up @@ -67,12 +68,12 @@ public class RobotContainer implements Logged {
private Climber climber = new Climber();
private LEDs leds = new LEDs();

private PathConstraints pathConstraints =
private final PathConstraints pathfindingConstraints =
new PathConstraints(
SwerveConstants.maxTranslationalSpeed,
SwerveConstants.maxTranslationalAcceleration,
SwerveConstants.maxAngularSpeed,
SwerveConstants.maxAngularAcceleration);
AutoConstants.pathfindingMaxVelocity,
AutoConstants.pathfindingMaxAcceleration,
AutoConstants.pathfindingMaxAngularVelocity,
AutoConstants.pathfindingMaxAngularAcceleration);

// Replace with CommandPS4Controller or CommandJoystick if needed
private final VirtualXboxController driverController =
Expand Down Expand Up @@ -280,19 +281,24 @@ private void configureDriveBindings() {
.x()
.whileTrue(
new ProxyCommand(
() -> AutoBuilder.pathfindToPose(swerve.getLeftChainPose(), pathConstraints)));
() ->
AutoBuilder.pathfindToPose(swerve.getLeftChainPose(), pathfindingConstraints)));

driverController
.y()
.whileTrue(
new ProxyCommand(
() -> AutoBuilder.pathfindToPose(swerve.getCenterChainPose(), pathConstraints)));
() ->
AutoBuilder.pathfindToPose(
swerve.getCenterChainPose(), pathfindingConstraints)));

driverController
.b()
.whileTrue(
new ProxyCommand(
() -> AutoBuilder.pathfindToPose(swerve.getRightChainPose(), pathConstraints)));
() ->
AutoBuilder.pathfindToPose(
swerve.getRightChainPose(), pathfindingConstraints)));
}

private void configureIntakeBindings() {
Expand Down

0 comments on commit 863ed54

Please sign in to comment.