1
Fork 0

time conversion

This commit is contained in:
Andy Killorin 2024-10-23 20:11:01 -04:00
parent e2b0360f10
commit 6e51d4f249
Signed by: ank
GPG key ID: 23F9463ECB67FE8C
2 changed files with 3 additions and 2 deletions

View file

@ -117,8 +117,8 @@ void Chassis::UpdateMotors(void)
*/ */
void Chassis::SetWheelSpeeds(float leftSpeedCMperSec, float rightSpeedCMperSec) void Chassis::SetWheelSpeeds(float leftSpeedCMperSec, float rightSpeedCMperSec)
{ {
leftMotor.SetTargetSpeed(leftSpeedCMperSec * LEFT_TICKS_PER_CM); leftMotor.SetTargetSpeed(leftSpeedCMperSec * LEFT_TICKS_PER_CM * SECONDS_PER_CONTROL_LOOP);
rightMotor.SetTargetSpeed(rightSpeedCMperSec * RIGHT_TICKS_PER_CM); rightMotor.SetTargetSpeed(rightSpeedCMperSec * RIGHT_TICKS_PER_CM * SECONDS_PER_CONTROL_LOOP);
} }
/** /**

View file

@ -19,6 +19,7 @@ protected:
* avoid rounding errors. * avoid rounding errors.
*/ */
const uint16_t CONTROL_LOOP_PERIOD_MS = 20; const uint16_t CONTROL_LOOP_PERIOD_MS = 20;
const float SECONDS_PER_CONTROL_LOOP = 1. / CONTROL_LOOP_PERIOD_MS;
protected: protected:
/** /**