Skip to content

fix(tricycle_controller): check non-strict inequality for M_PI_2 steering boundary#2392

Open
joseph-ros2-dev wants to merge 3 commits into
ros-controls:masterfrom
joseph-ros2-dev:fix-tricycle-controller-pi-2-boundary
Open

fix(tricycle_controller): check non-strict inequality for M_PI_2 steering boundary#2392
joseph-ros2-dev wants to merge 3 commits into
ros-controls:masterfrom
joseph-ros2-dev:fix-tricycle-controller-pi-2-boundary

Conversation

@joseph-ros2-dev

Copy link
Copy Markdown

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

@saikishor saikishor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

Can you add a test case for this change?

@joseph-ros2-dev

Copy link
Copy Markdown
Author

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!

@saikishor

Copy link
Copy Markdown
Member

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!

Good testing. Thanks for adding it

@christophfroehlich christophfroehlich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.65%. Comparing base (2850cc4) to head (5bcc2e1).

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     
Flag Coverage Δ
unittests 85.65% <100.00%> (+0.04%) ⬆️

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%) ⬆️
...cycle_controller/test/test_tricycle_controller.cpp 92.45% <100.00%> (+0.72%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(tricycle_controller): strict inequality for M_PI_2 boundary causes speed scale to drop to ~0 instead of 0.01 limit

3 participants