Plotting two robots of the same kind

107 views
Skip to first unread message

Alex Filipovic

unread,
Mar 13, 2021, 5:15:26 PM3/13/21
to Robotics & Machine Vision Toolboxes
Hi everyone

I wanted to ask if it was possible in RTB to plot two robots of the same kind in the same figure? I know it can be done with different robots. But when I tried it for the same robots, it didn't work. It plots the first robot for a moment and then immediately changes the workspace and plots the second robot which then remains the only thing in the worskpace. Is there a way to get around this issue and plot/animate the robots at the same time?

Thanks in advance
Alex

Alex Smith

unread,
Mar 15, 2021, 10:04:03 AM3/15/21
to Robotics & Machine Vision Toolboxes
Hi Alex, 

Can you post a full code snippet to demonstrate your problem?

Alex

Alex Filipovic

unread,
Mar 22, 2021, 7:24:43 PM3/22/21
to Robotics & Machine Vision Toolboxes

mdl_ur5;


ur5_1=SerialLink(ur5);
ur5_2=SerialLink(ur5);


toolPos = [0.001 -0.1836 1.164];
base1Pos = toolPos + [0.19887 -0.066567 0.14152];
base2Pos = toolPos + [-0.19887 -0.066567 0.14152];

angles1 = [1.9681 0.8766 1.7827]*180/pi;
angles2 = [-1.8235 -0.1413 1.7072]*180/pi;

Tb1 = SE3(rpy2r(angles1),base1Pos); 
Tb2 = SE3(rpy2r(angles2),base2Pos);

ur5_1.base = Tb1;
ur5_2.base = Tb2;


W=[-1.5 1.5 -1 1 -0.5 2];

qz=[pi/2, -pi/2, 0, pi/2, 0, pi/2];

figure
ur5_1.plot(qz, 'workspace', W)
hold on
ur5_2.plot(qz, 'workspace', W)


I just place the robots as I wish and try to plot them to check that. However, only one robot is in the figure.
Message has been deleted

Alex Smith

unread,
Mar 23, 2021, 5:15:31 AM3/23/21
to Robotics & Machine Vision Toolboxes
I got two robots to plot just removing some of your lines of code: 

mdl_ur5;


ur5_1=SerialLink(ur5, 'name', 'UR1');
ur5_2=SerialLink(ur5, 'name', 'UR2');


% toolPos = [0.001 -0.1836 1.164];
% base1Pos = toolPos + [0.19887 -0.066567 0.14152];
base2Pos = [-1.19887 -0.066567 0.0];
% angles1 = [1.9681 0.8766 1.7827];
% angles2 = [-1.8235 -0.1413 1.7072];
% Tb1 = SE3(rpy2r(angles1),base1Pos); 
Tb2 = SE3(base2Pos);
% ur5_1.base = Tb1;
ur5_2.base = Tb2;


W=[-2 2 -2 2 -1.0 5];

% qz=[pi/2, -pi/2, 0, pi/2, 0, pi/2];

figure
hold on
ur5_1.plot(qz, 'workspace', W)
ur5_2.plot(qz) 


Also, I added names to the robots to make them easier to identify. Your definitions of the base positions is strange to me, but if you examine the values of ur5*.base you should be able to see if the translations make sense in space, and if you would be able to see the robots in the workspace you have defined. 

Note that the floor is normally drawn at z = -1, but can be changed as an option in the serialLink.plot function.

Hope that helps. 

Alex

On Monday, 22 March 2021 at 23:25:11 UTC jovan.s...@gmail.com wrote:
mdl_ur5;


ur5_1=SerialLink(ur5);
ur5_2=SerialLink(ur5);


toolPos = [0.001 -0.1836 1.164];
base1Pos = toolPos + [0.19887 -0.066567 0.14152];
base2Pos = toolPos + [-0.19887 -0.066567 0.14152];

angles1 = [1.9681 0.8766 1.7827]*180/pi;
angles2 = [-1.8235 -0.1413 1.7072]*180/pi;

Tb1 = SE3(rpy2r(angles1),base1Pos); 
Tb2 = SE3(rpy2r(angles2),base2Pos);

ur5_1.base = Tb1;
ur5_2.base = Tb2;


W=[-1.5 1.5 -1 1 -0.5 2];

qz=[pi/2, -pi/2, 0, pi/2, 0, pi/2];

figure
ur5_1.plot(qz, 'workspace', W)
hold on
ur5_2.plot(qz, 'workspace', W)



So I just place the robots adequately, and then I plot them, and they won't show in the same figure.

On Monday, March 15, 2021 at 3:04:03 PM UTC+1 Alex Smith wrote:

Peter Corke

unread,
Mar 27, 2021, 1:32:43 AM3/27/21
to Robotics & Machine Vision Toolboxes
It may not be in the doco, but the robots need to have different names.

>> ur5_2.name='UR5-2'

should do the trick.

Reply all
Reply to author
Forward
0 new messages