Skip to content

fix(mobile): reset RandomPath progress between runs - #1006

Open
Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/random-path-progress-reset-20261128
Open

Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/random-path-progress-reset-20261128

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Fixes #1005.

Summary

A seeded RandomPath restarts its random generator and waypoint in init(), but retains the previous waypoint distance. After a one-step run, the restarted vehicle is back at its initial pose and the first waypoint has exactly that stale distance. The no-progress check discards the waypoint, so a fresh and a restarted simulation use different paths despite identical initial conditions and seeds.

For seed 2, a 0.1 s run followed by a 5 s run differs from a fresh 5 s run by up to 2.9019800497003274 in the trajectory array; their first headings are 0.07891548644582533 and 0.02136939104648566.

Reset _d_prev to its initial infinite value alongside _goal. This restores the documented repeatable waypoint sequence across Vehicle.run() resets. The path-following rule within a run and fresh-run results are unchanged; restarted runs affected by the stale distance now reproduce the fresh trajectory.

Add six regression cases covering three seeds and both a one-step and a longer prior run. Each checks two subsequent runs against the complete fresh trajectory.

@Afloat16 is the primary author and responsible owner. Prepared with assistance from ChatGPT (GPT-6 Astra Pro).

Related issue

Fixes #1005; the issue was claimed before implementation.

Validation

Python 3.12.14, NumPy 2.2.6, spatialmath-python 1.1.19, Linux x86-64, Matplotlib Agg. The repository was installed in its supported pure-Python mode (RTB_PURE_WHEEL=1).

  • New regression against main 5aef407: python -m pytest tests/test_mobile.py -k random_path_restarted -q — 3 failed, 3 passed.
  • Fixed source: MPLBACKEND=Agg OMP_NUM_THREADS=2 python -m pytest tests/test_mobile.py tests/test_vehicle_estimators.py tests/test_mobile_workspace.py -q — 194 passed, 6 skipped, 30 subtests passed.
  • ruff format --check src/roboticstoolbox/mobile/drivers.py tests/test_mobile.py — passed.
  • git diff --check — passed.

The complete suite was attempted with the repository's 50 s timeout and stopped in the unrelated tests/test_ik_joint_order.py::test_solution_reproduces_the_pose while evaluating Python inverse kinematics. It did not produce a complete-suite verdict. Native extensions and the documentation build were not validated here.

Whole-package mypy reports the same 24 pre-existing errors on the base and the change. Ruff reports the same eight pre-existing diagnostics in tests/test_mobile.py; the changed production file is clean. No unrelated lint or typing changes are included.

Checklist

  • I checked that no other open PR already addresses this Issue, and commented on the Issue to claim it
  • PR title follows Conventional Commits
  • Tests pass locally (pytest) — targeted suite passes; full-suite limitation is recorded above
  • Added/updated tests for this change, if applicable
  • New/changed code is type-hinted with modern syntax (existing signature unchanged)
  • Docstrings updated — existing documented reset contract is restored; no signature change
  • If this PR is from a fork, Allow edits by maintainers is ticked
  • PR is as small/focused as practical
  • I understand that the Codacy check is advisory; All tests passed and the PR title check are required
  • If this change alters numerical results or public behaviour, I have said so in the summary above
  • If an AI assistant wrote or helped with this change, I have said so in the summary above, and I have read the diff myself
  • No test files, data files, or notebooks specific to your own project

Reset the previous-distance sentinel with the waypoint and random generator
so a prior short run cannot discard the first waypoint after initialisation.
Add repeated-run trajectory regressions for three seeds.

Co-Authored-By: ChatGPT (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.

[Bug]: A short run changes later seeded RandomPath simulations after reset

1 participant