Repository navigation
fix: migrate bdsim %run -m subprocess pattern to %run -i (chap4-9/15/16) - #36
Merged
Merged
Conversation
…x= kwarg Both were raising DeprecationWarnings on every run: DINTEGRATOR is deprecated in favour of INTEGRATOR_S (block names are always allcaps in bdsim's own convention), and PROD's matrix= kwarg has had no effect since matrix-vs-elementwise became auto-detected from input type. Verified both scripts run with zero warnings after the change.
Same run_shell()/subprocess-pickle removal as the chap7/15/16 pass: add models_dir/examples_dir, replace the COLAB if/else with a single %run -i $models_dir/RRMC[2].py. Downstream of that, out.clock0.x was also wrong -- bdsim uses capital X for discrete state (x is for continuous state, empty here since this system is discrete-only) -- which was silently masking a stale q from an unrelated earlier section once out.clock0 itself started raising cleanly instead of falling through a subprocess pickle. Verified end-to-end: RRMC and RRMC2 both run clean under the current (already-fixed) bdsim, and puma.fkine(q) no longer hits the reshape error that was really just a symptom of q never having been correctly assigned. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…del scripts IPython's %run -m resolves names through Python's import machinery, which rejects hyphenated module names -- breaks for every RVC3/models script using the repo's hyphenated-filename convention (walking, jointspace, IBVS-*). Switch to %run -i (file-path mode), matching the pattern already proven in chap4. - chap7: jointspace (COLAB branch) and walking cells; walking.py lives in RVC3/examples/ not RVC3/models/, so add an examples_dir alongside models_dir - chap15: IBVS-main cell; notebook had no models_dir/sys.path setup at all, added it - chap16: same gap plus a bigger one -- the notebook was missing its entire setup/import cell (zero imports anywhere), which was also the root cause of the NameError: SphericalCamera/CentralCamera cells. Added a standard setup cell (imports + models_dir) and fixed all 5 %run -m cells (partitioned/arm/holonomic/nonholonomic/quadrotor) Two things intentionally left out of this migration: - app.ipynb's eigdemo cell: not an RVC3-python file at all -- lives in RTB's own repo with inconsistent packaging (entry_points expects src/roboticstoolbox/examples/, actual file is at repo-root examples/). Needs its own investigation, not a mechanical swap. - Downstream failures once %run -i actually reaches the scripts (walking.py's PyPlot crash, now fixed separately in RTB PR #595; the IBVS scripts' bdsim BlockCreationError, not yet investigated) are out of scope here -- this commit only fixes the invocation mechanics. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Same subprocess-pickle removal as the already-migrated chap4/7/8/15/16: chap5's braitenberg cell and chap9's six bdsim script cells (vloop_test, ploop_test, zerotorque, feedforward, computed-torque-main, opspace, SEA) all switch from the COLAB if/else + run_shell() subprocess pattern to a single unconditional %run -i $models_dir/<script>.py. chap7's jointspace cell (left on the old if/else + run_shell() pattern by the previous migration pass) is fully migrated to match. The now-dead run_shell() def is removed from chap5/7/8/9's imports cells -- confirmed zero remaining references repo-wide. Two bugs caught during verification, fixed here since they're bugs in this migration's own targets, not pre-existing content: - chap9's feedforward cell pointed at a nonexistent feedforward.py -- the actual script is feedforward-main.py (hyphenated, like computed-torque-main.py alongside it). - chap16's IBVS-arm-main cell used out.clock1.x; bdsim uses capital X for discrete state (x is for continuous state) -- same bug class as chap8's clock0.x fix. Downstream bugs newly surfaced now that %run -i actually reaches these scripts are deliberately left unfixed here, matching the precedent set by the original chap7/15/16 migration (walking.py's crash, the IBVS scripts' BlockCreationError): - chap5: braitenberg.py -- BlockCreationError creating VehiclePlot. - chap9: feedforward-main.py -- AttributeError: y0, once the missing-file error above stopped masking it. opspace.py -- RuntimeError: could not compile system (already known, unrelated to this migration). - chap16: IBVS-partitioned/holonomic/nonholonomic/quadrotor-main.py -- BlockCreationError on their first custom block (Camera, Function, MultiRotorMixer) -- same bucket as IBVS-main's failure in chap15, already flagged as not yet investigated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
3 tasks done
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
IPython's
%run -mresolves names through Python's import machinery, which rejects hyphenated module names -- breaks for everyRVC3/modelsscript using the repo's hyphenated-filename convention (walking,jointspace,IBVS-*,computed-torque-main,feedforward-main). It also meant bdsim's older subprocess/run_shell()/pickle-file dance (needed to work around animation issues that no longer exist -- bdsim's notebook animation support now works directly in-kernel) was still hanging around in several notebooks. This branch finishes migrating every remaining bdsim script cell to%run -i $models_dir/<script>.py, which runs the script in place sharing the notebook's own namespace, and removesrun_shell()entirely (confirmed zero references remain repo-wide).out.clock0.xfixed toout.clock0.X(bdsim uses capital X for discrete state).models_dir/sys.pathsetup at all -- added it (chap16 was missing its entire setup cell, root cause of separateNameErrors there).vloop_test,ploop_test,zerotorque,feedforward-main,computed-torque-main,opspace,SEA) migrated;run_shell()def removed from chap5/7/8/9's imports cells.DINTEGRATOR->INTEGRATOR_S, dropped the deprecatedmatrix=kwarg.feedforward.py(actual file isfeedforward-main.py); chap16'sIBVS-arm-maincell usedout.clock1.xinstead of.X(same bug class as chap8's fix).Deliberately left unfixed, matching the precedent already set for
walking.py's crash (fixed separately, RTB PR #595) -- downstream bugs inside the scripts themselves, only surfaced now that%run -iactually reaches them:braitenberg.py--BlockCreationErrorcreatingVehiclePlot.feedforward-main.py--AttributeError: y0.opspace.py--RuntimeError: could not compile system(already known, unrelated to this migration).IBVS-main.pyand 4 of chap16's 5 IBVS scripts --BlockCreationErroron their first custom block (Camera/Function/MultiRotorMixer).Test plan
tests/notebook_runner.pyacross chap5/7/8/9/15/16:run_shellfully gone, no invocation-mechanics failures remain. Only the pre-existing/deferred script-content bugs listed above remain as errors -- everything else that used to fail from the old subprocess pattern now runs clean.🤖 Generated with Claude Code