rt_robot - construct/clone a robot object[view code]
A DH matrix describes the kinematics of a manipulator in a general way using the standard Denavit and Hartenberg conventions. Each row represents one link of the manipulator and the columns are assigned according to the following table.
Column | Symbol | Description |
1 | alpha | link twist angle |
2 | A | link length |
3 | theta | link rotation angle |
4 | D | link offset distance |
5 | sigma | joint type: 0 for revolute, non-zero for prismatic |
The last column is optional. If it is not given then toolbox functions assume that the manipulator is all-revolute. Hence really n-by-5 is the high dimension of the DH matrix. For a n-axis manipulator DH can be an n-by-4 or a n-by-5 matrix.
Lengths A and D may be expressed in any unit, and this choice will flow on to the units in which homogeneous transforms and Jacobians are represented. All angles are in radians.
A DYN matrix describes the kinematics and dynamics of a manipulator in a general way using the standard Denavit and Hartenberg conventions. Each row represents one link of the manipulator and the columns are assigned according to the following table.
Column | Symbol | Description |
1 | alpha | link twist angle |
2 | A | link length |
3 | theta | link rotation angle |
4 | D | link offset distance |
5 | sigma | joint type: 0 for revolute, non-zero for prismatic |
6 | mass | mass of the link |
7 | rx | link COG with respect to the link coordinate frame |
8 | ry | |
9 | rz | |
10 | Ixx | elements of the link inertia tensor about the link COG |
11 | Iyy | |
12 | Izz | |
13 | Ixy | |
14 | Iyz | |
15 | Ixz | |
16 | Jm | armature inertia |
17 | G | reduction gear ratio: joint speed/link speed |
18 | B | viscous friction, motor referred |
19 | Tc+ | Coulomb friction (positive rotation), motor referred |
20 | Tc- | Coulomb friction (negative rotation), motor referred |
Columns 17, 18 and 19 (and 20 which is related to column 19) are optional. If they are not given then toolbox functions assume the following default values:
Symbol | Value |
G | 1 |
B | 0.0 |
[Tc+, Tc-] | [0, 0] |
The first 5 columns of a DYN matrix contain the kinematic parameters and may be used anywhere that a DH kinematic matrix is required (the dynamic data is ignored).
All angles are in radians. The choice of all other units is up to the user, and this choice will flow on to the units in which homogeneous transforms, Jacobians inertias and torques are represented.
The rt_robot function is the constructor for a robot object. The robot object has type robot.
The first form returns a default robot.
The second form creates a robot from a Scilab list of robot objects which define the robot's kinematics and optionally dynamics.
The third and the fourth forms create a robot object from legacy DH and DYN format matrices.
The fifth form is the copy constructor for the robot object and returns a new robot object with the same value as its argument. If the optional argument L is provided, then its lenght must equal the number of constituent links of the robot r which you are attempting to clone. Note that, unlike the Matlab version of this toolbox, THE VARIABLE ASSIGNMENT OPERATOR (=) DOES NOT CLONE A ROBOT OBJECT but rather it allows a quick reference to the object itself. This can result very useful, for example when you have to change few kinematic or dynamic parameters in the constituent links of a robot model and you want avoid redefinition or copy of the entire robot object.
The last three forms all accept optional trailing string arguments which are taken in order as being robot name, manufacturer and comment.
Since Scilab does not support the concept of public class, variables methods have been written to allow robot object parameters to be referenced (r) or assigned (a) as given by the following table:
Method | Operation | Returns | Type |
robot.n | r | number of joints | scalar |
robot.links | r + a | constituent links | list of link objects |
robot.name | r + a | robot name | string |
robot.manuf | r + a | robot manufacturer | string |
robot.comment | r + a | general comment | string |
robot.gravity | r + a | vector defining gravity direction | 3-element column vector |
robot.mdh | r | DH convention: 0 if standard, 1 if modified. Determined from the constituent links | scalar |
robot.mdh | a | DH convention: 0 if standard, 1 if modified. Set all mdh values in the constituent links | scalar |
robot.base | r + a | homogeneous transform defining base of robot | 4-by-4 matrix |
robot.tool | r + a | homogeneous transform defining base of robot | 4-by-4 matrix |
robot.dh | r | legacy DH matrix | n-by-5 matrix |
robot.dyn | r | legacy DYN matrix | n-by-20 matrix |
robot.q | r + a | joint coordinates | n-element column vector |
robot.qlim | r + a | joint coordinate limits | n-by-2 matrix |
robot.islimit | r | joint limit vector, for each joint set to -1, 0 or 1 depending if below low limit, OK or greater than upper limit | n-element column vector |
robot.offset | r + a | joint coordinate offsets | n-element column vector |
robot.plotopt | r + a | options for robot/rt_plot | list of valid options for robot plotting (see robot/rt_plot) |
robot.lineopt | r + a | line style for robot graphical links | 2-element list: string (valid Scilab color) and scalar (positive integer for line thickness property) |
robot.shadowopt | r + a | line style for robot shadow links | 2-element list: string (valid Scilab color) and scalar (positive integer for line thickness property) |
robot.handle | r + a | graphics handles | structure |
The following are default values for parameters of a generic n-axis robot:
Method | Value |
robot.name | "noname" |
robot.manuf | "" |
robot.comment | "" |
robot.gravity | [0; 0; 9.81] |
robot.offset | zeros(n, 1) |
robot.base | eye(4, 4) |
robot.tool | eye(4, 4) |
robot.lineopt | list("black", 4) |
robot.shadowopt | list("black", 1) |
Some of these operations at the robot level are actually wrappers around similarly named link object functions: offset, qlim and islimit.
The offset vector is added to the user specified joint angles before any kinematic or dynamic function is invoked (it is actually implemented whitin the link object). Similarly it is subtracted after an operation such as inverse kinematics. The need for a joint offset vector arises because of the constraints of the Denavit-Hartenberg (or modified Denavit-Hartenberg) notation. The pose of the robot with zero joint angles is frequently some rather unusual (or even unachievable) pose. The joint coordinate offset provides a means to make an arbitrary pose correspond to the zero joint angle case.
In Scilab variable display and operators may be defined for new objects using Scilab-coded functions. The following is a list of all overloaded operators for the new Scilab object, the robot:
In Scilab some basic primitive functions may be overloaded for new data types. The following is a list of all overloaded functions for the new Scilab object, the robot:
// create a default robot model rdef = rt_robot(), // create a robot from a list of links: // Puma 560 standard (kinematic data only) L = list(); L(1) = rt_link([%pi/2 0 0 0 0], "standard"); L(2) = rt_link([0 0.4318 0 0 0], "standard"); L(3) = rt_link([-%pi/2 0.0203 0 0.15005 0], "standard"); L(4) = rt_link([%pi/2 0 0 0.4318 0], "standard"); L(5) = rt_link([-%pi/2 0 0 0 0], "standard"); L(6) = rt_link([0 0 0 0 0], "standard"); p560_kinem = rt_robot(L, "P560 (K)", "Unimation", "Kinematic data only"); clear L; disp(p560_kinem); // modified (AKB) Puma 560 (kinematic data, link masses and COGs) L = list(); L(1) = rt_link([0, 0, 0, 0, 0], "mod"); L(2) = rt_link([-%pi/2, 0, 0, 0.2435, 0], "mod"); L(3) = rt_link([0, 0.4318, 0, -0.0934, 0], "mod"); L(4) = rt_link([%pi/2, -0.0203, 0, 0.4331, 0], "mod"); L(5) = rt_link([-%pi/2, 0, 0, 0, 0], "mod"); L(6) = rt_link([%pi/2, 0, 0, 0, 0], "mod"); L(1).m = 0; L(2).m = 17.4; L(3).m = 4.8; L(4).m = 0.82; L(5).m = 0.34; L(6).m = 0.09; L(1).r = [0, 0, 0]; L(2).r = [0.068, 0.006, -0.016]; L(3).r = [0, -0.070, 0.014]; L(4).r = [0, 0, -0.019]; L(5).r = [0, 0, 0]; L(6).r = [0, 0, 0.032]; p560m_kmr = rt_robot(L, "P560M (K&D)", "Unimation"), clear L; // create a robot (planar RR) from a legacy DH matrix rrplan_dh = [0, 1, 0, 0;.. // alpha, a, theta, d 0, 1, 0, 0;], // sigma not given => all-revolute rrplan = rt_robot(rrplan_dh, "Simple RR Planar", "", "from legacy DH"), // create a robot (Stanford Arm) from a legacy DYN matrix alpha = [-%pi/2; %pi/2; 0; -%pi/2; %pi/2; 0], // kinematic parameters A = [0; 0; 0; 0; 0; 0], theta = [0; 0; -%pi/2; 0; 0; 0], D = [0.412; 0.154; 0; 0; 0; 0.263], sigma = [0; 0; 1; 0; 0; 0], // Joint 3 is prismatic, therefore // sigma has to be given m = [9.29; 5.01; 4.25; 1.08; 0.63; 0.51], // dynamic parameters rx = [0; 0; 0; 0; 0; 0], ry = [0.0175; -1.054; 0; 0.092; 0; 0], rz = [-0.1105; 0; -6.447; -0.054; 0.566; 1.554], Ixx = [0.276; 0.108; 2.51; 0.002; 0.003; 0.013], Iyy = [0.255; 0.018; 2.51; 0.001; 0.003; 0.013], Izz = [0.071; 0.100; 0.006; 0.001; 0.0004; 0.0003], Ixy = [0; 0; 0; 0; 0; 0], Iyz = [0; 0; 0; 0; 0; 0], Ixz = [0; 0; 0; 0; 0; 0], Jm = [0.953; 2.193; 0.782; 0.106; 0.097; 0.020], G = [1; 1; 1; 1; 1; 1], stanford_dyn = [.. // legacy DYN matrix alpha, A, theta, D, sigma, m, rx, ry, rz, Ixx, Iyy, Izz, Ixy, Iyz, Ixz, Jm, G]; stanf = rt_robot(stanford_dyn, "Stanford Arm"), // B and Tc are not given // clone a robot stanf_copy = rt_robot(stanf); // stanf and stanf_copy are distinct stanf_copy.name = "Stanford Copy"; disp(stanf); // the two names are different disp(stanf_copy); // refer to a robot r = stanf_copy; // r "points" to stanf_copy and from r.name = "Another Name"; // now on each change on it will disp(r); // affect the stanf_copy object too. disp(stanf_copy); // stanf_copy's name has changed! disp(stanf); // But stanf's name has not! This // because stanf and stanf_copy are // distinct objects // change few parameters of constituent links of a robot model // avoiding redefinition or copy of an entire robot object exec <PATH>/models/rt_puma560.sce; // load Puma 560 parameters disp(p560); // display the robot L = p560.links; // quick reference to links L(1).A = 1; L(2).A = 0.8; L(3).theta = -%pi/2; disp(p560); // parameters have changed! // some other reference or assignment operations p560.mdh, // refer mdh p560.mdh = 1, // assign mdh p560.qlim = [-2.2*ones(6,1), 2.2*ones(6,1)]; // assign joint limits q = 2*%pi*rand(6,1) - %pi, p560.islimit(q), // test joint state vector rt_showlink(p560); // show detailed robot data // Get the type of a robot object typeof(stanf) == "robot", // returns %T (true)
rt_link, rt_showlink, robot/rt_plot,
Corke, P.I. "A Robotics Toolbox for MATLAB", IEEE Robotics and Automation Magazine, Volume 3(1), March 1996, pp. 24-32