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()
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..b1db48a 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",
@@ -195,9 +172,7 @@
"id": "16",
"metadata": {},
"outputs": [],
- "source": [
- "plt.plot(out.clock1.t, out.clock1.x)"
- ]
+ "source": "plt.plot(out.clock1.t, out.clock1.X)"
},
{
"cell_type": "markdown",
@@ -251,9 +226,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 +242,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 +258,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 +318,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
-}
+}
\ No newline at end of file
diff --git a/notebooks/chap5.ipynb b/notebooks/chap5.ipynb
index 92d686b..0898957 100644
--- a/notebooks/chap5.ipynb
+++ b/notebooks/chap5.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\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')\nsys.path.append(models_dir)\n\n# ------ standard imports ------ #\nimport numpy as np\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",
@@ -69,7 +69,7 @@
"cell_type": "markdown",
"id": "6",
"metadata": {},
- "source": "
\n\n**Warning:** There are issues in running bdsim from inside Jupyter. We have two options, disable all graphics (which is a bit dull) or run bdsim from a subprocess with its own popout windows.\n\nFor Colab we can only do the first option. \n\nOtherwise, we use the wrapper function `run_shell()` defined in the first cell to spawn a new Python instance to run the block diagram which will pop up new windows on your screen to display a simple animation showing the vehicle's motion in the plane. This makes it a bit harder to get parameters and data between Jupyter and the `bdsim` simulation, so:\n* parameter values are passed to `bdsim` as `--global` command line options.\n* the `-o` command line option to `bdsim` causes it to write results as a pickle file, which are then imported back into Jupyter.\n\n
"
+ "source": "\n\n**Note:** Earlier editions of this notebook ran `bdsim` in a subprocess to work around animation issues inside Jupyter. That's no longer necessary — `bdsim`'s notebook animation support now works directly in-kernel, so these examples just use `%run -i` to run the block-diagram script in place, sharing the notebook's own namespace (so parameter variables set above are visible to the script, and its results, e.g. `out`, appear directly here afterward).\n\n
"
},
{
"cell_type": "code",
@@ -77,12 +77,7 @@
"id": "7",
"metadata": {},
"outputs": [],
- "source": [
- "if COLAB:\n",
- " %run -m braitenberg -H -g # no graphics\n",
- "else:\n",
- " run_shell(\"braitenberg\")"
- ]
+ "source": "%run -i $models_dir/braitenberg.py"
},
{
"cell_type": "code",
diff --git a/notebooks/chap7.ipynb b/notebooks/chap7.ipynb
index cb96f37..fc95327 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# ------ 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": "%run -i $models_dir/jointspace.py"
},
{
"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",
diff --git a/notebooks/chap8.ipynb b/notebooks/chap8.ipynb
index bc65e80..56edd99 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# ------ 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",
diff --git a/notebooks/chap9.ipynb b/notebooks/chap9.ipynb
index b290bf6..767c4e1 100644
--- a/notebooks/chap9.ipynb
+++ b/notebooks/chap9.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\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')\nsys.path.append(models_dir)\n\n# ------ standard imports ------ #\nimport numpy as np\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",
@@ -163,12 +163,7 @@
"id": "16",
"metadata": {},
"outputs": [],
- "source": [
- "if COLAB:\n",
- " %run -m vloop_test -H -g # no graphics\n",
- "else:\n",
- " run_shell(\"vloop_test\")"
- ]
+ "source": "%run -i $models_dir/vloop_test.py"
},
{
"cell_type": "markdown",
@@ -184,12 +179,7 @@
"id": "18",
"metadata": {},
"outputs": [],
- "source": [
- "if COLAB:\n",
- " %run -m ploop_test -H -g # no graphics\n",
- "else:\n",
- " run_shell(\"ploop_test\")"
- ]
+ "source": "%run -i $models_dir/ploop_test.py"
},
{
"cell_type": "markdown",
@@ -683,12 +673,7 @@
"id": "67",
"metadata": {},
"outputs": [],
- "source": [
- "if COLAB:\n",
- " %run -m zerotorque -H -g # no graphics\n",
- "else:\n",
- " run_shell(\"zerotorque\")"
- ]
+ "source": "%run -i $models_dir/zerotorque.py"
},
{
"cell_type": "code",
@@ -747,12 +732,7 @@
"id": "73",
"metadata": {},
"outputs": [],
- "source": [
- "if COLAB:\n",
- " %run -m feedforward -H -g # no graphics\n",
- "else:\n",
- " run_shell(\"bdrun feedforward\")"
- ]
+ "source": "%run -i $models_dir/feedforward-main.py"
},
{
"cell_type": "markdown",
@@ -768,12 +748,7 @@
"id": "75",
"metadata": {},
"outputs": [],
- "source": [
- "if COLAB:\n",
- " %run -m computed-torque-main -H -g # no graphics\n",
- "else:\n",
- " run_shell(\"computed-torque-main\")"
- ]
+ "source": "%run -i $models_dir/computed-torque-main.py"
},
{
"cell_type": "markdown",
@@ -849,12 +824,7 @@
"id": "83",
"metadata": {},
"outputs": [],
- "source": [
- "if COLAB:\n",
- " %run -m opspace -H -g # no graphics\n",
- "else:\n",
- " run_shell(\"opspace\")"
- ]
+ "source": "%run -i $models_dir/opspace.py"
},
{
"cell_type": "markdown",
@@ -870,12 +840,7 @@
"id": "85",
"metadata": {},
"outputs": [],
- "source": [
- "if COLAB:\n",
- " %run -m SEA -H -g # no graphics\n",
- "else:\n",
- " run_shell(\"SEA\")"
- ]
+ "source": "%run -i $models_dir/SEA.py"
}
],
"metadata": {