Skip to content

Commit

Permalink
Use int32_t number to avoid integer overflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueAndi committed Aug 20, 2024
1 parent 1df025c commit 8a411e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Service/src/DifferentialDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void DifferentialDrive::calculateLinearSpeedLeftRight(int16_t linearSpeedCenter,
int32_t wheelBase32 = static_cast<int32_t>(RobotConstants::WHEEL_BASE); /* [mm] */
int32_t encoderStepsPerM32 = static_cast<int32_t>(RobotConstants::ENCODER_STEPS_PER_M); /* [steps/m] */
int32_t linearSpeedTurnInPlace32 =
(angularSpeed32 * wheelBase32 * encoderStepsPerM32) / (2 * 1000 * 1000); /* [steps/s] */
(angularSpeed32 * wheelBase32 * encoderStepsPerM32) / static_cast<int32_t>(2000000); /* [steps/s] */

linearSpeedLeft = halfLinearSpeedCenter32 - linearSpeedTurnInPlace32; /* [steps/s] */
linearSpeedRight = halfLinearSpeedCenter32 + linearSpeedTurnInPlace32; /* [steps/s] */
Expand Down

0 comments on commit 8a411e4

Please sign in to comment.