Skip to content

Conversation

@zachwaffle4
Copy link

ChassisAccelerations and the drivetrain acceleration types are added in both Java and C++. ChassisAccelerations is basically just ChassisSpeeds but for accelerations! DifferentialDriveWheelAccelerations, MecanumDriveWheelAccelerations, and SwerveModuleAccelerations are the acceleration equivalent of the drivetrain speeds types.

In Java, the Kinematics interface now has an additional generic parameter A which represents the accelerations, and toChassisAccelerations and toWheelAccelerations methods, which are implemented the same way as toChassisSpeeds and toWheelSpeeds.

Protobuf and struct classes were also added for all four classes in Java and C++.

…r accelerations) and make both classes interpolatable

Signed-off-by: Zach Harel <[email protected]>
…use it already had the protobuf) and fix toString format

Signed-off-by: Zach Harel <[email protected]>
Signed-off-by: Zach Harel <[email protected]>
…celerations, and SwerveModuleAccelerations with relevant protobufs/structs

Signed-off-by: Zach Harel <[email protected]>
…anumDriveWheelAccelerations, and SwerveModuleAccelerations with relevant protobufs/structs

Signed-off-by: Zach Harel <[email protected]>
Signed-off-by: Zach Harel <[email protected]>
…classes to include new third generic parameter

Signed-off-by: Zach Harel <[email protected]>
…them and also make gradle happy

Signed-off-by: Zach Harel <[email protected]>
@zachwaffle4 zachwaffle4 requested a review from a team as a code owner August 22, 2025 00:17
@github-actions github-actions bot added component: wpimath Math library 2027 2027 target labels Aug 22, 2025
Copy link
Contributor

@KangarooKoala KangarooKoala left a 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.

@zachwaffle4
Copy link
Author

I included the interpolation here solely because it was also something I wanted to add and I didn't want to make another PR

…swerve (which includes angular velocity due to centripetal acceleration component)

Signed-off-by: Zach Harel <[email protected]>
…y in module acceleration calculations

Signed-off-by: Zach Harel <[email protected]>
…ematic-acceleration

# Conflicts:
#	wpimath/src/main/native/cpp/kinematics/proto/SwerveModuleAccelerationsProto.cpp
#	wpimath/src/main/native/cpp/kinematics/struct/ChassisAccelerationsStruct.cpp
#	wpimath/src/main/native/cpp/kinematics/struct/DifferentialDriveWheelAccelerationsStruct.cpp
#	wpimath/src/main/native/cpp/kinematics/struct/MecanumDriveWheelAccelerationsStruct.cpp
#	wpimath/src/main/native/cpp/kinematics/struct/SwerveModuleAccelerationsStruct.cpp
#	wpimath/src/main/native/include/wpi/math/kinematics/ChassisAccelerations.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/DifferentialDriveWheelAccelerations.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/MecanumDriveWheelAccelerations.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/SwerveModuleAccelerations.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/proto/ChassisAccelerationsProto.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/proto/DifferentialDriveWheelAccelerationsProto.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/proto/MecanumDriveWheelAccelerationsProto.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/proto/SwerveModuleAccelerationsProto.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/struct/ChassisAccelerationsStruct.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/struct/DifferentialDriveWheelAccelerationsStruct.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/struct/MecanumDriveWheelAccelerationsStruct.hpp
#	wpimath/src/main/native/include/wpi/math/kinematics/struct/SwerveModuleAccelerationsStruct.hpp
Signed-off-by: Zach Harel <[email protected]>
calcmogul
calcmogul previously approved these changes Nov 20, 2025
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was #8185 (comment) ever resolved?

@zachwaffle4
Copy link
Author

Was #8185 (comment) ever resolved?

yes (just now)

Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So close...

Comment on lines 40 to 41
* @tparam WheelSpeeds Wheel speeds type.
* @tparam WheelPositions Wheel positions type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @tparam WheelSpeeds Wheel speeds type.
* @tparam WheelPositions Wheel positions type.
* @tparam WheelPositions Wheel positions type.
* @tparam WheelSpeeds Wheel speeds type.

Comment on lines 46 to 47
* @tparam WheelSpeeds Wheel speeds type.
* @tparam WheelPositions Wheel positions type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @tparam WheelSpeeds Wheel speeds type.
* @tparam WheelPositions Wheel positions type.
* @tparam WheelPositions Wheel positions type.
* @tparam WheelSpeeds Wheel speeds type.

Comment on lines 25 to 26
* @tparam WheelSpeeds Wheel speeds type.
* @tparam WheelPositions Wheel positions type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @tparam WheelSpeeds Wheel speeds type.
* @tparam WheelPositions Wheel positions type.
* @tparam WheelPositions Wheel positions type.
* @tparam WheelSpeeds Wheel speeds type.

Comment on lines 28 to 29
* @tparam WheelSpeeds Wheel speeds type.
* @tparam WheelPositions Wheel positions type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @tparam WheelSpeeds Wheel speeds type.
* @tparam WheelPositions Wheel positions type.
* @tparam WheelPositions Wheel positions type.
* @tparam WheelSpeeds Wheel speeds type.

@Override
public void pack(ProtobufSwerveModuleAcceleration msg, SwerveModuleAcceleration value) {
msg.setAcceleration(value.acceleration);
Rotation2d.proto.pack(msg.getAngle(), value.angle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Rotation2d.proto.pack(msg.getAngle(), value.angle);
Rotation2d.proto.pack(msg.getMutableAngle(), value.angle);

Unpacking doesn't need to be mutable, but packing does (since that's when we modify msg).

@Override
public SwerveModuleAcceleration unpack(ProtobufSwerveModuleAcceleration msg) {
return new SwerveModuleAcceleration(
msg.getAcceleration(), Rotation2d.proto.unpack(msg.getMutableAngle()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg.getAcceleration(), Rotation2d.proto.unpack(msg.getMutableAngle()));
msg.getAcceleration(), Rotation2d.proto.unpack(msg.getAngle()));

This doesn't need to be mutable since we're only unpacking (so we don't modify anything).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2027 2027 target component: wpimath Math library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants