Use DifferentialDriveWheelSpeeds in RamseteCommand ctor (#2091)

This commit is contained in:
Prateek Machiraju
2019-11-19 01:11:05 -05:00
committed by Peter Johnson
parent b37b68daaf
commit 5891628112
8 changed files with 61 additions and 70 deletions

View File

@@ -118,8 +118,7 @@ public class RobotContainer {
new RamseteController(kRamseteB, kRamseteZeta),
new SimpleMotorFeedforward(ksVolts, kvVoltSecondsPerMeter, kaVoltSecondsSquaredPerMeter),
kDriveKinematics,
m_robotDrive.getLeftEncoder()::getRate,
m_robotDrive.getRightEncoder()::getRate,
m_robotDrive::getWheelSpeeds,
new PIDController(kPDriveVel, 0, 0),
new PIDController(kPDriveVel, 0, 0),
// RamseteCommand passes volts to the callback

View File

@@ -72,11 +72,7 @@ public class DriveSubsystem extends SubsystemBase {
@Override
public void periodic() {
// Update the odometry in the periodic block
m_odometry.update(Rotation2d.fromDegrees(getHeading()),
new DifferentialDriveWheelSpeeds(
m_leftEncoder.getRate(),
m_rightEncoder.getRate()
));
m_odometry.update(Rotation2d.fromDegrees(getHeading()), getWheelSpeeds());
}
/**
@@ -88,6 +84,15 @@ public class DriveSubsystem extends SubsystemBase {
return m_odometry.getPoseMeters();
}
/**
* Returns the current wheel speeds of the robot.
*
* @return The current wheel speeds.
*/
public DifferentialDriveWheelSpeeds getWheelSpeeds() {
return new DifferentialDriveWheelSpeeds(m_leftEncoder.getRate(), m_rightEncoder.getRate());
}
/**
* Resets the odometry to the specified pose.
*