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

@@ -15,8 +15,7 @@ RamseteCommand::RamseteCommand(
frc::RamseteController controller,
frc::SimpleMotorFeedforward<units::meters> feedforward,
frc::DifferentialDriveKinematics kinematics,
std::function<units::meters_per_second_t()> leftSpeed,
std::function<units::meters_per_second_t()> rightSpeed,
std::function<frc::DifferentialDriveWheelSpeeds()> wheelSpeeds,
frc2::PIDController leftController, frc2::PIDController rightController,
std::function<void(volt_t, volt_t)> output,
std::initializer_list<Subsystem*> requirements)
@@ -25,8 +24,7 @@ RamseteCommand::RamseteCommand(
m_controller(controller),
m_feedforward(feedforward),
m_kinematics(kinematics),
m_leftSpeed(leftSpeed),
m_rightSpeed(rightSpeed),
m_speeds(wheelSpeeds),
m_leftController(std::make_unique<frc2::PIDController>(leftController)),
m_rightController(std::make_unique<frc2::PIDController>(rightController)),
m_outputVolts(output),
@@ -82,11 +80,11 @@ void RamseteCommand::Execute() {
auto leftOutput =
volt_t(m_leftController->Calculate(
m_leftSpeed().to<double>(), targetWheelSpeeds.left.to<double>())) +
m_speeds().left.to<double>(), targetWheelSpeeds.left.to<double>())) +
leftFeedforward;
auto rightOutput = volt_t(m_rightController->Calculate(
m_rightSpeed().to<double>(),
m_speeds().right.to<double>(),
targetWheelSpeeds.right.to<double>())) +
rightFeedforward;

View File

@@ -60,10 +60,8 @@ class RamseteCommand : public CommandHelper<CommandBase, RamseteCommand> {
* trajectory.
* @param feedforward A component for calculating the feedforward for the drive.
* @param kinematics The kinematics for the robot drivetrain.
* @param leftSpeed A function that supplies the speed of the left side
* of the robot drive.
* @param rightSpeed A function that supplies the speed of the right side
* of the robot drive.
* @param wheelSpeeds A function that supplies the speeds of the left
* and right sides of the robot drive.
* @param leftController The PIDController for the left side of the robot
* drive.
* @param rightController The PIDController for the right side of the robot
@@ -76,8 +74,7 @@ class RamseteCommand : public CommandHelper<CommandBase, RamseteCommand> {
frc::RamseteController controller,
frc::SimpleMotorFeedforward<units::meters> feedforward,
frc::DifferentialDriveKinematics kinematics,
std::function<units::meters_per_second_t()> leftSpeed,
std::function<units::meters_per_second_t()> rightSpeed,
std::function<frc::DifferentialDriveWheelSpeeds()> wheelSpeeds,
frc2::PIDController leftController,
frc2::PIDController rightController,
std::function<void(units::volt_t, units::volt_t)> output,
@@ -121,8 +118,7 @@ class RamseteCommand : public CommandHelper<CommandBase, RamseteCommand> {
frc::RamseteController m_controller;
frc::SimpleMotorFeedforward<units::meters> m_feedforward;
frc::DifferentialDriveKinematics m_kinematics;
std::function<units::meters_per_second_t()> m_leftSpeed;
std::function<units::meters_per_second_t()> m_rightSpeed;
std::function<frc::DifferentialDriveWheelSpeeds()> m_speeds;
std::unique_ptr<frc2::PIDController> m_leftController;
std::unique_ptr<frc2::PIDController> m_rightController;
std::function<void(units::volt_t, units::volt_t)> m_outputVolts;