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

@@ -68,12 +68,7 @@ frc2::Command* RobotContainer::GetAutonomousCommand() {
frc::SimpleMotorFeedforward<units::meters>(
DriveConstants::ks, DriveConstants::kv, DriveConstants::ka),
DriveConstants::kDriveKinematics,
[this] {
return units::meters_per_second_t(m_drive.GetLeftEncoder().GetRate());
},
[this] {
return units::meters_per_second_t(m_drive.GetRightEncoder().GetRate());
},
[this] { return m_drive.GetWheelSpeeds(); },
frc2::PIDController(DriveConstants::kPDriveVel, 0, 0),
frc2::PIDController(DriveConstants::kPDriveVel, 0, 0),
[this](auto left, auto right) { m_drive.TankDriveVolts(left, right); },

View File

@@ -29,9 +29,7 @@ DriveSubsystem::DriveSubsystem()
void DriveSubsystem::Periodic() {
// Implementation of subsystem periodic method goes here.
m_odometry.Update(frc::Rotation2d(units::degree_t(GetHeading())),
frc::DifferentialDriveWheelSpeeds{
units::meters_per_second_t(m_leftEncoder.GetRate()),
units::meters_per_second_t(m_rightEncoder.GetRate())});
GetWheelSpeeds());
}
void DriveSubsystem::ArcadeDrive(double fwd, double rot) {
@@ -70,6 +68,11 @@ double DriveSubsystem::GetTurnRate() {
frc::Pose2d DriveSubsystem::GetPose() { return m_odometry.GetPose(); }
frc::DifferentialDriveWheelSpeeds DriveSubsystem::GetWheelSpeeds() {
return {units::meters_per_second_t(m_leftEncoder.GetRate()),
units::meters_per_second_t(m_rightEncoder.GetRate())};
}
void DriveSubsystem::ResetOdometry(frc::Pose2d pose) {
m_odometry.ResetPosition(pose,
frc::Rotation2d(units::degree_t(GetHeading())));

View File

@@ -101,6 +101,13 @@ class DriveSubsystem : public frc2::SubsystemBase {
*/
frc::Pose2d GetPose();
/**
* Returns the current wheel speeds of the robot.
*
* @return The current wheel speeds.
*/
frc::DifferentialDriveWheelSpeeds GetWheelSpeeds();
/**
* Resets the odometry to the specified pose.
*