The toolbox provides the functions simulating manipulator motions. The first function creates a special panel in the Matlab figure window which allows changing a configuration of the manipulator using a set of controls (each control corresponds to a single configuration variable). To display this panel the following function is used
robot_panel(r)
where: r structure representing a manipulator plotted in the figure window.
The second function enables showing the manipulator realizing the pre-planned trajectory:
r = robot_motion(r, q, delay)
where: r - structure representing a manipulator object; q - matrix containing pre-planned trajectory; delay - pause between animation steps.
To use a special panel for interactive communication with the user, first a robot object has to be created. In this example a 3PR manipulator whose DH parameters are given in the table below will be defined.
i | αi-1 | ai-1 | di | θi |
---|---|---|---|---|
1 | 0 | 0 | d1 | 0 |
2 | -π/2 | 0 | d2 | π/2 |
3 | -π/2 | 1 | d3 | 0 |
4 | 0 | 0 | 1 | θ4 |
% workspace
axis([-5, 10, -5, 10, -5, 10])
csys_plot(csys(eye(4), 'CSysAxisLength', axis, 'CSysAxisLabel', {'','',''}));
grid on
camlight
% manipulator
r = robot([dh(0,0,5,0); dh(-pi/2,0,5,pi/2); dh(-pi/2,1,3,0); dh(0,0,1,0)], ['d','d','p','r'],
'RobotBase', rp2t(rotx(-pi/2)*rotz(-pi/2),[0;0;5]),'RobotGrasper', rp2t(roty(-pi/2),[0; 0; 2]),
'RobotGrasperSize', 0.75, 'RobotRange', [0, 10; 1, 10; 0, 5; -pi, pi], 'RobotColor', [0,0.45,0.9],
'RobotExColor', [0,0.75,1], 'RobotCylinderRadius', 0.25, 'RobotCylinderApprox', 16, 'RobotModel', 'rangeex');
r = robot_plot(r, 'surf');
% panel
robot_panel(r);
The manipulator from Example 1 will be moved from its start configuration [5; 5; 3; 0] to final configuration [1; 5; 3; 0] through intermediate configurations: [4; 5; 3; 0], [3; 5; 3; 0] and [2; 5; 3; 0].
% workspace
axis([-5, 10, -5, 10, -5, 10])
csys_plot(csys(eye(4), 'CSysAxisLength', axis, 'CSysAxisLabel', {'','',''}));
grid on
camlight
% manipulator
r = robot([dh(0,0,5,0); dh(-pi/2,0,5,pi/2); dh(-pi/2,1,3,0); dh(0,0,1,0)], ['d','d','p','r'],
'RobotBase', rp2t(rotx(-pi/2)*rotz(-pi/2),[0;0;5]),'RobotGrasper', rp2t(roty(-pi/2),[0; 0; 2]),
'RobotGrasperSize', 0.75, 'RobotRange', [0, 10; 1, 10; 0, 5; -pi, pi], 'RobotColor', [0,0.45,0.9],
'RobotExColor', [0,0.75,1], 'RobotCylinderRadius', 0.25, 'RobotCylinderApprox', 16, 'RobotModel', 'rangeex');
r = robot_plot(r, 'surf');
% movement through the given configurations
c1 = [5; 5; 3; 0];
c2 = [4; 5; 3; 0];
c3 = [3; 5; 3; 0];
c4 = [2; 5; 3; 0];
c5 = [1; 5; 3; 0];
r = robot_motion(r, [c1 c2 c3 c4 c5], 0.2);