Skip to content

Commit d95c3ca

Browse files
author
Murilo M. Marinho
committed
[one_dof_planar_robot.py] Adding dependency of lesson5
1 parent 5c548f4 commit d95c3ca

2 files changed

Lines changed: 105 additions & 164 deletions

File tree

dqrobotics/lesson5/lesson_dq5_robot_control_basics_part1.ipynb

Lines changed: 39 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 391,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -40,7 +40,7 @@
4040
},
4141
{
4242
"cell_type": "code",
43-
"execution_count": 392,
43+
"execution_count": null,
4444
"metadata": {},
4545
"outputs": [],
4646
"source": [
@@ -51,7 +51,7 @@
5151
},
5252
{
5353
"cell_type": "code",
54-
"execution_count": 393,
54+
"execution_count": null,
5555
"metadata": {},
5656
"outputs": [],
5757
"source": [
@@ -156,31 +156,17 @@
156156
},
157157
{
158158
"cell_type": "code",
159-
"execution_count": 394,
160-
"metadata": {},
161-
"outputs": [
162-
{
163-
"name": "stdout",
164-
"output_type": "stream",
165-
"text": [
166-
"\u001b[0;31mSignature:\u001b[0m \u001b[0mOneDofPlanarRobot\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ml1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
167-
"\u001b[0;31mDocstring:\u001b[0m Initialize self. See help(type(self)) for accurate signature.\n",
168-
"\u001b[0;31mSource:\u001b[0m \n",
169-
" \u001b[0;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ml1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
170-
"\u001b[0;34m\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0ml1_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0ml1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
171-
"\u001b[0;31mFile:\u001b[0m ~/git/OpenExecutableBooksRobotics/dqrobotics/lesson5/one_dof_planar_robot.py\n",
172-
"\u001b[0;31mType:\u001b[0m function"
173-
]
174-
}
175-
],
159+
"execution_count": null,
160+
"metadata": {},
161+
"outputs": [],
176162
"source": [
177163
"from one_dof_planar_robot import OneDofPlanarRobot\n",
178164
"OneDofPlanarRobot.__init__??"
179165
]
180166
},
181167
{
182168
"cell_type": "code",
183-
"execution_count": 395,
169+
"execution_count": null,
184170
"metadata": {},
185171
"outputs": [],
186172
"source": [
@@ -196,7 +182,7 @@
196182
},
197183
{
198184
"cell_type": "code",
199-
"execution_count": 396,
185+
"execution_count": null,
200186
"metadata": {},
201187
"outputs": [],
202188
"source": [
@@ -285,52 +271,18 @@
285271
},
286272
{
287273
"cell_type": "code",
288-
"execution_count": 397,
289-
"metadata": {},
290-
"outputs": [
291-
{
292-
"name": "stdout",
293-
"output_type": "stream",
294-
"text": [
295-
"\u001b[0;31mSignature:\u001b[0m \u001b[0mOneDofPlanarRobot\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mikm_tx\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
296-
"\u001b[0;31mSource:\u001b[0m \n",
297-
" \u001b[0;32mdef\u001b[0m \u001b[0mikm_tx\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mtx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
298-
"\u001b[0;34m\u001b[0m \u001b[0;34m'''fkm calculates the IKM for the 1-DoF planar robot using the \u001b[0m\n",
299-
"\u001b[0;34m desired x-axis translation.'''\u001b[0m\u001b[0;34m\u001b[0m\n",
300-
"\u001b[0;34m\u001b[0m \u001b[0;34m\u001b[0m\n",
301-
"\u001b[0;34m\u001b[0m \u001b[0;31m# Return the angle to reach the desired tx\u001b[0m\u001b[0;34m\u001b[0m\n",
302-
"\u001b[0;34m\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0macos\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtx\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0ml1_\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
303-
"\u001b[0;31mFile:\u001b[0m ~/git/OpenExecutableBooksRobotics/dqrobotics/lesson5/one_dof_planar_robot.py\n",
304-
"\u001b[0;31mType:\u001b[0m function"
305-
]
306-
}
307-
],
274+
"execution_count": null,
275+
"metadata": {},
276+
"outputs": [],
308277
"source": [
309278
"OneDofPlanarRobot.ikm_tx??"
310279
]
311280
},
312281
{
313282
"cell_type": "code",
314-
"execution_count": 398,
315-
"metadata": {},
316-
"outputs": [
317-
{
318-
"name": "stdout",
319-
"output_type": "stream",
320-
"text": [
321-
"\u001b[0;31mSignature:\u001b[0m \u001b[0mOneDofPlanarRobot\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mikm_ty\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mty\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
322-
"\u001b[0;31mSource:\u001b[0m \n",
323-
" \u001b[0;32mdef\u001b[0m \u001b[0mikm_ty\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mty\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
324-
"\u001b[0;34m\u001b[0m \u001b[0;34m'''fkm calculates the IKM for the 1-DoF planar robot using the \u001b[0m\n",
325-
"\u001b[0;34m desired y-axis translation.'''\u001b[0m\u001b[0;34m\u001b[0m\n",
326-
"\u001b[0;34m\u001b[0m \u001b[0;34m\u001b[0m\n",
327-
"\u001b[0;34m\u001b[0m \u001b[0;31m# Return the angle to reach the desired ty\u001b[0m\u001b[0;34m\u001b[0m\n",
328-
"\u001b[0;34m\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0masin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mty\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0ml1_\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
329-
"\u001b[0;31mFile:\u001b[0m ~/git/OpenExecutableBooksRobotics/dqrobotics/lesson5/one_dof_planar_robot.py\n",
330-
"\u001b[0;31mType:\u001b[0m function"
331-
]
332-
}
333-
],
283+
"execution_count": null,
284+
"metadata": {},
285+
"outputs": [],
334286
"source": [
335287
"OneDofPlanarRobot.ikm_ty??"
336288
]
@@ -345,7 +297,7 @@
345297
},
346298
{
347299
"cell_type": "code",
348-
"execution_count": 399,
300+
"execution_count": null,
349301
"metadata": {},
350302
"outputs": [],
351303
"source": [
@@ -375,7 +327,7 @@
375327
},
376328
{
377329
"cell_type": "code",
378-
"execution_count": 400,
330+
"execution_count": null,
379331
"metadata": {},
380332
"outputs": [],
381333
"source": [
@@ -441,43 +393,18 @@
441393
},
442394
{
443395
"cell_type": "code",
444-
"execution_count": 401,
445-
"metadata": {},
446-
"outputs": [
447-
{
448-
"name": "stdout",
449-
"output_type": "stream",
450-
"text": [
451-
"\u001b[0;31mSignature:\u001b[0m \u001b[0mOneDofPlanarRobot\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtranslation_jacobian\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtheta1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
452-
"\u001b[0;31mSource:\u001b[0m \n",
453-
" \u001b[0;32mdef\u001b[0m \u001b[0mtranslation_jacobian\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mtheta1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
454-
"\u001b[0;34m\u001b[0m \u001b[0;34m''' Calculates the translation Jacobian of the 1-DoF planar\u001b[0m\n",
455-
"\u001b[0;34m robot. '''\u001b[0m\u001b[0;34m\u001b[0m\n",
456-
"\u001b[0;34m\u001b[0m \u001b[0;34m\u001b[0m\n",
457-
"\u001b[0;34m\u001b[0m \u001b[0mj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0ml1_\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0mi_\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0msin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtheta1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mj_\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mcos\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtheta1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
458-
"\u001b[0;34m\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mvec3\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
459-
"\u001b[0;31mFile:\u001b[0m ~/git/OpenExecutableBooksRobotics/dqrobotics/lesson5/one_dof_planar_robot.py\n",
460-
"\u001b[0;31mType:\u001b[0m function"
461-
]
462-
}
463-
],
396+
"execution_count": null,
397+
"metadata": {},
398+
"outputs": [],
464399
"source": [
465400
"OneDofPlanarRobot.translation_jacobian??"
466401
]
467402
},
468403
{
469404
"cell_type": "code",
470-
"execution_count": 402,
471-
"metadata": {},
472-
"outputs": [
473-
{
474-
"name": "stdout",
475-
"output_type": "stream",
476-
"text": [
477-
"Corresponding end effector velocity\n"
478-
]
479-
}
480-
],
405+
"execution_count": null,
406+
"metadata": {},
407+
"outputs": [],
481408
"source": [
482409
"# Length\n",
483410
"l1 = 1\n",
@@ -499,17 +426,9 @@
499426
},
500427
{
501428
"cell_type": "code",
502-
"execution_count": 403,
503-
"metadata": {},
504-
"outputs": [
505-
{
506-
"name": "stdout",
507-
"output_type": "stream",
508-
"text": [
509-
"t_dot = [-0.00302661 -0.35998728 -0. ]\n"
510-
]
511-
}
512-
],
429+
"execution_count": null,
430+
"metadata": {},
431+
"outputs": [],
513432
"source": [
514433
"t_dot = Jt*theta1_dot\n",
515434
"print(f\"t_dot = {t_dot}\")"
@@ -548,17 +467,9 @@
548467
},
549468
{
550469
"cell_type": "code",
551-
"execution_count": 404,
552-
"metadata": {},
553-
"outputs": [
554-
{
555-
"name": "stdout",
556-
"output_type": "stream",
557-
"text": [
558-
"t_dot = - 0.19i + 0.74j - 0.71k\n"
559-
]
560-
}
561-
],
470+
"execution_count": null,
471+
"metadata": {},
472+
"outputs": [],
562473
"source": [
563474
"# Length\n",
564475
"l1 = 1\n",
@@ -583,17 +494,9 @@
583494
},
584495
{
585496
"cell_type": "code",
586-
"execution_count": 405,
497+
"execution_count": null,
587498
"metadata": {},
588-
"outputs": [
589-
{
590-
"name": "stdout",
591-
"output_type": "stream",
592-
"text": [
593-
"Corresponding joint velocity\n"
594-
]
595-
}
596-
],
499+
"outputs": [],
597500
"source": [
598501
"\n",
599502
"# Get the translation jacobian, based on theta\n",
@@ -605,17 +508,9 @@
605508
},
606509
{
607510
"cell_type": "code",
608-
"execution_count": 406,
609-
"metadata": {},
610-
"outputs": [
611-
{
612-
"name": "stdout",
613-
"output_type": "stream",
614-
"text": [
615-
"theta_dot = [-0.62168767]\n"
616-
]
617-
}
618-
],
511+
"execution_count": null,
512+
"metadata": {},
513+
"outputs": [],
619514
"source": [
620515
"from dqrobotics.utils.DQ_LinearAlgebra import pinv\n",
621516
"\n",
@@ -659,17 +554,9 @@
659554
},
660555
{
661556
"cell_type": "code",
662-
"execution_count": 407,
663-
"metadata": {},
664-
"outputs": [
665-
{
666-
"name": "stdout",
667-
"output_type": "stream",
668-
"text": [
669-
"Running control loop for 251 iterations.\n"
670-
]
671-
}
672-
],
557+
"execution_count": null,
558+
"metadata": {},
559+
"outputs": [],
673560
"source": [
674561
"import numpy as np\n",
675562
"\n",
@@ -713,7 +600,7 @@
713600
},
714601
{
715602
"cell_type": "code",
716-
"execution_count": 408,
603+
"execution_count": null,
717604
"metadata": {},
718605
"outputs": [],
719606
"source": [
@@ -752,7 +639,7 @@
752639
},
753640
{
754641
"cell_type": "code",
755-
"execution_count": 409,
642+
"execution_count": null,
756643
"metadata": {},
757644
"outputs": [],
758645
"source": [
@@ -845,19 +732,7 @@
845732
"cell_type": "code",
846733
"execution_count": null,
847734
"metadata": {},
848-
"outputs": [
849-
{
850-
"ename": "AttributeError",
851-
"evalue": "'OneDofPlanarRobot' object has no attribute 'plot'",
852-
"output_type": "error",
853-
"traceback": [
854-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
855-
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
856-
"Cell \u001b[0;32mIn[410], line 52\u001b[0m\n\u001b[1;32m 49\u001b[0m theta1 \u001b[38;5;241m=\u001b[39m theta1 \u001b[38;5;241m+\u001b[39m theta1_dot\u001b[38;5;241m*\u001b[39mtau\n\u001b[1;32m 51\u001b[0m \u001b[38;5;66;03m# Plot the robot\u001b[39;00m\n\u001b[0;32m---> 52\u001b[0m \u001b[43mone_dof_planar_robot\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mplot\u001b[49m(theta1)\n\u001b[1;32m 54\u001b[0m \u001b[38;5;66;03m# Plot the desired position\u001b[39;00m\n\u001b[1;32m 55\u001b[0m \u001b[38;5;66;03m#hold on\u001b[39;00m\n\u001b[1;32m 56\u001b[0m \u001b[38;5;66;03m#plot(tx,ty,'bx')\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 60\u001b[0m \u001b[38;5;66;03m#drawnow; % [For animations only] Ask MATLAB to draw the plot now\u001b[39;00m\n\u001b[1;32m 61\u001b[0m \u001b[38;5;66;03m#pause(0.001) % [For animations only] Pause so that MATLAB has enough time to draw the plot\u001b[39;00m\n",
857-
"\u001b[0;31mAttributeError\u001b[0m: 'OneDofPlanarRobot' object has no attribute 'plot'"
858-
]
859-
}
860-
],
735+
"outputs": [],
861736
"source": [
862737
"# Length\n",
863738
"l1 = 1\n",

0 commit comments

Comments
 (0)