Simplify reduce_wheel_speed_until_steering_reached logic#2396
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2396 +/- ##
==========================================
- Coverage 85.60% 85.60% -0.01%
==========================================
Files 148 148
Lines 15829 15828 -1
Branches 1339 1339
==========================================
- Hits 13551 13550 -1
Misses 1792 1792
Partials 486 486
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@joseph-ros2-dev what do you think about this? |
|
Thank you for opening PR #2396 — the Reviewing both PRs together, I found that Issue 1: Discontinuity at the 30° lower boundary (unaddressed by either PR)The current logic applies Numerical verification
Proposed fix:
|
alpha_delta |
Old scale |
Proposed scale |
Delta | Note |
|---|---|---|---|---|
| 100° | 0.0100 | 0.0100 | — | cos < 0 → std::max clamps ✓ |
| 90° (exact) | ~6e-17 | 0.0100 | — | BUG fixed: std::max clamps ✓ |
| 89.43° | 0.0100 | 0.0116 | +0.002 | cos(acos(0.01))/cos(30°) |
| 75° | 0.2588 | 0.2989 | +0.040 | cos(75°)/cos(30°) |
| 60° | 0.5000 | 0.5774 | +0.077 | cos(60°)/cos(30°) |
| 45° | 0.7071 | 0.8165 | +0.109 | cos(45°)/cos(30°) |
| 30° | 0.8660 | 1.0000 | +0.134 | JUMP fixed: cos(30°)/cos(30°) = 1 ✓ |
| 29.9° | 1.0000 | 1.0000 | — | if branch |
| 0° | 1.0000 | 1.0000 | — | if branch |
Summary
| Property | Old code | PR #2392 (>=) |
This proposal |
|---|---|---|---|
| Continuous at 30° | ✗ jump to 0.866 | ✗ jump to 0.866 | ✓ stays at 1.000 |
| Correct at 90° (exact) | ✗ ~6e-17 | ✓ 0.01 | ✓ 0.01 via std::max |
| Needs exact boundary value | depends on M_PI_2 |
depends on M_PI_2 |
✓ not needed |
| Design intent explicit | ✗ | ✗ | ✓ min_scale = 0.01 |
Aligned with steering_kinematics.cpp |
✗ | ✗ | ✓ same normalization |
Would it make sense to update PR #2392 with this approach to address both issues at once, aligned with the same design philosophy as your refactor in #2396?
|
Can we merge this PR here first? Please leave an approval in the github UI if you agree. As a follow-up, let's implement a proper function instead, see the plots from @thedevmystic in #1695 (comment) |
joseph-ros2-dev
left a comment
There was a problem hiding this comment.
LGTM. The normalization approach cleanly resolves the discontinuity.
Ready to proceed with applying the same fix to tricycle_controller in #2392.
Description
While checking #2392 I was confused by the code. I used the chance to simplify the logic a bit.
Is this user-facing behavior change?
Minimal, the scale is continuous now as
cos(max_phi_delta) / cos(min_phi_delta)is not exactly 0.01.Did you use Generative AI?
no
Additional Information