mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-06 03:31:43 +00:00
[wpimath] Change kinematics.ToTwist2d(end - start) to kinematics.ToTwist2d(start, end) (#5493)
This commit is contained in:
@@ -234,8 +234,16 @@ class SwerveDriveKinematics
|
||||
wpi::array<SwerveModulePosition, NumModules> moduleDeltas) const;
|
||||
|
||||
Twist2d ToTwist2d(
|
||||
const SwerveDriveWheelPositions<NumModules>& wheelDeltas) const override {
|
||||
return ToTwist2d(wheelDeltas.positions);
|
||||
const SwerveDriveWheelPositions<NumModules>& start,
|
||||
const SwerveDriveWheelPositions<NumModules>& end) const override {
|
||||
auto result =
|
||||
wpi::array<SwerveModulePosition, NumModules>(wpi::empty_array);
|
||||
for (size_t i = 0; i < NumModules; i++) {
|
||||
auto startModule = start.positions[i];
|
||||
auto endModule = end.positions[i];
|
||||
result[i] = {endModule.distance - startModule.distance, endModule.angle};
|
||||
}
|
||||
return ToTwist2d(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user