fix: model scripts silently relying on ambient np/mkgrid imports - #46
Open
petercorke wants to merge 1 commit into
Open
fix: model scripts silently relying on ambient np/mkgrid imports#46petercorke wants to merge 1 commit into
petercorke wants to merge 1 commit into
Conversation
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>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
6 of the 12
IBVS-*-main.py/other-main.pyscripts underRVC3/modelswere missing imports their own code (or their.bdfile'seval'd parameter expressions, which run against the calling script's ownglobals()viabdload(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 +.bdexpr),mkgrid(.bdexpr)IBVS-quadrotor-main.py:np,mkgrid(both script body)These only ever worked when
%run -i'd fromrvctool/a notebook, which happens to pre-importnumpyand (viamachinevisiontoolbox.base)mkgridinto the shared namespace before these scripts run -- silently masking the gap. Surfaced by a newrvc3-modelcommand (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
.bdfiles use stale bdsim parameter names, fixed in #45 against different files (.bdJSON, not.py). Non-overlapping changes, will combine cleanly whenever both land.Test plan
BDSIM_NO_GRAPHICS=1 MPLBACKEND=Agg python RVC3/models/<script>.py) past the import/eval stage