robot/rt_plot - create a graphical animation for a robot object[view code]
Options are specified by a variable length argument list comprising strings and numeric values. The allowed values are:
string | required numeric value | meaning |
"workspace" | [xmin, xmax, ymin, ymax, zmin, zmax] (6-element row vector) | set the 3D plot bounds or workspace |
"mag" | scale (scalar) | annotation scale factor |
"loop" | n (scalar) | animation is repeated n times |
"perspective" | show a perspective view | |
"ortho" | show a orthogonal view | |
"base" or "nobase" | control display of base, a line from the floor upto joint 0 | |
"wrist" or "nowrist" | control display of wrist axes | |
"name" or "noname" | control display of robot name near joint 0 | |
"shadow" or "noshadow" | control display of a 'shadow' on the floor | |
"joints" or "nojoints" | control display of joints, these are cylinders for revolute joints and boxes for prismatic joints | |
"erase" or "noerase" | control erasure of robot after each change |
The options came from 3 sources and are processed in the order:
rt_plot is overloaded for robot objects.
The first form displays a graphical representation of the robot given the kinematic information in robot. The robot is represented by a simple stick figure polyline where line segments join the origins of the link coordinate frames. If q is a matrix (p > 1) representing a joint-space trajectory then an animation of the robot motion is shown. The basic stick figure robot can be graphically annotated with
Each graphical robot has a unique tag set equal to the robot's name. When rt_plot is called it looks for all graphical objects with that name and moves them. The graphical robot holds a copy of the robot object as user_data (see polyline_properties). That copy contains the graphical handles of all the graphical sub-elements of the robot and also the current joint angle state. This state is used and adjusted by the rt_drivebot function.
The second form returns the robot's current joint angle state.
// To animate a Puma robot the following code could be used. exec <PATH>/models/rt_puma560.sce; // load Puma 560 parameters h0 = scf(0); a0 = h0.children; // create a new graphic win. a0.tight_limits = "on"; a0.rotation_angles = [80, -46]; // adjust observation point rt_plot(p560, qready); // display it at ready pos. t = [0:0.056:10]; jt = rt_jtraj(qready, qstretch, t); // traject. to stretch pose rt_plot(p560, jt); // animate the robot! // To show multiple views of the same robot the following code could be // used. clf(0, "clear"); h0 = scf(0); a0 = h0.children; a0.tight_limits = "on"; a0.rotation_angles = [73, 33]; // MULT.VIEWS #1 rt_plot(p560, qz); // add a graphical robot h1 = scf(1); a1 = h1.children; a1.tight_limits = "on"; a1.rotation_angles = [73, -61]; // MULT.VIEWS #1 rt_plot(p560, qz); // add a graphical robot rt_plot(p560, qready); // both robots should move // now the two figures can be adjusted to give different viewpoints a0.rotation_angles = [73, 33]; // MULT.VIEWS #2 a1.rotation_angles = [73, 128]; a0.rotation_angles = [90, 0]; // MULT.VIEWS #3 (front) a1.rotation_angles = [0, 0]; // (top) // Play with options xdel(h1.figure_id); clf(0, "clear"); h0 = scf(0); a0 = h0.children; a0.tight_limits = "on"; a0.rotation_angles = [74, -30]; rt_plot(p560, qstretch, "base"); // display robot base clf(0, "clear"); h0 = scf(0); a0 = h0.children; a0.tight_limits = "on"; a0.rotation_angles = [74, -30]; rt_plot(p560, jt, "base", "loop", 3); // display robot base // and // repeat animation 3 times clf(0, "clear"); h0 = scf(0); a0 = h0.children; a0.tight_limits = "on"; a0.rotation_angles = [74, -30]; tic();.. rt_plot(p560, qready, "base");.. elaps_time0 = toc(), h1 = scf(1); a1 = h1.children; a1.tight_limits = "on"; a1.rotation_angles = [74, -30]; tic();.. rt_plot(p560, qready, "noname", "nobase", "noshadow", "nojoints", "nowrist");.. elaps_time1 = toc(), // time requested to plot: the most detailed // vs // the simplest stick robot figure p560.lineopt = list("orange", 4); p560.shadowopt = list("red", 1); xdel(h1.figure_id); clf(0, "clear"); h0 = scf(0); a0 = h0.children; a0.tight_limits = "on"; a0.rotation_angles = [74, -30]; rt_plot(p560, jt); // animate a robot with orange links, // blue joints and red shadow!
Options for plotting are only processed on the first call when the graphical object is established, they are skipped on subsequent calls. Thus if you wish to change options, clear the figure before replotting.
rt_drivebot, rt_fkine, rt_robot, polyline_properties,
Corke, P.I. "A Robotics Toolbox for MATLAB", IEEE Robotics and Automation Magazine, Volume 3(1), March 1996, pp. 24-32