Skip to content

fix: model scripts silently relying on ambient np/mkgrid imports - #46

Open
petercorke wants to merge 1 commit into
mainfrom
fix/model-scripts-missing-imports
Open

fix: model scripts silently relying on ambient np/mkgrid imports#46
petercorke wants to merge 1 commit into
mainfrom
fix/model-scripts-missing-imports

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

6 of the 12 IBVS-*-main.py/other -main.py scripts under RVC3/models were missing imports their own code (or their .bd file's eval'd parameter expressions, which run against the calling script's own globals() via bdload(globalvars=globals())) actually needs:

  • IBVS-arm-main.py: np, mkgrid (both .bd-expression only)
  • IBVS-holonomic-main.py: np (script body)
  • IBVS-main.py: np, mkgrid (both .bd-expression only)
  • IBVS-nonholonomic-main.py: np (script body)
  • IBVS-partitioned-main.py: np (body + .bd expr), mkgrid (.bd expr)
  • IBVS-quadrotor-main.py: np, mkgrid (both script body)

These only ever worked when %run -i'd from rvctool/a notebook, which happens to pre-import numpy and (via machinevisiontoolbox.base) mkgrid into the shared namespace before these scripts run -- silently masking the gap. Surfaced by a new rvc3-model command (companion PR, docs/getting-going) which runs these scripts standalone with no such ambient namespace.

The other 6 scripts an initial grep-for-numpy-import pass flagged (computed-torque-main.py, driveconfig.py, drivepoint.py, feedforward-main.py, jointspace.py, lanechange.py) turned out to be false positives -- they don't need numpy directly and already run clean standalone; left untouched.

3 of the 6 fixed here (holonomic, nonholonomic, quadrotor) still hit a separate, already-tracked bug once past the import stage: their .bd files use stale bdsim parameter names, fixed in #45 against different files (.bd JSON, not .py). Non-overlapping changes, will combine cleanly whenever both land.

Test plan

  • All 6 fixed scripts run standalone (BDSIM_NO_GRAPHICS=1 MPLBACKEND=Agg python RVC3/models/<script>.py) past the import/eval stage
  • The other 6 flagged-but-fine scripts confirmed still running clean, untouched

6 of the 12 IBVS-*-main.py / other -main.py scripts under RVC3/models
were missing imports their own code (or their .bd file's eval'd
parameter expressions, which run against the calling script's own
globals() via bdload(globalvars=globals())) actually needs:

- IBVS-arm-main.py:          np, mkgrid (both .bd-expression only)
- IBVS-holonomic-main.py:    np (script body)
- IBVS-main.py:               np, mkgrid (both .bd-expression only)
- IBVS-nonholonomic-main.py: np (script body)
- IBVS-partitioned-main.py:  np (body + .bd expr), mkgrid (.bd expr)
- IBVS-quadrotor-main.py:    np, mkgrid (both script body)

These only ever worked when %run -i'd from rvctool/a notebook, which
happens to pre-import numpy and (via machinevisiontoolbox.base) mkgrid
into the shared namespace before these scripts run -- silently masking
the gap. Surfaced by the new rvc3-model command (docs/getting-going
branch), which runs these scripts standalone with no such ambient
namespace.

The other 6 scripts flagged by an initial grep-for-numpy-import pass
(computed-torque-main.py, driveconfig.py, drivepoint.py,
feedforward-main.py, jointspace.py, lanechange.py) turned out to be
false positives -- they don't need numpy directly and already run
clean standalone; left untouched.

3 of the 6 fixed here (holonomic, nonholonomic, quadrotor) still hit
a separate, already-tracked bug once past the import stage: their .bd
files use stale bdsim parameter names (args/kwargs -> fargs/fkwargs,
maxw/minw -> wmax/wmin), fixed on fix/notebook-errata against
different files (.bd JSON, not .py). Non-overlapping, will combine
cleanly whenever both branches land.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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