Convert the unitless joystick inputs to actual physical units#5451
Merged
PeterJohnson merged 7 commits intowpilibsuite:mainfrom Jul 18, 2023
Merged
Conversation
Taking the joystick inputs from -1 to 1, multiply them by the max speed (defined in Constants.java) to get the specified speed.
Member
|
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}));
} |
calcmogul
requested changes
Jul 17, 2023
Member
calcmogul
left a comment
There was a problem hiding this comment.
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.
Contributor
Author
|
Made the corresponding change in C++ |
Member
|
/format |
calcmogul
requested changes
Jul 17, 2023
...les/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/RobotContainer.java
Show resolved
Hide resolved
calcmogul
previously approved these changes
Jul 17, 2023
Member
|
/format |
calcmogul
previously approved these changes
Jul 17, 2023
Contributor
Author
|
The build (GitHub Actions check) was failing in cpp. I used Should be fixed now in the commit. |
Member
|
/format |
calcmogul
approved these changes
Jul 17, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.