fix(tricycle_controller): check non-strict inequality for M_PI_2 steering boundary
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 exactly M_PI_2 (e.g. at the start of a zero-radius spin maneuver from a straight-line driving state), the strict inequality check alpha_delta > M_PI_2 evaluates to false. The control logic then falls through to the else branch, calculating scale = cos(M_PI_2).
Due to double-precision floating-point limits, cos(M_PI_2) yields ~6.12e-17 instead of the expected 0.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 intended 0.01 speed limit when the error is exactly at the M_PI_2 boundary.
Fixes #2391
Hello @saikishor,
I have added the unit test velocity_attenuation_at_pi_2_boundary to test_tricycle_controller.cpp to verify this boundary behavior. The local test successfully passed (100% passed).
Please let me know if you have any further feedback. Thanks!
Hello @saikishor,
I have added the unit test
velocity_attenuation_at_pi_2_boundarytotest_tricycle_controller.cppto verify this boundary behavior. The local test successfully passed (100% passed).Please let me know if you have any further feedback. Thanks!
Good testing. Thanks for adding it
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 86.67%. Comparing base (a466e1a) to head (0a5106d).
:warning: Report is 19 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #2392 +/- ##
==========================================
- Coverage 86.70% 86.67% -0.03%
==========================================
Files 148 148
Lines 15858 14505 -1353
Branches 1351 1174 -177
==========================================
- Hits 13749 12572 -1177
+ Misses 1613 1502 -111
+ Partials 496 431 -65
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 86.67% <100.00%> (-0.03%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| tricycle_controller/src/tricycle_controller.cpp | 67.34% <100.00%> (+1.89%) |
:arrow_up: |
| ...cycle_controller/test/test_tricycle_controller.cpp | 92.45% <100.00%> (+0.72%) |
:arrow_up: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
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?
@joseph-ros2-dev can you comment on this plz?