Repository navigation
fix(servos): cap the slew step after a stalled loop - #120
Conversation
ServoWrapper::update() sized each step from the time since the joint's previous step. A blocking call (smooth or calibration move, flash write) that stalled the loop while a joint was slewing let it cover speed x stall time in one step: a 3 s calibration move at 25 deg/s made another joint jump 75 deg at once. stop() also left that timestamp behind, so a later setTarget could time its first step from the old stop. Cap the step gap at 100 ms (servoSlewNext in servos.h) and reset the timestamp in stop(). Adds a native test for the step math.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Thanks for this. The 100 ms cap in servoSlewNext() and the lastUpdateMs_ reset in stop() keep a stalled loop from dumping a whole slew into one step. |
ServoWrapper::update()sizes each step from the time since the joint's previous step. When a blocking call stalls the loop while a joint is still slewing (a smooth or calibration move such asPOST /test/servoorPOST /setup/servo, or a flash write), the next step covers speed x stall time in one go. Example: a 3 s calibration move at 25 deg/s made another joint that was still slewing jump 75 deg at once instead of slewing.stop()also left that timestamp in place, so a latersetTarget()could time its first step from the old stop.Changes:
servoSlewNext()ininclude/servos.hholds the step math and caps the gap atSERVO_MAX_STEP_GAP_MS(100 ms, ten loop steps), so a stalled joint resumes at its commanded speed.ServoWrapper::stop()resetslastUpdateMs_.test/test_servo_slew.Normal loop timing is unchanged: steps under 100 ms behave exactly as before.
Testing:
pio test -e native -f test_servo_slew -f test_servo_normpasses. Found and checked on an ESP32 build of this firmware (LEDC servo outputs) with 5 SG90s on the bench.Summary by CodeRabbit