-
Couldn't load subscription status.
- Fork 664
[wpimath] Add ChassisAccelerations and drivetrain accelerations classes and add forward and inverse kinematics for accelerations to the interface #8185
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
base: 2027
Are you sure you want to change the base?
Conversation
…r accelerations) and make both classes interpolatable Signed-off-by: Zach Harel <zach@zharel.me>
Signed-off-by: Zach Harel <zach@zharel.me>
Signed-off-by: Zach Harel <zach@zharel.me>
…use it already had the protobuf) and fix toString format Signed-off-by: Zach Harel <zach@zharel.me>
Signed-off-by: Zach Harel <zach@zharel.me>
Signed-off-by: Zach Harel <zach@zharel.me>
…celerations, and SwerveModuleAccelerations with relevant protobufs/structs Signed-off-by: Zach Harel <zach@zharel.me>
…anumDriveWheelAccelerations, and SwerveModuleAccelerations with relevant protobufs/structs Signed-off-by: Zach Harel <zach@zharel.me>
Signed-off-by: Zach Harel <zach@zharel.me>
Signed-off-by: Zach Harel <zach@zharel.me>
…classes to include new third generic parameter Signed-off-by: Zach Harel <zach@zharel.me>
Signed-off-by: Zach Harel <zach@zharel.me>
Signed-off-by: Zach Harel <zach@zharel.me>
Signed-off-by: Zach Harel <zach@zharel.me>
…them and also make gradle happy Signed-off-by: Zach Harel <zach@zharel.me>
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.
Do we need to include adding interpolate() to the wheel speeds classes (and wheel accelerations classes) in this PR? It's already pretty large and doesn't seem directly related.
wpimath/src/main/java/edu/wpi/first/math/kinematics/ChassisAccelerations.java
Outdated
Show resolved
Hide resolved
wpimath/src/main/java/edu/wpi/first/math/kinematics/ChassisAccelerations.java
Outdated
Show resolved
Hide resolved
wpimath/src/main/java/edu/wpi/first/math/kinematics/ChassisAccelerations.java
Outdated
Show resolved
Hide resolved
|
I included the interpolation here solely because it was also something I wanted to add and I didn't want to make another PR |
wpimath/src/main/java/edu/wpi/first/math/kinematics/ChassisAccelerations.java
Show resolved
Hide resolved
…celeration vs velocity Signed-off-by: Zach Harel <zach@zharel.me>
…erations and related files Signed-off-by: Zach Harel <zach@zharel.me>
…of angularAcceleration Signed-off-by: Zach Harel <zach@zharel.me>
…rAcceleration and then Signed-off-by: Zach Harel <zach@zharel.me>
…swerve (which includes angular velocity due to centripetal acceleration component) Signed-off-by: Zach Harel <zach@zharel.me>
…y in module acceleration calculations Signed-off-by: Zach Harel <zach@zharel.me>
wpimath/src/main/java/edu/wpi/first/math/kinematics/ChassisAccelerations.java
Outdated
Show resolved
Hide resolved
wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java
Outdated
Show resolved
Hide resolved
wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java
Outdated
Show resolved
Hide resolved
wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java
Outdated
Show resolved
Hide resolved
wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java
Outdated
Show resolved
Hide resolved
wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java
Outdated
Show resolved
Hide resolved
…rivekinematics to its own method Signed-off-by: Zach Harel <zach@zharel.me>
…ons for clarity Signed-off-by: Zach Harel <zach@zharel.me>
wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp
Outdated
Show resolved
Hide resolved
wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp
Outdated
Show resolved
Hide resolved
wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp
Outdated
Show resolved
Hide resolved
wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp
Outdated
Show resolved
Hide resolved
…cs methods Signed-off-by: Zach Harel <zach@zharel.me>
wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Zach Harel <zach@zharel.me>
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.
Where's the derivation of the swerve drive kinematics math again?
wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h
Outdated
Show resolved
Hide resolved
wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h
Outdated
Show resolved
Hide resolved
wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h
Outdated
Show resolved
Hide resolved
Signed-off-by: Zach Harel <zach@zharel.me>
…erations method Signed-off-by: Zach Harel <zach@zharel.me>
wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java
Show resolved
Hide resolved
…iveKinematics Signed-off-by: Zach Harel <zach@zharel.me>
wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java
Outdated
Show resolved
Hide resolved
… javadoc Signed-off-by: Zach Harel <zach@zharel.me>
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.
Great work! The first PRs always take the longest (and this one is already a really large change)- Thanks for sticking with it!
wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java
Outdated
Show resolved
Hide resolved
| // We already know that our omega should be 2π from the previous test. Next, we need to | ||
| // determine | ||
| // the vx and vy of our chassis center. Because our COR is at a 45 degree angle from the center, |
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.
This isn't super important, but if we're going to end up making changes anyways, could you prevent this single awkward word? (One thing you could do is to briefly join the entire paragraph into one line and then format)
If this would be the only remaining change, it's probably fine to mark this as resolved and then someone can spin off another PR to fix this.
| // FL (12, 12): radius angle = 135°, tangential = 45°, centripetal = -135° → total angle = | ||
| // -144° | ||
| // FR (12, -12): radius angle = 45°, tangential = -45°, centripetal = -135° → total angle = | ||
| // 126° | ||
| // BL (-12, 12): radius angle = 135°, tangential = 45°, centripetal = 45° → total angle = | ||
| // -54° | ||
| // BR (-12, -12): radius angle = -45°, tangential = 45°, centripetal = 135° → total angle = | ||
| // 36° |
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.
Pity this didn't fit, it'd have been really nice if it did. If there's already changes to make that aren't just comment formatting, maybe try this?
| // FL (12, 12): radius angle = 135°, tangential = 45°, centripetal = -135° → total angle = | |
| // -144° | |
| // FR (12, -12): radius angle = 45°, tangential = -45°, centripetal = -135° → total angle = | |
| // 126° | |
| // BL (-12, 12): radius angle = 135°, tangential = 45°, centripetal = 45° → total angle = | |
| // -54° | |
| // BR (-12, -12): radius angle = -45°, tangential = 45°, centripetal = 135° → total angle = | |
| // 36° | |
| // FL (12, 12): radius angle = 135°, tangential = 45°, centripetal = -135° | |
| // → total angle = -144° | |
| // FR (12, -12): radius angle = 45°, tangential = -45°, centripetal = -135° | |
| // → total angle = 126° | |
| // BL (-12, 12): radius angle = 135°, tangential = 45°, centripetal = 45° | |
| // → total angle = -54° | |
| // BR (-12, -12): radius angle = -45°, tangential = 45°, centripetal = 135° | |
| // → total angle = 36° |
Up to you how you want to format it, this is just a suggestion.
| .toArray(Rotation2d[]::new); | ||
|
|
||
| assertAll( | ||
| () -> assertEquals(totalAccel, moduleAccelerations[0].acceleration, 0.1), |
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.
Could the tolerances be changed from 0.1 to kEpsilon? I'm not sure why some of the other tests use 0.1 instead of kEpsilon, but it'd be good to specify a higher level of tolerance.
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.
Does lowering the alpha tolerance in testTurnInPlaceForwardAccelerations work locally?
| // FL (12, 12): radius angle = 135°, tangential = 45°, centripetal = | ||
| // -135° → total angle = -144° FR (12, -12): radius angle = 45°, tangential = | ||
| // -45°, centripetal = -135° → total angle = 126° BL (-12, 12): radius angle | ||
| // = 135°, tangential = 45°, centripetal = 45° → total angle = -54° BR | ||
| // (-12, -12): radius angle = -45°, tangential = 45°, centripetal = 135° → | ||
| // total angle = 36° |
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.
Hm, not sure why the formatting got so messed up.
Signed-off-by: Zach Harel <zach@zharel.me>
…rations Signed-off-by: Zach Harel <zach@zharel.me>
…for precision Signed-off-by: Zach Harel <zach@zharel.me>
wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
|
CI failures:
|
ChassisAccelerations and the drivetrain acceleration types are added in both Java and C++.
ChassisAccelerationsis basically justChassisSpeedsbut for accelerations!DifferentialDriveWheelAccelerations,MecanumDriveWheelAccelerations, andSwerveModuleAccelerationsare the acceleration equivalent of the drivetrain speeds types.In Java, the
Kinematicsinterface now has an additional generic parameterAwhich represents the accelerations, andtoChassisAccelerationsandtoWheelAccelerationsmethods, which are implemented the same way astoChassisSpeedsandtoWheelSpeeds.Protobuf and struct classes were also added for all four classes in Java and C++.