Skip to content

fix(mobile): brake from the applied speed after saturation - #1008

Open
Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/velocity-limit-history-20261129
Open

Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/velocity-limit-history-20261129

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Summary

When a controller repeatedly asks for more than the speed limit, limits_va remembers the velocity before speed clipping. The next acceleration limit therefore starts from a velocity that the vehicle never applied. After 30 derivative evaluations requesting 10 m/s with a 1 m/s speed limit and 1 m/s² acceleration limit at dt=0.1 s, a zero-speed command still returns 1 m/s for the following five evaluations instead of braking through 0.9, 0.8, 0.7, 0.6 and 0.5 m/s.

Record the velocity after both limits have been applied. This changes the numerical response of deriv and u_limited after saturation for Bicycle, Unicycle and DiffSteer; it allows braking immediately at the configured acceleration limit. The ordinary step path applies the limiter twice and can mask this problem. Regressions exercise both direct derivative integration and limited controls, forward/reverse travel, and independently saturated differential-drive wheels.

Contribution owner: @Afloat16. Codex (GPT-6 Astra Pro) assisted with the implementation and regression tests.

Related issue

Newly reproduced problem. Checked the existing acceleration PRs/issues and @Afloat16's contribution history. #937 fixes integer-control truncation, a separate cause; these tests also use current main with that fix already present.

Validation

Linux, Python 3.12.14, NumPy 2.5.5, SciPy 1.18.1, Matplotlib 3.11.2; imported the checkout with PYTHONPATH=src:rtb-data and MPLBACKEND=Agg.

  • New regressions on unchanged base 5aef407ae89cea7dd7edf378dee0757e697cd3bb: 9 failed.
  • python -m pytest tests/test_vehicle_estimators.py tests/test_mobile.py -q: 180 passed, 6 skipped, 30 subtests passed.
  • git diff --check: passed.
  • Ruff reports 17 existing lint findings in these two files; the codes/messages are unchanged from the base. Its format check requests changes to pre-existing estimator tests outside this patch.
  • The complete repository test matrix, type checks and documentation build were not run locally.

Checklist

  • Checked existing PRs and issues for the same problem; this does not claim an existing issue.
  • PR title follows Conventional Commits.
  • Targeted tests pass locally, with the exact scope above.
  • Added regression tests and modern type annotations.
  • No public signatures or docstring contracts change.
  • Allow edits by maintainers is enabled.
  • This PR contains one focused fix.
  • Numerical behaviour changes are described above.
  • No project-specific data or notebooks are included.

Co-Authored-By: Codex (GPT-6 Astra Pro) noreply@openai.com

Store the final limited velocity so subsequent acceleration limits start from the actual speed. Cover braking after forward/reverse saturation for Bicycle, Unicycle and differential-drive models.

Co-Authored-By: Codex (GPT-6 Astra Pro) <noreply@openai.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

This branch has not been deployed

No deployments
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.

1 participant