|
4 | 4 | "cell_type": "markdown", |
5 | 5 | "metadata": {}, |
6 | 6 | "source": [ |
7 | | - "# Dynamics of 2-link manipulator\n", |
| 7 | + "<!-- RTB_HEADER -- generated from the notebook metadata (rtb_header) by sync_bootstrap.py, do not hand-edit -->\n", |
| 8 | + "<table>\n", |
| 9 | + " <tr>\n", |
| 10 | + " <td><div align=\"left\"><font size=\"30\">Robotics Toolbox for Python</font></div></td>\n", |
| 11 | + " <td><img src=\"figs/RobToolBox_RoundLogoB.png\" width=\"300\"></td>\n", |
| 12 | + " </tr>\n", |
| 13 | + "</table>\n", |
8 | 14 | "\n", |
| 15 | + "<p></p>\n", |
| 16 | + "<div align=\"center\" style=\"font-size: 1.5em;\">Dynamics of a 2-link manipulator</div>\n", |
| 17 | + "<p></p>\n", |
| 18 | + "\n", |
| 19 | + "(c) Peter Corke 2026\n", |
| 20 | + "\n", |
| 21 | + "The gravity and velocity torques of the two-link planar arm in Spong, Hutchinson and Vidyasagar, computed by the Toolbox from a DH model and from an ETS model, and compared with the analytic Euler-Lagrange equations.\n", |
| 22 | + "\n", |
| 23 | + "> **Modernised 2026-10-19** to address API drift: this notebook was written for an earlier release of the Toolbox, and has been updated so that it runs with the current one." |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "markdown", |
| 28 | + "metadata": {}, |
| 29 | + "source": [ |
9 | 30 | "\n", |
10 | 31 | "\n", |
11 | 32 | "Reference:\n", |
|
75 | 96 | "metadata": {}, |
76 | 97 | "outputs": [], |
77 | 98 | "source": [ |
78 | | - "from roboticstoolbox import DHRobot, RevoluteDH, ERobot, ELink, ETS\n", |
| 99 | + "from roboticstoolbox import DHRobot, RevoluteDH, Robot, Link, ET\n", |
79 | 100 | "from math import pi, sin, cos\n", |
80 | 101 | "import numpy as np\n", |
81 | 102 | "\n", |
|
119 | 140 | "source": [ |
120 | 141 | "L1 = RevoluteDH(a=l1, m=m1, r=[-lc1, 0, 0])\n", |
121 | 142 | "L2 = RevoluteDH(a=l2, m=m2, r=[-lc2, 0, 0])\n", |
122 | | - "robot = DHRobot([L1, L2], gravity=[0, g, 0])" |
| 143 | + "robot = DHRobot([L1, L2], gravity=[0, -g, 0])" |
123 | 144 | ] |
124 | 145 | }, |
125 | 146 | { |
126 | 147 | "cell_type": "markdown", |
127 | 148 | "metadata": {}, |
128 | 149 | "source": [ |
129 | | - "The DH notation only allows rotation about the z-axis, which is out of the page in the Figure above. Gravity acts downward so we set the gravity acceleration to be `[0, g, 0]` - accelerating upward at `g` provides the weight force experienced on Earth." |
| 150 | + "The DH notation only allows rotation about the z-axis, which is out of the page in the Figure above. The `gravity` argument is the acceleration due to gravity, a vector in the world frame. Gravity acts downward, in the $-y$ direction of the figure, so we set it to `[0, -g, 0]` (the default is `[0, 0, -9.81]`). The gravity load is the torque the joints must exert to hold the arm still against gravity, so it is positive for an arm stretched out horizontally." |
130 | 151 | ] |
131 | 152 | }, |
132 | 153 | { |
|
136 | 157 | "outputs": [], |
137 | 158 | "source": [ |
138 | 159 | "print(robot)\n", |
139 | | - "print(robot.dyntable())" |
| 160 | + "print(robot.dynamics())" |
140 | 161 | ] |
141 | 162 | }, |
142 | 163 | { |
|
268 | 289 | "\n", |
269 | 290 | "L1 = RevoluteDH(a=l1, m=m1, r=[-lc1, 0, 0])\n", |
270 | 291 | "L2 = RevoluteDH(a=l2, m=m2, r=[-lc2, 0, 0])\n", |
271 | | - "robot = DHRobot([L1, L2], gravity=[0, g, 0], symbolic=True)\n", |
| 292 | + "robot = DHRobot([L1, L2], gravity=[0, -g, 0], symbolic=True)\n", |
272 | 293 | "\n", |
273 | 294 | "\n", |
274 | 295 | "q = symbol(\"q_:2\")\n", |
|
280 | 301 | "cell_type": "markdown", |
281 | 302 | "metadata": {}, |
282 | 303 | "source": [ |
283 | | - "## ERobot notation" |
| 304 | + "## ETS notation" |
284 | 305 | ] |
285 | 306 | }, |
286 | 307 | { |
|
324 | 345 | "metadata": {}, |
325 | 346 | "outputs": [], |
326 | 347 | "source": [ |
327 | | - "L1 = ELink(ets=ETS.rz(), m=1, r=[0.5, 0, 0], name=\"L1\")\n", |
328 | | - "L2 = ELink(ets=ETS.tx(1) * ETS.rz(), m=1, r=[0.5, 0, 0], parent=L1, name=\"L2\")\n", |
329 | | - "robot = ERobot([L1, L2], gravity=[0, g, 0])" |
| 348 | + "L1 = Link(ets=ET.Rz(), m=1, r=[0.5, 0, 0], name=\"L1\")\n", |
| 349 | + "L2 = Link(ets=ET.tx(1) * ET.Rz(), m=1, r=[0.5, 0, 0], parent=L1, name=\"L2\")\n", |
| 350 | + "robot = Robot([L1, L2], gravity=[0, -g, 0])" |
330 | 351 | ] |
331 | 352 | }, |
332 | 353 | { |
|
340 | 361 | " tau_el = EL_grav(q)\n", |
341 | 362 | " print(tau_rne, \"vs\", tau_el)" |
342 | 363 | ] |
343 | | - }, |
344 | | - { |
345 | | - "cell_type": "code", |
346 | | - "execution_count": null, |
347 | | - "metadata": {}, |
348 | | - "outputs": [], |
349 | | - "source": [] |
350 | | - }, |
351 | | - { |
352 | | - "cell_type": "code", |
353 | | - "execution_count": null, |
354 | | - "metadata": {}, |
355 | | - "outputs": [], |
356 | | - "source": [] |
357 | | - }, |
358 | | - { |
359 | | - "cell_type": "code", |
360 | | - "execution_count": null, |
361 | | - "metadata": {}, |
362 | | - "outputs": [], |
363 | | - "source": [] |
364 | 364 | } |
365 | 365 | ], |
366 | 366 | "metadata": { |
|
409 | 409 | "_Feature" |
410 | 410 | ], |
411 | 411 | "window_display": false |
| 412 | + }, |
| 413 | + "rtb_header": { |
| 414 | + "title": "Dynamics of a 2-link manipulator", |
| 415 | + "paragraphs": [ |
| 416 | + "The gravity and velocity torques of the two-link planar arm in Spong, Hutchinson and Vidyasagar, computed by the Toolbox from a DH model and from an ETS model, and compared with the analytic Euler-Lagrange equations." |
| 417 | + ], |
| 418 | + "modernised": "2026-10-19" |
412 | 419 | } |
413 | 420 | }, |
414 | 421 | "nbformat": 4, |
|
0 commit comments