mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[examples] Convert the unitless joystick inputs to actual physical units (#5451)
Taking the joystick inputs from -1 to 1, multiply them by the max speed (as defined in Constants.java) to get the target speed, rather than using the unitless raw joystick inputs.
This commit is contained in:
@@ -35,9 +35,13 @@ RobotContainer::RobotContainer() {
|
||||
m_drive.SetDefaultCommand(frc2::RunCommand(
|
||||
[this] {
|
||||
m_drive.Drive(
|
||||
units::meters_per_second_t{m_driverController.GetLeftY()},
|
||||
units::meters_per_second_t{m_driverController.GetLeftX()},
|
||||
units::radians_per_second_t{m_driverController.GetRightX()}, false);
|
||||
// Multiply by max speed to map the joystick unitless inputs to
|
||||
// actual units. This will map the [-1, 1] to [max speed backwards,
|
||||
// max speed forwards], converting them to actual units.
|
||||
m_driverController.GetLeftY() * AutoConstants::kMaxSpeed,
|
||||
m_driverController.GetLeftX() * AutoConstants::kMaxSpeed,
|
||||
m_driverController.GetRightX() * AutoConstants::kMaxAngularSpeed,
|
||||
false);
|
||||
},
|
||||
{&m_drive}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user