mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Fix NPE in RamseteCommand (#2019)
This commit is contained in:
@@ -35,10 +35,12 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
|
||||
* the PID and feedforward functionality, returning only the raw wheel speeds from the RAMSETE
|
||||
* controller.
|
||||
*/
|
||||
@SuppressWarnings("PMD.TooManyFields")
|
||||
public class RamseteCommand extends CommandBase {
|
||||
private final Timer m_timer = new Timer();
|
||||
private DifferentialDriveWheelSpeeds m_prevSpeeds;
|
||||
private double m_prevTime;
|
||||
private final boolean m_usePID;
|
||||
|
||||
private final Trajectory m_trajectory;
|
||||
private final Supplier<Pose2d> m_pose;
|
||||
@@ -113,6 +115,8 @@ public class RamseteCommand extends CommandBase {
|
||||
m_rightController = requireNonNullParam(rightController, "rightController", "RamseteCommand");
|
||||
m_output = requireNonNullParam(outputVolts, "outputVolts", "RamseteCommand");
|
||||
|
||||
m_usePID = true;
|
||||
|
||||
addRequirements(requirements);
|
||||
}
|
||||
|
||||
@@ -150,6 +154,8 @@ public class RamseteCommand extends CommandBase {
|
||||
m_leftController = null;
|
||||
m_rightController = null;
|
||||
|
||||
m_usePID = false;
|
||||
|
||||
addRequirements(requirements);
|
||||
}
|
||||
|
||||
@@ -164,8 +170,10 @@ public class RamseteCommand extends CommandBase {
|
||||
* initialState.velocityMetersPerSecond));
|
||||
m_timer.reset();
|
||||
m_timer.start();
|
||||
m_leftController.reset();
|
||||
m_rightController.reset();
|
||||
if (m_usePID) {
|
||||
m_leftController.reset();
|
||||
m_rightController.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,7 +190,7 @@ public class RamseteCommand extends CommandBase {
|
||||
double leftOutput;
|
||||
double rightOutput;
|
||||
|
||||
if (m_leftController != null) {
|
||||
if (m_usePID) {
|
||||
double leftFeedforward =
|
||||
m_ks * Math.signum(leftSpeedSetpoint)
|
||||
+ m_kv * leftSpeedSetpoint
|
||||
|
||||
Reference in New Issue
Block a user