fix(tricycle_controller): check non-strict inequality for M_PI_2 steering boundary#2392
Conversation
saikishor
left a comment
There was a problem hiding this comment.
Hello,
Can you add a test case for this change?
|
Hello @saikishor, I have added the unit test Please let me know if you have any further feedback. Thanks! |
Good testing. Thanks for adding it |
christophfroehlich
left a comment
There was a problem hiding this comment.
I'm not entirely sure if this state makes sense. This logic just reduces wheel speed until the steering angle is reached. why should it not stop if the delta_angle is Pi/2?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2392 +/- ##
==========================================
+ Coverage 85.60% 85.65% +0.04%
==========================================
Files 148 148
Lines 15829 15842 +13
Branches 1339 1339
==========================================
+ Hits 13551 13569 +18
+ Misses 1792 1788 -4
+ Partials 486 485 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This PR addresses the edge case in the steering error attenuation mechanism of the tricycle controller.
Description
When the steering angle error (
alpha_delta) is exactlyM_PI_2(e.g. at the start of a zero-radius spin maneuver from a straight-line driving state), the strict inequality checkalpha_delta > M_PI_2evaluates tofalse. The control logic then falls through to theelsebranch, calculatingscale = cos(M_PI_2).Due to double-precision floating-point limits,
cos(M_PI_2)yields~6.12e-17instead of the expected0.01(1% speed limit), virtually halting the wheel command entirely on the first control cycle.Solution
Changing the strict inequality
>to>=in the boundary check allows the controller to correctly apply the intended0.01speed limit when the error is exactly at theM_PI_2boundary.Fixes #2391