From dae740c22472e0c6a3b3ed6386aa8f4542ed2fb8 Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Sun, 16 Aug 2026 16:18:36 +1000 Subject: [PATCH 1/4] fix: RRMC/RRMC2 -- DINTEGRATOR -> INTEGRATOR_S, drop deprecated matrix= 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. --- RVC3/models/RRMC.py | 4 ++-- RVC3/models/RRMC2.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/RVC3/models/RRMC.py b/RVC3/models/RRMC.py index 81d85a4..3fd8c76 100755 --- a/RVC3/models/RRMC.py +++ b/RVC3/models/RRMC.py @@ -22,8 +22,8 @@ # define the blocks jacobian = bd.JACOBIAN(robot=puma, frame="0", inverse=True, name="Jacobian") velocity = bd.CONSTANT([0, 0.05, 0, 0, 0, 0]) -qdot = bd.PROD("**", matrix=True) -integrator = bd.DINTEGRATOR(clock, x0=q0, name="q") +qdot = bd.PROD("**") +integrator = bd.INTEGRATOR_S(clock, x0=q0, name="q") robot = bd.ARMPLOT(robot=puma, q0=q0, name="plot") # robot = bd.PRINT('{:.3f}') diff --git a/RVC3/models/RRMC2.py b/RVC3/models/RRMC2.py index 89ac7d9..1a3b79e 100755 --- a/RVC3/models/RRMC2.py +++ b/RVC3/models/RRMC2.py @@ -44,8 +44,8 @@ delta = bd.TR2DELTA() jacobian = bd.JACOBIAN(robot=puma, frame="e", inverse=True, name="Jacobian") gain = bd.GAIN(Kp) -qdot = bd.PROD("**", matrix=True) -integrator = bd.DINTEGRATOR(clock, x0=q0, name="q") +qdot = bd.PROD("**") +integrator = bd.INTEGRATOR_S(clock, x0=q0, name="q") fkine = bd.FKINE(puma) robot = bd.ARMPLOT(robot=puma, q0=q0, name="plot") tr2t = bd.TR2T() From 4e8fae582593e4617f22db68b55a10615e27a98a Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Mon, 17 Aug 2026 08:19:28 +1000 Subject: [PATCH 2/4] fix: chap8 -- migrate RRMC/RRMC2 to %run -i, fix clock0.x -> clock0.X 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 --- notebooks/chap8.ipynb | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/notebooks/chap8.ipynb b/notebooks/chap8.ipynb index bc65e80..2665648 100644 --- a/notebooks/chap8.ipynb +++ b/notebooks/chap8.ipynb @@ -32,7 +32,7 @@ "id": "2", "metadata": {}, "outputs": [], - "source": "from IPython.display import HTML\n\nimport matplotlib.pyplot as plt\n\n# add RTB examples folder to the path\nimport sys, os.path\nimport RVC3 as rvc\nsys.path.append(os.path.join(rvc.__path__[0], 'models'))\n\n# helper function to run bdsim in a subprocess and transfer results using a pickle file\nimport pickle\ndef run_shell(tool, **params):\n global out\n pyfile = os.path.join(rvc.__path__[0], \"models\", tool+\".py\")\n cmd = f\"python {pyfile} -H +a -o\"\n for key, value in params.items():\n cmd += f' --global \"{key}={value}\"'\n print(cmd)\n os.system(cmd)\n with open(\"bd.out\", \"rb\") as f:\n out = pickle.load(f)\n\n# ------ standard imports ------ #\nimport numpy as np\nfrom scipy import linalg\nimport math\nfrom math import pi\nnp.set_printoptions(\n linewidth=120, formatter={\n 'float': lambda x: f\"{0:8.4g}\" if abs(x) < 1e-10 else f\"{x:8.4g}\"})\nnp.random.seed(0)\nfrom spatialmath import *\nfrom spatialmath.base import *\nfrom roboticstoolbox import *" + "source": "from IPython.display import HTML\n\nimport matplotlib.pyplot as plt\n\n# add RTB examples folder to the path\nimport sys, os.path\nimport RVC3 as rvc\nmodels_dir = os.path.join(rvc.__path__[0], 'models')\nexamples_dir = os.path.join(rvc.__path__[0], 'examples')\nsys.path.append(models_dir)\n\n# helper function to run bdsim in a subprocess and transfer results using a pickle file\nimport pickle\ndef run_shell(tool, **params):\n global out\n pyfile = os.path.join(rvc.__path__[0], \"models\", tool+\".py\")\n cmd = f\"python {pyfile} -H +a -o\"\n for key, value in params.items():\n cmd += f' --global \"{key}={value}\"'\n print(cmd)\n os.system(cmd)\n with open(\"bd.out\", \"rb\") as f:\n out = pickle.load(f)\n\n# ------ standard imports ------ #\nimport numpy as np\nfrom scipy import linalg\nimport math\nfrom math import pi\nnp.set_printoptions(\n linewidth=120, formatter={\n 'float': lambda x: f\"{0:8.4g}\" if abs(x) < 1e-10 else f\"{x:8.4g}\"})\nnp.random.seed(0)\nfrom spatialmath import *\nfrom spatialmath.base import *\nfrom roboticstoolbox import *" }, { "cell_type": "markdown", @@ -194,12 +194,7 @@ "id": "19", "metadata": {}, "outputs": [], - "source": [ - "if COLAB:\n", - " %run -m RRMC -H -g # no graphics\n", - "else:\n", - " run_shell(\"RRMC\")\n" - ] + "source": "%run -i $models_dir/RRMC.py" }, { "cell_type": "code", @@ -207,10 +202,7 @@ "id": "20", "metadata": {}, "outputs": [], - "source": [ - "t = out.clock0.t;\n", - "q = out.clock0.x;" - ] + "source": "t = out.clock0.t;\nq = out.clock0.X;" }, { "cell_type": "code", @@ -228,12 +220,7 @@ "id": "22", "metadata": {}, "outputs": [], - "source": [ - "from roboticstoolbox.models.DH import Puma560 # need to explicitly import this because we run RRMC in a subprocess\n", - "puma = Puma560()\n", - "\n", - "Tfk = puma.fkine(q);" - ] + "source": "from roboticstoolbox.models.DH import Puma560\npuma = Puma560()\n\nTfk = puma.fkine(q);" }, { "cell_type": "code", @@ -251,12 +238,7 @@ "id": "24", "metadata": {}, "outputs": [], - "source": [ - "if COLAB:\n", - " %run -m RRMC2 -H -g # no graphics\n", - "else:\n", - " run_shell(\"RRMC2\")\n" - ] + "source": "%run -i $models_dir/RRMC2.py" }, { "cell_type": "markdown", From 0babef6d9f6cb98eb813a33da1f159b632caac6a Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Mon, 17 Aug 2026 08:22:03 +1000 Subject: [PATCH 3/4] fix: migrate %run -m to %run -i for chap7/chap15/chap16 hyphenated model 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 --- notebooks/chap15.ipynb | 23 +++------------------- notebooks/chap16.ipynb | 43 +++++++----------------------------------- notebooks/chap7.ipynb | 13 +++---------- 3 files changed, 13 insertions(+), 66 deletions(-) diff --git a/notebooks/chap15.ipynb b/notebooks/chap15.ipynb index 95a40ca..245fedc 100644 --- a/notebooks/chap15.ipynb +++ b/notebooks/chap15.ipynb @@ -43,22 +43,7 @@ "id": "2", "metadata": {}, "outputs": [], - "source": [ - "import numpy as np\n", - "from scipy import linalg\n", - "import matplotlib.pyplot as plt\n", - "import math\n", - "from math import pi\n", - "np.set_printoptions(\n", - " linewidth=120, formatter={\n", - " 'float': lambda x: f\"{0:8.4g}\" if abs(x) < 1e-10 else f\"{x:8.4g}\"})\n", - "np.random.seed(0)\n", - "\n", - "from machinevisiontoolbox.base import *\n", - "from machinevisiontoolbox import *\n", - "from spatialmath.base import *\n", - "from spatialmath import *" - ] + "source": "import numpy as np\nfrom scipy import linalg\nimport matplotlib.pyplot as plt\nimport math\nfrom math import pi\nnp.set_printoptions(\n linewidth=120, formatter={\n 'float': lambda x: f\"{0:8.4g}\" if abs(x) < 1e-10 else f\"{x:8.4g}\"})\nnp.random.seed(0)\n\nfrom machinevisiontoolbox.base import *\nfrom machinevisiontoolbox import *\nfrom spatialmath.base import *\nfrom spatialmath import *\n\nimport sys, os.path\nimport RVC3 as rvc\nmodels_dir = os.path.join(rvc.__path__[0], 'models')" }, { "cell_type": "markdown", @@ -518,9 +503,7 @@ "id": "48", "metadata": {}, "outputs": [], - "source": [ - "%run -m IBVS-main -H" - ] + "source": "%run -i $models_dir/IBVS-main.py -H" }, { "cell_type": "code", @@ -791,4 +774,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file diff --git a/notebooks/chap16.ipynb b/notebooks/chap16.ipynb index dfe9d08..d59b906 100644 --- a/notebooks/chap16.ipynb +++ b/notebooks/chap16.ipynb @@ -44,26 +44,7 @@ "id": "2", "metadata": {}, "outputs": [], - "source": [ - "import sys, os.path\n", - "import RVC3 as rvc\n", - "sys.path.append(os.path.join(rvc.__path__[0], 'models'))\n", - "\n", - "import numpy as np\n", - "from scipy import linalg\n", - "import matplotlib.pyplot as plt\n", - "import math\n", - "from math import pi\n", - "np.set_printoptions(\n", - " linewidth=120, formatter={\n", - " 'float': lambda x: f\"{0:8.4g}\" if abs(x) < 1e-10 else f\"{x:8.4g}\"})\n", - "np.random.seed(0)\n", - "\n", - "from machinevisiontoolbox.base import *\n", - "from machinevisiontoolbox import *\n", - "from spatialmath.base import *\n", - "from spatialmath import *" - ] + "source": "import numpy as np\nfrom scipy import linalg\nimport matplotlib.pyplot as plt\nimport math\nfrom math import pi\nnp.set_printoptions(\n linewidth=120, formatter={\n 'float': lambda x: f\"{0:8.4g}\" if abs(x) < 1e-10 else f\"{x:8.4g}\"})\nnp.random.seed(0)\n\nfrom machinevisiontoolbox.base import *\nfrom machinevisiontoolbox import *\nfrom spatialmath.base import *\nfrom spatialmath import *\n\nimport sys, os.path\nimport RVC3 as rvc\nmodels_dir = os.path.join(rvc.__path__[0], 'models')" }, { "cell_type": "markdown", @@ -79,9 +60,7 @@ "id": "4", "metadata": {}, "outputs": [], - "source": [ - "%run -m IBVS-partitioned-main -H" - ] + "source": "%run -i $models_dir/IBVS-partitioned-main.py -H" }, { "cell_type": "markdown", @@ -185,9 +164,7 @@ "id": "15", "metadata": {}, "outputs": [], - "source": [ - "%run -m IBVS-arm-main -H" - ] + "source": "%run -i $models_dir/IBVS-arm-main.py -H" }, { "cell_type": "code", @@ -251,9 +228,7 @@ "id": "22", "metadata": {}, "outputs": [], - "source": [ - "%run -m IBVS-holonomic-main -H" - ] + "source": "%run -i $models_dir/IBVS-holonomic-main.py -H" }, { "cell_type": "markdown", @@ -269,9 +244,7 @@ "id": "24", "metadata": {}, "outputs": [], - "source": [ - "%run -m IBVS-nonholonomic-main -H" - ] + "source": "%run -i $models_dir/IBVS-nonholonomic-main.py -H" }, { "cell_type": "markdown", @@ -287,9 +260,7 @@ "id": "26", "metadata": {}, "outputs": [], - "source": [ - "%run -m IBVS-quadrotor-main -H" - ] + "source": "%run -i $models_dir/IBVS-quadrotor-main.py -H" }, { "cell_type": "markdown", @@ -349,4 +320,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file diff --git a/notebooks/chap7.ipynb b/notebooks/chap7.ipynb index cb96f37..5d9c00f 100644 --- a/notebooks/chap7.ipynb +++ b/notebooks/chap7.ipynb @@ -32,7 +32,7 @@ "id": "2", "metadata": {}, "outputs": [], - "source": "from IPython.display import HTML\n\nimport matplotlib.pyplot as plt\n\n# add RTB examples folder to the path\nimport sys, os.path\nimport RVC3 as rvc\nsys.path.append(os.path.join(rvc.__path__[0], 'models'))\n\n# helper function to run bdsim in a subprocess and transfer results using a pickle file\nimport pickle\ndef run_shell(tool, **params):\n global out\n pyfile = os.path.join(rvc.__path__[0], \"models\", tool+\".py\")\n cmd = f\"python {pyfile} -H +a -o\"\n for key, value in params.items():\n cmd += f' --global \"{key}={value}\"'\n print(cmd)\n os.system(cmd)\n with open(\"bd.out\", \"rb\") as f:\n out = pickle.load(f)\n \n# ------ standard imports ------ #\nimport numpy as np\nfrom scipy import optimize\nimport math\nfrom math import pi\nnp.set_printoptions(\n linewidth=120, formatter={\n 'float': lambda x: f\"{0:8.4g}\" if abs(x) < 1e-10 else f\"{x:8.4g}\"})\nnp.random.seed(0)\nfrom spatialmath import *\nfrom spatialmath.base import *\nfrom roboticstoolbox import *" + "source": "from IPython.display import HTML\n\nimport matplotlib.pyplot as plt\n\n# add RTB examples folder to the path\nimport sys, os.path\nimport RVC3 as rvc\nmodels_dir = os.path.join(rvc.__path__[0], 'models')\nexamples_dir = os.path.join(rvc.__path__[0], 'examples')\nsys.path.append(models_dir)\n\n# helper function to run bdsim in a subprocess and transfer results using a pickle file\nimport pickle\ndef run_shell(tool, **params):\n global out\n pyfile = os.path.join(rvc.__path__[0], \"models\", tool+\".py\")\n cmd = f\"python {pyfile} -H +a -o\"\n for key, value in params.items():\n cmd += f' --global \"{key}={value}\"'\n print(cmd)\n os.system(cmd)\n with open(\"bd.out\", \"rb\") as f:\n out = pickle.load(f)\n \n# ------ standard imports ------ #\nimport numpy as np\nfrom scipy import optimize\nimport math\nfrom math import pi\nnp.set_printoptions(\n linewidth=120, formatter={\n 'float': lambda x: f\"{0:8.4g}\" if abs(x) < 1e-10 else f\"{x:8.4g}\"})\nnp.random.seed(0)\nfrom spatialmath import *\nfrom spatialmath.base import *\nfrom roboticstoolbox import *" }, { "cell_type": "markdown", @@ -1615,12 +1615,7 @@ "id": "161", "metadata": {}, "outputs": [], - "source": [ - "if COLAB:\n", - " %run -m jointspace -H -g # no graphics\n", - "else:\n", - " run_shell(\"jointspace\")" - ] + "source": "if COLAB:\n %run -i $models_dir/jointspace.py -H -g # no graphics\nelse:\n run_shell(\"jointspace\")" }, { "cell_type": "markdown", @@ -2029,9 +2024,7 @@ "id": "201", "metadata": {}, "outputs": [], - "source": [ - "%run -m walking" - ] + "source": "%run -i $examples_dir/walking.py" }, { "cell_type": "markdown", From fcd16aef21a033fbe421178aa997aee547ba2c5e Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Mon, 17 Aug 2026 08:49:34 +1000 Subject: [PATCH 4/4] fix: complete the run_shell/%run -m -> %run -i migration for chap5/chap9 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/