Robotics Toolbox for Python

936 views
Skip to first unread message

Abigail Pop

unread,
Mar 25, 2021, 9:56:10 AM3/25/21
to Robotics & Machine Vision Toolboxes
Hello, I am trying to just check the se of the re=obotic toolbox for the planar 2D and 3D robots. I am currently plotting the final configuration against time, but as you can see in the picture attached, the trajectory is not exactly something to aim for.

I am thinking that my mistake in the code for the 2D Planar robot comes from the definition of the IK:

T1 =  SE3(1, 1, 0)
sol1 = robot1.ikine_LM(T1)  # solve IK
q_pickup1 = sol1.q

However, it is not completely clear to me from the documentation, how this should be defined in terms of pose and orientation for planar robots? I initially considered that I might have to use the SE2 for it, but is seems that when I inspect the ikine function only works with SE3?

Thank you.

Figure 2021-03-25 130852.png

Peter Corke

unread,
Mar 27, 2021, 1:18:39 AM3/27/21
to Robotics & Machine Vision Toolboxes
Hi Abigail, could you rephase the question, am not sure what you are asking.  At the moment there is no explicit support for planar robots, but is planned

Peter

Abigail Pop

unread,
Apr 6, 2021, 10:40:06 AM4/6/21
to Robotics & Machine Vision Toolboxes
Hello,

Thank you for your reply.

I am currently trying to get familiar with the library, so I am trying to use the functions for dynamics & kinematics for the 2D & 3D planar robots.
I am now stuck due to two main questions:

1. When calling the DH Parameters of a robot, I saw there is a second table(I saw it in your example with Puma & I am seeing it also when I print the DH for my 2D planar robot). Just so you know, what I make reference to, I am attaching the print screen from Puma as it has more components:

Capture.JPG

I was wondering if I can find somewhere an explanation for what these parameters are? I see that in the table for a 2D planar, this second table does not have the same form, but the difference between the 2, still does not make me understand what each value represents.
This leads me to a side question: is it not possible to call the dynamics functions for the planar robots?

2. The second question appears from the kinematics functions of the robots. When I am trying to plot with the function: robot1.plot(q, movie='2D_sim.gif'), I get some errors in the gif. One of them is that code does not print anything that is printed after the plot (I even waited for longer periods, but the plotting seems to not have an end) & the image does not appear to be saved or showed in the plot window of Spyder as a .gif file. I was wondering if you see something wrong with my code? Or have an explanation for how I can achieve the proper results.
 
Capture2.JPG

Hope, I was more clear in explaining my issues this time & thank you in advance,
Abigail POP

Himanshu Varshney

unread,
Apr 9, 2021, 7:38:22 AM4/9/21
to Robotics & Machine Vision Toolboxes
Hi Abigail POP,


Let me answer your 1st question,
In Robotics Toolbox, there are many robot models predefined for our convenience. In robot models, some characteristics are also already defined which are DH parameters, some joint configurations, Base position, Tool position, Gravity direction, etc.

So, whenever we create an instance of a predefined robot model, all the above-mentioned characteristics are also created automatically along with it. When we try to print the instance of the predefined model, the predefined joint configurations table (2nd table) will also get printed along with the DH parameters table.

In the case of Puma560, there are 4 predefined joint configurations,
1. qz = Zero angle configuration (all joint angle is zero)
2. qr = Ready pose configuration (Vertical arm pose)
3. qs = Stretch pose configuration (Horizontal pose)
4. qn = Nominal pose configuration



Now, coming to your 2nd question,
There are some issues with the python script you wrote. They're not a syntax error, that's why it won't throw any error while compilation. It'll throw some output to the console because python automatically creates an empty variable whenever we use a new variable.

I'm assuming that, you want to plot the trajectory, make GIF and perform dynamics operations on "qt" joint variable. Variables "puma.q" and "puma.qd" will always throw you a empty (zero) array. So, replace "puma.q" to "qt.q" and  "puma.qd" to "qt.qd"   to a part of your script as shown below.

qt = rtb.jtraj(puma.qz, q_pickup, 50)
puma.plot(qt.q,movie='panda1.gif')

tau = puma.rne(puma.qn, np.zeros((6,)), np.zeros((6,)))

i = puma.inertia(qt.q) #Not required in your script
c = puma.coriolis(qt.q, qt.qd) #Not required in your script
g = puma.gravload (qt.q) #Not required in your script

Also, the puma.accel() function is used incorrectly. Correct syntax is puma.accel(q, qd, torque).
Let us suppose two cases,
Case 1: Before replacing "puma.q" and "puma.qd" without syntax correction i.e., 

qdd = puma.accel(puma.q, tau, puma.qd)
print(qdd)

Here, 
puma.q is a new empty array with all values zero i.e., [0,0,0,0,0,0] (1x6).
tau is a [1x6] non empty array.
puma.qd is a new empty array with all values zero i.e., [0,0,0,0,0,0] (1x6).

Hence, the usage and syntax is wrong but it'll get compiled successfully because compiler is doing it's work and according to compiler everything is good to go but technically it's wrong and giving wrong output.

Case 2: After replacing "puma.q" to "qt.q"and  "puma.qd" to "qt.qd" with syntax correction i.e., 

qdd = puma.accel(qt.q, qt.qd, tau)
print(qdd)

Here, 
qt.q is a [50x6] non empty matrix.
qt.qd is a [50x6] non empty matrix.
tau is a [1x6] non empty array.

Here, tau is a [1x6] array but we need [50x6] matrix to perform the operation correctly. So, compiler will use tau as [50x6] matrix by appending 49 more rows with [0,0,0,0,0,0] (1x6)arrays.
Now, the usage and syntax is correct and it'll get compiled successfully  but technically it's also give the wrong output because of bad selection of matrices.


I hope, you understood it correctly. I tried my best to solve your query. 
If you still have any query or face any issue, feel free to come back here and reply to this thread because it'll be beneficial for everyone.

Himanshu Varshney

unread,
Apr 9, 2021, 7:46:26 AM4/9/21
to Robotics & Machine Vision Toolboxes
Also, I highly suggest you to refer the book "Robotics, Vision and Control: Fundamental Algorithms in MATLAB"  written by our beloved sir Peter Corke. He has explained everything in detail in this book.

- Himanshu Varshney

Abigail Pop

unread,
May 3, 2021, 6:46:39 AM5/3/21
to Robotics & Machine Vision Toolboxes
Hello,

And thank you for your answers.

I have realized that using the correct form that you mention above:  replace "puma.q" to "qt.q" and  "puma.qd" to "qt.qd" is showing me another problem. That is that my qt object cannot be called in some instances. That means that it does not appear in my variable explorer page and when I try to call qt.q sometimes it returns the error of qt not having this parameter. It does not always happen, but I would like to ask if you have any idea if this issue can be from the IDE I am using (which is Spyder) or some back-end code, because in my code the only changes that I did are the one mentioned in your previous reply.

Thank you,
Abigail

Abigail Pop

unread,
May 3, 2021, 6:48:05 AM5/3/21
to Robotics & Machine Vision Toolboxes
I am sorry, I frogot to attach the printscreen of the error.
Please find it attached below,

Thank you.

Capture.JPG
Reply all
Reply to author
Forward
0 new messages