-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert the unitless joystick inputs to actual physical units #5451
Convert the unitless joystick inputs to actual physical units #5451
Conversation
Taking the joystick inputs from -1 to 1, multiply them by the max speed (defined in Constants.java) to get the specified speed.
Here's the corresponding change for C++: diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp
index 52b25b9cb..60b493e52 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp
@@ -34,10 +34,9 @@ RobotContainer::RobotContainer() {
// Turning is controlled by the X axis of the right stick.
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);
+ m_drive.Drive(m_driverController.GetLeftY() * kMaxSpeed,
+ m_driverController.GetLeftX() * kMaxSpeed,
+ m_driverController.GetRightX() * kMaxAngularSpeed, false);
},
{&m_drive}));
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java side looks good, but needs C++.
Taking the joystick inputs from -1 to 1, multiply them by the max speed to get the specified speed.
Made the corresponding change in C++ |
/format |
...les/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/RobotContainer.java
Show resolved
Hide resolved
/format |
The build (GitHub Actions check) was failing in cpp. I used Should be fixed now in the commit. |
/format |
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 resolves issue #5417.