Roboticstoolboxcommands
Roboticstoolboxcommands
Copyright
2011
c Peter Corke
[email protected]
September 2011
http://www.petercorke.com
3
Preface
springer.com
123 link manipulators. These parameters are encapsu-
R
lated in MATLAB objects — robot objects can be
created by the user for any serial-link manipulator
and a number of examples are provided for well know robots such as the Puma 560
and the Stanford arm amongst others. The Toolbox also provides functions for manip-
ulating and converting between datatypes such as vectors, homogeneous transforma-
tions and unit-quaternions which are necessary to represent 3-dimensional position and
orientation.
This ninth release of the Toolbox has been significantly extended to support mobile
robots. For ground robots the Toolbox includes standard path planning algorithms
(bug, distance transform, D*, PRM), kinodynamic planning (RRT), localization (EKF,
particle filter), map building (EKF) and simultaneous localization and mapping (EKF),
and a Simulink model a of non-holonomic vehicle. The Toolbox also including a de-
tailed Simulink model for a quadcopter flying robot.
The routines are generally written in a straightforward manner which allows for easy
understanding, perhaps at the expense of computational efficiency. If you feel strongly
about computational efficiency then you can always rewrite the function to be more
R
efficient, compile the M-file using the MATLAB compiler, or create a MEX version.
R
The manual is now auto-generated from the comments in the MATLAB code itself
which reduces the effort in maintaining code and a separate manual as I used to — the
downside is that there are no worked examples and figures in the manual. However the
book “Robotics, Vision & Control” provides a detailed discussion (600 pages, nearly
400 figures and 1000 code examples) of how to use the Toolbox functions to solve
R
Robotics Toolbox 9 for MATLAB 4 Copyright
Peter
c Corke 2011
many types of problems in robotics, and I commend it to you.
R
Robotics Toolbox 9 for MATLAB 5 Copyright
Peter
c Corke 2011
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1 Introduction 9
1.1 What’s changed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.1.1 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.1.2 Changed behaviour . . . . . . . . . . . . . . . . . . . . . . . 9
1.1.3 New functions . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.1.4 Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2 How to obtain the Toolbox . . . . . . . . . . . . . . . . . . . . . . . 12
1.3 MATLAB version issues . . . . . . . . . . . . . . . . . . . . . . . . 13
1.4 Use in teaching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5 Use in research . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.6 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.7 Related software . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.7.1 Octave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.7.2 Python version . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.7.3 Machine Vision toolbox . . . . . . . . . . . . . . . . . . . . 14
1.8 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
R
Robotics Toolbox 9 for MATLAB 6 Copyright
Peter
c Corke 2011
CONTENTS CONTENTS
Vehicle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
about . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
angdiff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
angvec2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
angvec2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
colnorm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
ctraj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
delta2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
diff2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
e2h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
edgelist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
eul2jac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
eul2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
eul2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
gauss2d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
h2e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
homline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
homtrans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
imeshgrid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
ishomog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
isrot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
isvec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
jtraj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
lspb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
mdl Fanuc10L . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
mdl MotomanHP6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
mdl S4ABB2p8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
mdl puma560 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
mdl puma560akb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
mdl stanford . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
mdl twolink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
mstraj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
mtraj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
numcols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
numrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
oa2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
oa2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
plot2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
plot box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
plot circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
plot ellipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
plot ellipse inv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
plot homline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
plot point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
plot poly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
plot sphere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
plotbotopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
plotp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
qplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
R
Robotics Toolbox 9 for MATLAB 7 Copyright
Peter
c Corke 2011
CONTENTS CONTENTS
r2t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
ramp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
rotx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
roty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
rotz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
rpy2jac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
rpy2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
rpy2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
rt2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
rtdemo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
se2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
skew . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
startup rtb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
t2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
tb optparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
tpoly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
tr2angvec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
tr2delta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
tr2eul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
tr2jac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
tr2rpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
tranimate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
transl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
trinterp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
trnorm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
trotx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
troty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
trotz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
trplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
vex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
wtrans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
R
Robotics Toolbox 9 for MATLAB 8 Copyright
Peter
c Corke 2011
Chapter 1
Introduction
1.1.1 Documentation
• The manual (robot.pdf) no longer a separately written document. This was just
too hard to keep updated with changes to code. All documentation is now in the
m-file, making maintenance easier and consistency more likely. The negative
consequence is that the manual is a little “drier” than it used to be.
• The Functions link from the Toolbox help browser lists all functions with hyper-
links to the individual help entries.
• Online HTML-format help is available from www.petercorke.com/robot/
??.
R
Robotics Toolbox 9 for MATLAB 9 Copyright
Peter
c Corke 2011
1.1. WHAT’S CHANGED CHAPTER 1. INTRODUCTION
Release 9 introduces considerable new functionality, in particular for mobile robot con-
trol, navigation and localization:
• Mobile robotics:
Vehicle Model of a mobile robot that has the ”bicycle” kinematic model (car-
like). For given inputs it updates the robot state and returns noise corrupted
odometry measurements. This can be used in conjunction with a ”driver”
class such as RandomPath which drives the vehicle between random way-
points within a specified rectangular region.
Sensor
RangeBearingSensor Model of a laser scanner RangeBearingSensor, subclass
of Sensor, that works in conjunction with a Map object to return range and
bearing to invariant point features in the environment.
R
Robotics Toolbox 9 for MATLAB 10 Copyright
Peter
c Corke 2011
1.1. WHAT’S CHANGED CHAPTER 1. INTRODUCTION
EKF Extended Kalman filter EKF can be used to perform localization by dead
reckoning or map featuers, map buildings and simultaneous localization
and mapping.
DXForm Path planning classes: distance transform DXform, D* lattice planner
Dstar, probabilistic roadmap planner PRM, and rapidly exploring random
tree RRT.
Monte Carlo estimator ParticleFilter.
• Arm robotics:
jsingu
jsingu
qplot
DHFactor a simple means to generate the Denavit-Hartenberg kinematic model
of a robot from a sequence of elementary transforms.
• Trajectory related:
lspb
tpoly
mtraj
mstraj
• General transformation:
wtrans
se2
se3
homtrans
vex performs the inverse function to skew, it converts a skew-symmetric matrix
to a 3-vector.
• Data structures:
Pgraph represents a non-directed embedded graph, supports plotting and mini-
mum cost path finding.
Polygon a generic 2D polygon class that supports plotting, intersectio/union/difference
of polygons, line/polygon intersection, point/polygon containment.
• Graphical functions:
trprint compact display of a transform in various formats.
trplot display a coordinate frame in SE(3)
trplot2 as above but for SE(2)
tranimate animate the motion of a coordinate frame
R
Robotics Toolbox 9 for MATLAB 11 Copyright
Peter
c Corke 2011
1.2. HOW TO OBTAIN THE TOOLBOX CHAPTER 1. INTRODUCTION
plot box plot a box given TL/BR corners or center+WH, with options for edge
color, fill color and transparency.
plot circle plot one or more circles, with options for edge color, fill color and
transparency.
plot sphere plot a sphere, with options for edge color, fill color and trans-
parency.
plot ellipse plot an ellipse, with options for edge color, fill color and trans-
parency.
]plot ellipsoid] plot an ellipsoid, with options for edge color, fill color and trans-
parency.
plot poly plot a polygon, with options for edge color, fill color and transparency.
• Utility:
about display a one line summary of a matrix or class, a compact version of
whos
tb optparse general argument handler and options parser, used internally in
many functions.
• Lots of Simulink models are provided in the subdirectory simulink. These
models all have the prefix sl .
1.1.4 Improvements
• Many functions now accept MATLAB style arguments given as trailing strings,
or string-value pairs. These are parsed by the internal function tb optparse.
• Many functions now handle sequences of rotation matrices or homogeneous
transformations.
• Improved error messages in many functions
• Removed trailing commas from if and for statements
R
Robotics Toolbox 9 for MATLAB 12 Copyright
Peter
c Corke 2011
1.3. MATLAB VERSION ISSUES CHAPTER 1. INTRODUCTION
to external web sites, the table of content to functions, and the “See also” functions to
each other.
A menu-driven demonstration can be invoked by the function rtdemo.
1.6 Support
There is no support! This software is made freely available in the hope that you find
it useful in solving whatever problems you have to hand. I am happy to correspond
R
Robotics Toolbox 9 for MATLAB 13 Copyright
Peter
c Corke 2011
1.7. RELATED SOFTWARE CHAPTER 1. INTRODUCTION
with people who have found genuine bugs or deficiencies but my response time can
be long and I can’t guarantee that I respond to your email. I am very happy to accept
contributions for inclusion in future versions of the toolbox, and you will be suitably
acknowledged.
I can guarantee that I will not respond to any requests for help with assignments
or homework, no matter how urgent or important they might be to you. That’s
what you your teachers, tutors, lecturers and professors are paid to do.
You might instead like to communicate with other users via the Google Group called
“Robotics and Machine Vision Toolbox”
http://groups.google.com.au/group/robotics-tool-box
which is a forum for discussion. You need to signup in order to post, and the signup
process is moderated by me so allow a few days for this to happen. I need you to write a
few words about why you want to join the list so I can distinguish you from a spammer
or a web-bot.
1.7.1 Octave
R
Octave is an open-source mathematical environment that is very similar to MATLAB
, but it has some important differences particularly with respect to graphics and classes.
Many Toolbox functions work just fine under Octave. Three important classes (Quater-
nion, Link and SerialLink) will not work so modified versions of these classes is pro-
vided in the subdirectory called Octave. Copy all the directories from Octave to
the main Robotics Toolbox directory.
The Octave port is a second priority for support and upgrades and is offered in the hope
that you find it useful.
R
Robotics Toolbox 9 for MATLAB 14 Copyright
Peter
c Corke 2011
1.8. ACKNOWLEDGEMENTS CHAPTER 1. INTRODUCTION
Month = nov,
Number = {4},
Pages = {16-25},
Title = {Machine Vision Toolbox},
Volume = {12},
Year = {2005}}
and provides a very wide range of useful computer vision functions beyond the Math-
work’s Image Processing Toolbox. You can obtain this from http://www.petercorke.
com/vision.
1.8 Acknowledgements
Last, but not least, I have corresponded with a great many people via email since the
first release of this Toolbox. Some have identified bugs and shortcomings in the doc-
umentation, and even better, some have provided bug fixes and even new modules,
thankyou. See the file CONTRIB for details. I’d like to especially mention Wynand
Smart for some arm robot models, Paul Pounds for the quadcopter model, and Paul
Newman (Oxford) for inspiring the mobile robot code.
R
Robotics Toolbox 9 for MATLAB 15 Copyright
Peter
c Corke 2011
Chapter 2
SerialLink
Serial-link robot class
Options
R
Robotics Toolbox 9 for MATLAB 16 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Methods
plot display graphical representation of robot
teach drive the graphical robot
fkine return forward kinematics
ikine6s return inverse kinematics for 6-axis spherical wrist robot
ikine return inverse kinematics using iterative method
jacob0 return Jacobian matrix in world frame
jacobn return Jacobian matrix in tool frame
jtraj return a joint space trajectory
dyn show dynamic properties of links
isspherical true if robot has spherical wrist
islimit true if robot has spherical wrist
payload add a payload in end-effector frame
coriolis return Coriolis joint force
gravload return gravity joint force
inertia return joint inertia matrix
accel return joint acceleration
fdyn return joint motion
rne return joint force
perturb return SerialLink object with perturbed parameters
showlink return SerialLink object with perturbed parameters
friction return SerialLink object with perturbed parameters
maniplty return SerialLink object with perturbed parameters
Properties (read/write)
n number of joints
config joint configuration string, eg. ‘RRRRRR’
mdh kinematic convention boolean (0=DH, 1=MDH)
islimit joint limit boolean vector
q joint angles from last plot operation
handle graphics handles in object
R
Robotics Toolbox 9 for MATLAB 17 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Note
See also
Link, DHFactor
SerialLink.SerialLink
Create a SerialLink robot object
Options
which is equivalent to R2 mounted on the end of R1. Note that tool transform of R1
and the base transform of R2 are lost, constant transforms cannot be represented in
Denavit-Hartenberg notation.
Note
R
Robotics Toolbox 9 for MATLAB 18 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
Link, SerialLink.plot
SerialLink.accel
Manipulator forward dynamics
qdd = R.accel(q, qd, torque) is a vector (N × 1) of joint accelerations that result from
applying the actuator force/torque to the manipulator robot in state q and qd. If q, qd,
torque are matrices with M rows, then qdd is a matrix with M rows of acceleration
corresponding to the equivalent rows of q, qd, torque.
qdd = R.ACCEL(x) as above but x=[q,qd,torque].
Note
• Uses the method 1 of Walker and Orin to compute the forward dynamics.
• This form is useful for simulation of manipulator dynamics, in conjunction with
a numerical integration function.
See also
SerialLink.char
String representation of parametesrs
SerialLink.cinertia
Cartesian inertia matrix
R
Robotics Toolbox 9 for MATLAB 19 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
SerialLink.inertia, SerialLink.rne
SerialLink.copy
Clone a robot object
SerialLink.coriolis
Coriolis matrix
Notes
See also
SerialLink.rne
SerialLink.display
Display parameters
R
Robotics Toolbox 9 for MATLAB 20 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Notes
• this method is invoked implicitly at the command line when the result of an
expression is a SerialLink object and the command has no trailing semicolon.
See also
SerialLink.char, SerialLink.dyn
SerialLink.dyn
display inertial properties
R.dyn() displays the inertial properties of the SerialLink object in a multi-line format.
The properties shown are mass, centre of mass, inertia, gear ratio, motor inertia and
motor friction.
See also
Link.dyn
SerialLink.fdyn
Integrate forward dynamics
[T,q,qd] = R.fdyn(T1, torqfun) integrates the dynamics of the robot over the time
interval 0 to T and returns vectors of time TI, joint position q and joint velocity qd.
The initial joint position and velocity are zero. The torque applied to the joints is
computed by the user function torqfun:
[ti,q,qd] = R.fdyn(T, torqfun, q0, qd0) as above but allows the initial joint position
and velocity to be specified.
The control torque is computed by a user defined function
TAU = torqfun(T, q, qd, ARG1, ARG2, ...)
where q and qd are the manipulator joint coordinate and velocity state respectively],
and T is the current time.
[T,q,qd] = R.fdyn(T1, torqfun, q0, qd0, ARG1, ARG2, ...) allows optional arguments
to be passed through to the user function.
R
Robotics Toolbox 9 for MATLAB 21 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Note
• This function performs poorly with non-linear joint friction, such as Coulomb
friction. The R.nofriction() method can be used to set this friction to zero.
• If torqfun is not specified, or is given as 0 or [], then zero torque is applied to
the manipulator joints.
• The builtin integration function ode45() is used.
See also
SerialLink.fkine
Forward kinematics
Note
• The robot’s base or tool transform, if present, are incorporated into the result.
See also
SerialLink.ikine, SerialLink.ikine6s
SerialLink.friction
Friction force
tau = R.friction(qd) is the vector of joint friction forces/torques for the robot moving
with joint velocities qd.
The friction model includes viscous friction (linear with velocity) and Coulomb fric-
tion (proportional to sign(qd)).
R
Robotics Toolbox 9 for MATLAB 22 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
Link.friction
SerialLink.gravload
Gravity loading
taug = R.gravload(q) is the joint gravity loading for the robot in the joint configuration
q. Gravitational acceleration is a property of the robot object.
If q is a row vector, the result is a row vector of joint torques. If q is a matrix, each row
is interpreted as a joint configuration vector, and the result is a matrix each row being
the corresponding joint torques.
taug = R.gravload(q, grav) is as above but the gravitational acceleration vector grav
is given explicitly.
See also
SerialLink.ikine
Inverse manipulator kinematics
R
Robotics Toolbox 9 for MATLAB 23 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Options
Notes
See also
SerialLink.ikine6s
Inverse kinematics for 6-axis robot with spherical wrist
Notes
• The inverse kinematic solution is generally not unique, and depends on the con-
figuration string.
Reference
Inverse kinematics for a PUMA 560 based on the equations by Paul and Zhang From
The International Journal of Robotics Research Vol. 5, No. 2, Summer 1986, p. 32-44
R
Robotics Toolbox 9 for MATLAB 24 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Author
Robert Biro with Gary Von McMurray, GTRI/ATRP/IIMB, Georgia Institute of Tech-
nology 2/13/95
See also
SerialLink.FKINE, SerialLink.IKINE
SerialLink.inertia
Manipulator inertia matrix
i = R.inertia(q) is the N × N symmetric joint inertia matrix which relates joint torque
to joint acceleration for the robot at joint configuration q. The diagonal elements i(j,j)
are the inertia seen by joint actuator j. The off-diagonal elements are coupling inertias
that relate acceleration on joint i to force/torque on joint j.
If q is a matrix (D × N ), each row is interpretted as a joint state vector, and the result
(NxNxD) is a 3d-matrix where each plane corresponds to the inertia for the corre-
sponding row of q.
See also
SerialLink.islimit
Joint limit test
v = R.ISLIMIT(q) is a vector of boolean values, one per joint, false (0) if q(i) is within
the joint limits, else true (1).
SerialLink.isspherical
Test for spherical wrist
R.isspherical() is true if the robot has a spherical wrist, that is, the last 3 axes intersect
at a point.
R
Robotics Toolbox 9 for MATLAB 25 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
SerialLink.ikine6s
SerialLink.itorque
Inertia torque
taui = R.itorque(q, qdd) is the inertia force/torque N-vector at the specified joint con-
figuration q and acceleration qdd, that is, taui = INERTIA(q)*qdd.
If q and qdd are row vectors, the result is a row vector of joint torques. If q and qdd
are matrices, each row is interpretted as a joint state vector, and the result is a matrix
each row being the corresponding joint torques.
Note
• If the robot model contains non-zero motor inertia then this will included in the
result.
See also
SerialLink.rne, SerialLink.inertia
SerialLink.jacob0
Jacobian in world coordinates
Options
‘rpy’ Compute analytical Jacobian with rotation rate in terms of roll-pitch-yaw angles
‘eul’ Compute analytical Jacobian with rotation rates in terms of Euler angles
‘trans’ Return translational submatrix of Jacobian
‘rot’ Return rotational submatrix of Jacobian
R
Robotics Toolbox 9 for MATLAB 26 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Note
• the Jacobian is computed in the world frame and transformed to the end-effector
frame.
• the default Jacobian returned is often referred to as the geometric Jacobian, as
opposed to the analytical Jacobian.
See also
SerialLink.jacob dot
Hessian in end-effector frame
jdq = R.jacob dot(q, qd) is the product of the Hessian, derivative of the Jacobian, and
the joint rates.
Notes
See also
SerialLink.jacobn
Jacobian in end-effector frame
Options
R
Robotics Toolbox 9 for MATLAB 27 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Notes
Reference
Paul, Shimano, Mayer, Differential Kinematic Control Equations for Simple Manipu-
lators, IEEE SMC 11(6) 1981, pp. 456-460
See also
SerialLink.jtraj
Create joint space trajectory
q = R.jtraj(T0, tf, m) is a joint space trajectory where the joint coordinates reflect mo-
tion from end-effector pose T0 to tf in m steps with default zero boundary conditions
for velocity and acceleration. The trajectory q is an m × N matrix, with one row per
time step, and one column per joint, where N is the number of robot joints.
Note
See also
SerialLink.maniplty
Manipulability measure
m = R.maniplty(q, options) is the manipulability index measure for the robot at the
joint configuration q. It indicates dexterity, how isotropic the robot’s motion is with
respect to the 6 degrees of Cartesian motion. The measure is low when the manipulator
is close to a singularity. If q is a matrix m is a column vector of manipulability indices
for each pose specified by a row of q.
R
Robotics Toolbox 9 for MATLAB 28 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Options
Notes
• by default the measure includes rotational and translational dexterity, but this
involves adding different units. It can be more useful to look at the translational
and rotational manipulability separately.
See also
SerialLink.inertia, SerialLink.jacob0
SerialLink.mtimes
Join robots
SerialLink.nofriction
Remove friction
rnf = R.nofriction() is a robot object with the same parameters as R but with non-linear
(Couolmb) friction coefficients set to zero.
rnf = R.nofriction(’all’) as above but all friction coefficients set to zero.
R
Robotics Toolbox 9 for MATLAB 29 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Notes:
• Non-linear (Coulomb) friction can cause numerical problems when integrating
the equations of motion (R.fdyn).
• The resulting robot object has its name string modified by prepending ‘NF/’.
See also
SerialLink.fdyn, Link.nofriction
SerialLink.payload
Add payload to end of manipulator
See also
SerialLink.ikine6s
SerialLink.perturb
Perturb robot parameters
rp = R.perturb(p) is a new robot object in which the dynamic parameters (link mass
and inertia) have been perturbed. The perturbation is multiplicative so that values are
multiplied by random numbers in the interval (1-p) to (1+p). The name string of the
perturbed robot is prefixed by ‘p/’.
Useful for investigating the robustness of various model-based control schemes. For
example to vary parameters in the range +/- 10 percent is:
r2 = p560.perturb(0.1);
SerialLink.plot
Graphical display and animation
R
Robotics Toolbox 9 for MATLAB 30 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
robot is displayed at the joint angle q, or if a matrix it is animated as the robot moves
along the trajectory.
The graphical robot object holds a copy of the robot object and the graphical element
is tagged with the robot’s name (.name property). This state also holds the last joint
configuration which can be retrieved, see PLOT(robot) below.
Figure behaviour
If no robot of this name is currently displayed then a robot will be drawn in the current
figure. If hold is enabled (hold on) then the robot will be added to the current figure.
If the robot already exists then that graphical model will be found and moved.
If one or more plots of this robot already exist then these will all be moved according
to the argument q. All robots in all windows with the same name will be moved.
Multiple robots can be displayed in the same plot, by using “hold on” before calls to
plot(robot).
The configuration of the robot as displayed is stored in the SerialLink object and can
be accessed by the read only object property R.q.
The robot is displayed as a basic stick figure robot with annotations such as:
• shadow on the floor
• XYZ wrist axes and labels
• joint cylinders and axes
which are controlled by options.
The size of the annotations is determined using a simple heuristic from the workspace
dimensions. This dimension can be changed by setting the multiplicative scale factor
using the ‘mag’ option.
R
Robotics Toolbox 9 for MATLAB 31 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Options
‘workspace’, W size of robot 3D workspace, W = [xmn, xmx ymn ymx zmn zmx]
‘delay’, d delay betwen frames for animation (s)
‘cylinder’, C color for joint cylinders, C=[r g b]
‘mag’, scale annotation scale factor
‘perspective’—’ortho’ type of camera view
‘raise’—’noraise’ controls autoraise of current figure on plot
‘render’—’norender’ controls shaded rendering after drawing
‘loop’—’noloop’ controls endless loop mode
‘base’—’nobase’ controls display of base ‘pedestal’
‘wrist’—’nowrist’ controls display of wrist
‘shadow’—’noshadow’ controls display of shadow
‘name’—’noname’ display the robot’s name
‘xyz’—’noa’ wrist axis label
‘jaxes’—’nojaxes’ control display of joint axes
‘joints’—’nojoints’ controls display of joints
The options come from 3 sources and are processed in order:
• Cell array of options returned by the function PLOTBOTOPT.
• Cell array of options given by the ‘plotopt’ option when creating the SerialLink
object.
• List of arguments in the command line.
See also
plotbotopt, SerialLink.fkine
SerialLink.rne
Inverse dynamics
tau = R.rne(q, qd, qdd) is the joint torque required for the robot R to achieve the
specified joint position q, velocity qd and acceleration qdd.
tau = R.rne(q, qd, qdd, grav) as above but overriding the gravitational acceleration
vector in the robot object R.
tau = R.rne(q, qd, qdd, grav, fext) as above but specifying a wrench acting on the end
of the manipulator which is a 6-vector [Fx Fy Fz Mx My Mz].
tau = R.rne(x) as above where x=[q,qd,qdd].
tau = R.rne(x, grav) as above but overriding the gravitational acceleration vector in
the robot object R.
tau = R.rne(x, grav, fext) as above but specifying a wrench acting on the end of the
manipulator which is a 6-vector [Fx Fy Fz Mx My Mz].
R
Robotics Toolbox 9 for MATLAB 32 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
If q,qd and qdd, or x are matrices with M rows representing a trajectory then tau is an
M × N matrix with rows corresponding to each trajectory state.
Notes:
• The robot base transform is ignored
• The torque computed also contains a contribution due to armature inertia.
• rne can be either an M-file or a MEX-file. See the manual for details on how to
configure the MEX-file. The M-file is a wrapper which calls either rne DH or
rne MDH depending on the kinematic conventions used by the robot object.
See also
SerialLink.showlink
Show parameters of all links
R.showlink() shows details of all link parameters for the robot object, including inertial
parameters.
See also
Link.showlink, Link
SerialLink.teach
Graphical teach pendant
See also
SerialLink.plot
R
Robotics Toolbox 9 for MATLAB 33 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Bug2
Bug navigation class
A concrete subclass of Navigation that implements the bug2 navigation algorithm. This
is a simple automaton that performs local planning, that is, it can only sense the imme-
diate presence of an obstacle.
Methods
path Compute a path from start to goal
visualize Display the occupancy grid
display Display the state/parameters in human readable form
char Convert the state/parameters to human readable form
Example
load map1
bug = Bug2(map);
bug.goal = [50; 35];
bug.path([20; 10]);
See also
Bug2.Bug2
bug2 navigation object constructor
See also
Navigation.Navigation
R
Robotics Toolbox 9 for MATLAB 34 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
DHFactor
Simplify symbolic link transform expressions
indicates a rotation of q1 about the z-axis, then rotation of q2 about the x-axis, transla-
tion of L1 about the y-axis, rotation of q3 about the x-axis and translation of L2 along
the z-axis.
Methods
display shows the simplified version in terms of Denavit-Hartenberg parameters
base shows the base transform
tool shows the tool transform
command returns a string that could be passed to the SerialLink() object constructor to generate
a robot with these kinematics.
Example
>> s = ’Rz(q1).Rx(q2).Ty(L1).Rx(q3).Tz(L2)’;
>> dh = DHFactor(s);
>> dh
DH(q1+90, 0, 0, +90).DH(q2, L1, 0, 0).DH(q3-90, L2, 0, 0).Rz(+90).Rx(-90).Rz(-90)
>> r = eval( dh.command() );
Notes
See also
SerialLink
R
Robotics Toolbox 9 for MATLAB 35 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
DXform
Distance transform navigation class
Methods
plan Compute the cost map given a goal and map
path Compute a path to the goal
visualize Display the obstacle map
display Print the parameters in human readable form
char Convert the parameters to a human readable string
Properties
Example
load map1
dx = DXform(map);
dx.plan(goal)
dx.path(start)
See also
DXform.DXform
Distance transform navigation constructor
R
Robotics Toolbox 9 for MATLAB 36 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
Navigation.Navigation
DXform.char
Convert navigation object to string
See also
DXform.display
DXform.plan
Plan path to goal
DX.plan() updates DX with a costmap of distance to the goal from every non-obstacle
point in the map. The goal is as specified to the constructor.
DX.plan(goal) as above but uses the specified goal
DX.plan(goal, s) as above but displays the evolution of the costmap, with one iteration
displayed every s seconds.
DXform.setgoal
the imorph primitive we need to set the target pixel to 0,
DXform.visualize
Visualize navigation environment
DX.visualize() displays the occupancy grid and the goal distance in a new figure. The
goal distance is shown by intensity which increases with distance from the goal. Ob-
stacles are overlaid and shown in red.
R
Robotics Toolbox 9 for MATLAB 37 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
DX.visualize(p) as above but also overlays the points p in the path points which is an
N × 2 matrix.
See also
Navigation.visualize
Dstar
D* navigation class
Methods
plan Compute the cost map given a goal and map
path Compute a path to the goal
visualize Display the obstacle map
display Print the parameters in human readable form
char Convert the parameters to a human readable string
modify cost Modify the costmap
costmap get Return the current costmap
Example
load map1
ds = Dstar(map);
ds.plan(goal)
ds.path(start)
See also
R
Robotics Toolbox 9 for MATLAB 38 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Dstar.Dstar
D* navigation constructor
See also
Navigation.Navigation
Dstar.char
Convert navigation object to string
See also
Dstar.display
Dstar.costmap get
Get the current costmap
Dstar.modify cost
Modify cost map
DS.modify cost(p, new) modifies the cost map at p=[X,Y] to have the value new.
After one or more point costs have been updated the path should be replanned by calling
DS.plan().
R
Robotics Toolbox 9 for MATLAB 39 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Dstar.plan
Plan path to goal
DS.plan() updates DS with a costmap of distance to the goal from every non-obstacle
point in the map. The goal is as specified to the constructor.
DS.plan(goal) as above but uses the specified goal.
Note
• if a path has already been planned, but the costmap was modified, then reinvok-
ing this method will replan, incrementally updating the plan at lower cost than a
full replan.
Dstar.reset
Reset the planner
DS.reset() resets the D* planner. The next instantiation of DS.plan() will perform a
global replan.
Dstar.visualize
Visualize navigation environment
DS.visualize() displays the occupancy grid and the goal distance in a new figure. The
goal distance is shown by intensity which increases with distance from the goal. Ob-
stacles are overlaid and shown in red.
DS.visualize(p) as above but also overlays the points p in the path points which is an
N × 2 matrix.
See also
Navigation.visualize
R
Robotics Toolbox 9 for MATLAB 40 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
EKF
Extended Kalman Filter for vehicle pose and map estimation
Methods
run run the filter
plot xy return/plot the actual path of the vehicle
plot P return/plot the estimate covariance
plot map plot feature points and confidence limits
plot ellipse plot path with covariance ellipses
display print the filter state in human readable form
char convert the filter state to human readable string
Properties
R
Robotics Toolbox 9 for MATLAB 41 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Create a vehicle with odometry covariance V, add a driver to it, create a Kalman filter
with estimated covariance V est and initial state covariance P0, then run the filter for
N time steps.
veh = Vehicle(V);
veh.add_driver( RandomPath(20, 2) );
ekf = EKF(veh, V_est, P0);
ekf.run(N);
Create a vehicle with odometry covariance V, add a driver to it, create a map with 20
point features, create a sensor that uses the map and vehicle state to estimate feature
range and bearing with covariance W, the Kalman filter with estimated covariances
V est and W est and initial vehicle state covariance P0, then run the filter for N time
steps.
veh = Vehicle(V);
veh.add_driver( RandomPath(20, 2) );
map = Map(20);
sensor = RangeBearingSensor(veh, map, W);
ekf = EKF(veh, V_est, P0, sensor, W_est, map);
ekf.run(N);
Create a vehicle with odometry covariance V, add a driver to it, create a sensor that
uses the map and vehicle state to estimate feature range and bearing with covariance
W, the Kalman filter with estimated sensor covariance W est and a “perfect” vehicle
(no covariance), then run the filter for N time steps.
veh = Vehicle(V);
veh.add_driver( RandomPath(20, 2) );
sensor = RangeBearingSensor(veh, map, W);
ekf = EKF(veh, [], [], sensor, W_est, []);
ekf.run(N);
Create a vehicle with odometry covariance V, add a driver to it, create a map with 20
point features, create a sensor that uses the map and vehicle state to estimate feature
range and bearing with covariance W, the Kalman filter with estimated covariances
V est and W est and initial state covariance P0, then run the filter for N time steps to
estimate
the vehicle state at each time step and the map.% veh = Vehicle(V);
veh.add_driver( RandomPath(20, 2) );
map = Map(20);
sensor = RangeBearingSensor(veh, map, W);
R
Robotics Toolbox 9 for MATLAB 42 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Reference
See also
EKF.EKF
EKF object constructor
E = EKF(vehicle, vest, p0) is an EKF that estimates the state of the vehicle with
estimated odometry covariance vest (2 × 2) and initial covariance (3 × 3).
E = EKF(vehicle, vest, p0, sensor, west, map) as above but uses information from a
vehicle mounted sensor, estimated sensor covariance west and a map.
If map is [] then it will be estimated.
If vest and p0 are [] the vehicle is assumed error free and the filter will estimate the
landmark positions (map).
If vest and p0 are finite the filter will estimate the vehicle pose and the landmark posi-
tions (map).
Notes
See also
EKF.char
Convert EKF object to string
E.char() is a string representing the state of the EKF object in human-readable form.
R
Robotics Toolbox 9 for MATLAB 43 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
EKF.display
Display status of EKF object
Notes
• this method is invoked implicitly at the command line when the result of an
expression is a EKF object and the command has no trailing semicolon.
See also
EKF.char
EKF.plot P
Plot covariance magnitude
E.plot P() plots the estimated covariance magnitude against time step.
E.plot P(ls) as above but the optional line style arguments ls are passed to plot.
m = E.plot P() returns the estimated covariance magnitude at all time steps as a vector.
EKF.plot ellipse
Plot vehicle covariance as an ellipse
E.plot ellipse(i) overlay the current plot with the estimated vehicle position covariance
ellipses for every i’th time step.
E.plot ellipse() as above but i=20.
E.plot ellipse(i, ls) as above but pass line style arguments ls to plot ellipse.
See also
plot ellipse
R
Robotics Toolbox 9 for MATLAB 44 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
EKF.plot map
Plot landmarks
E.plot map(i) overlay the current plot with the estimated landmark position (a +-marker)
and a covariance ellipses for every i’th time step.
E.plot map() as above but i=20.
E.plot map(i, ls) as above but pass line style arguments ls to plot ellipse.
See also
plot ellipse
EKF.plot xy
Plot vehicle position
EKF.run
Run the EKF
Notes
Link
Robot manipulator Link class
A Link object holds all information related to a robot link such as kinematics parame-
teres, rigid-body inertial parameters, motor and transmission parameters.
R
Robotics Toolbox 9 for MATLAB 45 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Methods
A return link transform (A) matrix
RP return joint type: ‘R’ or ‘P’
friction return friction force
nofriction return Link object with friction parameters set to zero
dyn display link dynamic parameters
islimit true if joint exceeds soft limit
isrevolute true if joint is revolute
isprismatic true if joint is prismatic
nofriction remove joint friction
display print the link parameters in human readable form
char convert the link parameters to human readable string
Properties (read/write)
Notes
See also
SerialLink, Link.Link
R
Robotics Toolbox 9 for MATLAB 46 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Link.A
Link transform matrix
Notes
• For a revolute joint the theta parameter of the link is ignored, and q used instead.
• For a prismatic joint the d parameter of the link is ignored, and q used instead.
• The link offset parameter is added to q before computation of the transformation
matrix.
Link.Link
Create robot link object
Options
R
Robotics Toolbox 9 for MATLAB 47 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
• the link dynamic (inertial and motor) parameters are all set to zero. These must
be set by explicitly assigning the object properties: m, r, I, Jm, B, Tc, G.
Link.RP
Joint type
Link.char
String representation of parameters
See also
Link.display
Link.display
Display parameters
Notes
• this method is invoked implicitly at the command line when the result of an
expression is a Link object and the command has no trailing semicolon.
See also
R
Robotics Toolbox 9 for MATLAB 48 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Link.dyn
display the inertial properties of link
L.dyn() displays the inertial properties of the link object in a multi-line format. The
properties shown are mass, centre of mass, inertia, friction, gear ratio and motor prop-
erties.
If L is a vector of Link objects show properties for each element.
Link.friction
Joint friction force
Link.islimit
Test joint limits
L.islimit(q) is true (1) if q is outside the soft limits set for this joint.
Link.isprismatic
Test if joint is prismatic
See also
Link.isrevolute
Link.isrevolute
Test if joint is revolute
R
Robotics Toolbox 9 for MATLAB 49 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
Link.isprismatic
Link.nofriction
Remove friction
Link.set.I
Set link inertia
Link.set.Tc
Set Coulomb friction
L.Tc = F set Coulomb friction parameters to [FP FM], for a symmetric Coulomb fric-
tion model.
L.Tc = [FP FM] set Coulomb friction to [FP FM], for an asymmetric Coulomb friction
model. FP>0 and FM<0.
See also
Link.friction
R
Robotics Toolbox 9 for MATLAB 50 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Link.set.r
Set centre of gravity
Map
Map of planar point features
m = Map(n, dim) returns a Map object that represents n random point features in a
planar region bounded by +/-dim in the x- and y-directions.
Methods
plot Plot the feature map
feature Return a specified map feature
display Display map parameters in human readable form
char Convert map parameters to human readable string
Properties
Reference
See also
RangeBearingSensor, EKF
R
Robotics Toolbox 9 for MATLAB 51 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Map.Map
Map of point feature landmarks
m = Map(n, dim) is a Map object that represents n random point features in a planar
region bounded by +/-dim in the x- and y-directions.
Map.char
Convert vehicle parameters and state to a string
Map.display
Display map parameters
Notes
• this method is invoked implicitly at the command line when the result of an
expression is a Map object and the command has no trailing semicolon.
See also
map.char
Map.feature
Return the specified map feature
R
Robotics Toolbox 9 for MATLAB 52 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Map.plot
Plot the feature map
M.plot() plots the feature map in the current figure, as a square region with dimensions
given by the M.dim property. Each feature is marked by a black diamond.
M.plot(ls) plots the feature map as above, but the arguments ls are passed to plot and
override the default marker style.
Notes
Map.verbosity
Set verbosity
M.verbosity(v) set verbosity to v, where 0 is silent and greater values display more
information.
Navigation
Navigation superclass
Methods
visualize display the occupancy grid
plan plan a path to goal
path return/animate a path from start to goal
display print the parameters in human readable form
char convert the parameters to a human readable string
R
Robotics Toolbox 9 for MATLAB 53 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Notes
• subclasses the Matlab handle class which means that pass by reference semantics
apply.
See also
Navigation.Navigation
Create a Navigation object
Options
R
Robotics Toolbox 9 for MATLAB 54 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Navigation.char
Convert navigation object to string
Navigation.display
Display status of navigation object
Notes
• this method is invoked implicitly at the command line when the result of an
expression is a Navigation object and the command has no trailing semicolon.
See also
Navigation.char
Navigation.path
Follow path from start to goal
N.path(start) animates the robot moving from start to the goal (which is a property of
the object).
N.path() display the occupancy grid, prompt the user to click a start location, then
compute a path from this point to the goal (which is a property of the object).
x = N.path(start) returns the path from start to the goal (which is a property of the
object).
The method performs the following steps:
• get start position interactively if not given
• initialized navigation, invoke method N.navigate init()
• visualize the environment, invoke method N.visualize()
• iterate on the next() method of the subclass
R
Robotics Toolbox 9 for MATLAB 55 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
Navigation.visualize, Navigation.goal
Navigation.verbosity
Set verbosity
N.verbosity(v) set verbosity to v, where 0 is silent and greater values display more
information.
Navigation.visualize
Visualize navigation environment
Options
PRM
Probabilistic roadmap navigation class
R
Robotics Toolbox 9 for MATLAB 56 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Methods
plan Compute the roadmap
path Compute a path to the goal
visualize Display the obstacle map
display Print the parameters in human readable form
char Convert the parameters to a human readable string
Example
load map1
prm = PRM(map);
prm.plan()
prm.path(start, goal)
See also
PRM.PRM
Create a PRM navigation object constructor
Options
See also
Navigation.Navigation
R
Robotics Toolbox 9 for MATLAB 57 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
PRM.char
Convert navigation object to string
See also
PRM.display
PRM.path
Find a path between two points
P.path(start, goal) finds and displays a path from start to goal which is overlaid on
the occupancy grid.
x = P.PATH(start, goal) is the path from start to goal as a 2 × N matrix with columns
representing points along the path.
PRM.plan
Create a probabilistic roadmap
P.plan() creates the probabilistic roadmap by randomly sampling the free space in the
map and building a graph with edges connecting close points. The resulting graph is
kept within the object.
PRM.visualize
e
Options
R
Robotics Toolbox 9 for MATLAB 58 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
ParticleFilter
Particle filter class
Monte-carlo based localisation for estimating vehicle position based on odometry and
observations of known landmarks.
Methods
run run the particle filter
plot xy display estimated vehicle path
plot pdf display particle distribution
Properties
Example
For the particle filter we need to define two covariance matrices. The first is is the
covariance of the random noise added to the particle states at each iteration to represent
uncertainty in configuration.
Q = diag([0.1, 0.1, 1*pi/180]).ˆ2;
R
Robotics Toolbox 9 for MATLAB 59 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
L = diag([0.1 0.1]);
which is configured with 1000 particles. The particles are initially uniformly dis-
tributed over the 3-dimensional configuration space.
We run the simulation for 1000 time steps
pf.run(1000);
The particles are a sampled approximation to the PDF and we can display this as
pf.plot_pdf()
Acknowledgement
Reference
See also
ParticleFilter.ParticleFilter
Particle filter constructor
R
Robotics Toolbox 9 for MATLAB 60 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Notes
See also
ParticleFilter.plot pdf
Plot particles as a PDF
PF.plot pdf() plots a sparse PDF as a series of vertical line segments of height equal to
particle weight.
ParticleFilter.plot xy
Plot vehicle position
ParticleFilter.run
Run the particle filter
Notes
R
Robotics Toolbox 9 for MATLAB 61 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Pgraph
Simple graph class
Graphs
• are undirected
• are symmetric cost edges (A to B is same cost as B to A)
• are embedded in coordinate system
• have no loops (edges from A to A)
• vertices are represented by integer ids, vid
• edges are represented by integer ids, eid
Graph connectivity is maintained by a labeling algorithm and this is updated every time
an edge is added.
Methods
R
Robotics Toolbox 9 for MATLAB 62 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Pgraph.PGraph
Graph class constructor
Options
Note
• The distance metric is either ‘Euclidean’ or ‘SE2’ which is the sum of the squares
of the difference in position and angle modulo 2pi.
Pgraph.add edge
Add an edge to the graph
E = G.add edge(v1, v2) add an edge between nodes with id v1 and v2, and returns the
edge id E.
R
Robotics Toolbox 9 for MATLAB 63 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
E = G.add edge(v1, v2, C) add an edge between nodes with id v1 and v2 with cost C.
Pgraph.add node
Add a node to the graph
v = G.add node(x) adds a node with coordinate x, where x is D × 1, and returns the
node id v.
v = G.add node(x, v) adds a node with coordinate x and connected to node v by an
edge.
v = G.add node(x, v, C) adds a node with coordinate x and connected to node v by an
edge with cost C.
Pgraph.char
Convert graph to string
s = G.char() returns a compact human readable representation of the state of the graph
including the number of vertices, edges and components.
Pgraph.clear
Clear the graph
Pgraph.closest
Find closest node
R
Robotics Toolbox 9 for MATLAB 64 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Pgraph.connectivity
Graph connectivity
Pgraph.coord
Coordinate of node
Pgraph.cost
Cost of edge
Pgraph.display
Display state of the graph
G.display() displays a compact human readable representation of the state of the graph
including the number of vertices, edges and components.
See also
PGraph.char
Pgraph.distance
Distance between nodes
d = G.distance(v1, v2) return the geometric distance between the nodes with id v1
and v2.
R
Robotics Toolbox 9 for MATLAB 65 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Pgraph.distances
distance to all nodes
Pgraph.edges
Find edges given vertex
Pgraph.goal
Set goal node
G.goal(vg) for least-cost path through graph set the goal node. The cost of reaching
every node in the graph connected to vg is computed.
See also
PGraph.path
cost is total distance from goal
Pgraph.neighbours
Neighbours of a node
n = G.neighbours(v) return a vector of ids for all nodes which are directly connected
neighbours of node id v.
[n,C] = G.neighbours(v) return a vector n of ids for all nodes which are directly con-
nected neighbours of node id v. The elements of C are the edge costs of the paths to
the corresponding node ids in n.
R
Robotics Toolbox 9 for MATLAB 66 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Pgraph.next
Find next node toward goal
v = G.next(vs) return the id of a node connected to node id vs that is closer to the goal.
See also
PGraph.goal, PGraph.path
Pgraph.path
Find path to goal node
p = G.path(vs) return a vector of node ids that form a path from the starting node vs
to the previously specified goal. The path includes the start and goal node id.
See also
PGraph.goal
Pgraph.pick
Graphically select a node
v = G.pick() returns the id of the node closest to the point clicked by user on a plot of
the graph.
See also
PGraph.plot
Pgraph.plot
Plot the graph
G.plot(opt) plot the graph in the current figure. Nodes are shown as colored circles.
R
Robotics Toolbox 9 for MATLAB 67 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Options
Pgraph.showComponent
t
Pgraph.showVertex
Highlight a vertex
Pgraph.vertices
Find vertices given edge
Polygon
- General polygon class
p = Polygon(vertices);
R
Robotics Toolbox 9 for MATLAB 68 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Methods
plot Plot polygon
area Area of polygon
moments Moments of polygon
centroid Centroid of polygon
perimeter Perimter of polygon
transform Transform polygon
inside Test if points are inside polygon
intersection Intersection of two polygons
difference Difference of two polygons
union Union of two polygons
xor Exclusive or of two polygons
display print the polygon in human readable form
char convert the polgyon to human readable string
Properties
Notes
Acknowledgement
The methods inside, intersection, difference, union, and xor are based on code written
by:
Kirill K. Pankratov, [email protected], http://puddle.mit.edu/ glenn/kirill/saga.html
and require a licence. However the author does not respond to email regarding the
licence, so use with care.
Polygon.Polygon
Polygon class constructor
R
Robotics Toolbox 9 for MATLAB 69 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Polygon.area
Area of polygon
Polygon.centroid
Centroid of polygon
Polygon.char
String representation
Polygon.difference
Difference of polygons
Notes
Polygon.display
Display polygon
R
Robotics Toolbox 9 for MATLAB 70 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
Polygon.char
Polygon.inside
Test if points are inside polygon
in = p.inside(p) tests if points given by columns of p are inside the polygon. The
corresponding elements of in are either true or false.
Polygon.intersect
Intersection of polygon with list of polygons
Polygon.intersect line
Intersection of polygon and line segment
i = P.intersect line(L) is the intersection points of a polygon P with the line segment
L=[x1 x2; y1 y2]. i is an N × 2 matrix with one column per intersection, each column
is [x y]’.
Polygon.intersection
Intersection of polygons
Notes
R
Robotics Toolbox 9 for MATLAB 71 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Polygon.moments
Moments of polygon
See also
mpq poly
Polygon.perimeter
Perimeter of polygon
Polygon.plot
Plot polygon
Polygon.transform
Transformation of polygon vertices
Polygon.union
Union of polygons
R
Robotics Toolbox 9 for MATLAB 72 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Notes
• If these polygons are not intersecting, returns a polygon with vertices of both
polygons separated by NaNs.
• If the result P is not simply connected (such as a polygon with a “hole”) the re-
sulting contour consist of counter- clockwise “outer boundary” and one or more
clock-wise “inner boundaries” around “holes”.
Polygon.xor
Exclusive or of polygons
Notes
• If these polygons are not intersecting, returns a polygon with vertices of both
polygons separated by NaNs.
• If the result P is not simply connected (such as a polygon with a “hole”) the re-
sulting contour consist of counter- clockwise “outer boundary” and one or more
clock-wise “inner boundaries” around “holes”.
Quaternion
Quaternion class
R
Robotics Toolbox 9 for MATLAB 73 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Methods
inv return inverse of quaterion
norm return norm of quaternion
unit return unit quaternion
unitize unitize this quaternion
plot same options as trplot()
interp interpolation (slerp) between q and q2, 0<=s<=1
scale interpolation (slerp) between identity and q, 0<=s<=1
dot derivative of quaternion with angular velocity w
R 3 × 3 rotation matrix
T 4 × 4 homogeneous transform matrix
s real part
v vector part
Notes
See also
trinterp, trplot
Quaternion.Quaternion
Constructor for quaternion objects
R
Robotics Toolbox 9 for MATLAB 74 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
q = Quaternion(s) is a quaternion formed from the scalar s and zero vector part:
s<0,0,0>
q = Quaternion(v) is a pure quaternion with the specified vector part: 0<v>
q = Quaternion(th, v) is a unit quaternion corresponding to rotation of th about the
vector v.
q = Quaternion(R) is a unit quaternion corresponding to the orthonormal rotation
matrix R.
q = Quaternion(T) is a unit quaternion equivalent to the rotational part of the homo-
geneous transform T.
Notes
Quaternion.R
Return equivalent orthonormal rotation matrix
Quaternion.T
Return equivalent homogeneous transformationmatrix
Quaternion.char
Create string representation of quaternion object
R
Robotics Toolbox 9 for MATLAB 75 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Quaternion.display
Display the value of a quaternion object
Notes
• this method is invoked implicitly at the command line when the result of an
expression is a Quaternion object and the command has no trailing semicolon.
See also
Quaternion.char
Quaternion.double
Convert a quaternion object to a 4-element vector
Quaternion.interp
Interpolate rotations expressed by quaternion objects
See also
ctraj, Quaternion.scale
R
Robotics Toolbox 9 for MATLAB 76 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Quaternion.inv
Invert a unit-quaternion
Quaternion.minus
Subtract two quaternion objects
Quaternion.mpower
Raise quaternion to integer power
Quaternion.mrdivide
Compute quaternion quotient.
Quaternion.mtimes
Multiply a quaternion object
R
Robotics Toolbox 9 for MATLAB 77 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Quaternion.norm
Compute the norm of a quaternion
Quaternion.plot
Plot a quaternion object
See also
trplot
Quaternion.plus
Add two quaternion objects
Quaternion.scale
Interpolate rotations expressed by quaternion objects
See also
ctraj, Quaternion.interp
R
Robotics Toolbox 9 for MATLAB 78 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Quaternion.unit
Unitize a quaternion
RRT
Class for rapidly-exploring random tree navigation
A concrete class that implements the RRT navigation algorithm. This class subclasses
the Navigation class.
Usage for subclass:
rrt = RRT(occgrid, options) create an instance object
rrt show summary statistics about the object
rrt.visualize() display the occupancy grid
rrt.plan(goal) plan a path to coordinate goal
rrt.path(start) display a path from start to goal
p = rrt.path(start) return a path from start to goal
Options
Notes
R
Robotics Toolbox 9 for MATLAB 79 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
RRT.visualize
;
RandomPath
Vehicle driver class
Methods
init reset the random number generator
demand return speed and steer angle to next waypoint
display display the state and parameters in human readable form
char convert the state and parameters to human readable form
Properties
Example
veh = Vehicle(V);
veh.add_driver( RandomPath(20, 2) );
Notes
• it is possible in some cases for the vehicle to move outside the desired region, for
instance if moving to a waypoint near the edge, the limited turning circle may
cause it to move outside.
R
Robotics Toolbox 9 for MATLAB 80 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
• the vehicle chooses a new waypoint when it is closer than property closeenough
to the current waypoint.
• uses its own random number stream so as to not influence the performance of
other randomized algorithms such as path planning.
Reference
See also
Vehicle
RandomPath.RandomPath
Create a driver object
See also
Vehicle
RandomPath.char
Convert driver parameters and state to a string
RandomPath.demand
Compute speed and heading to waypoint
[speed,steer] = R.demand() returns the speed and steer angle to drive the vehicle to-
ward the next waypoint. When the vehicle is within R.closeenough a new waypoint is
chosen.
R
Robotics Toolbox 9 for MATLAB 81 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
Vehicle
RandomPath.display
Display driver parameters and state
R.display() display driver parameters and state in compact human readable form.
See also
RandomPath.char
RandomPath.init
Reset random number generator
R.INIT() resets the random number generator used to create the waypoints. This en-
ables the sequence of random waypoints to be repeated.
See also
randstream
RangeBearingSensor
Range and bearing sensor class
A concrete subclass of Sensor that implements a range and bearing angle sensor that
provides robot-centric measurements of the world. To enable this it has references to a
map of the world (Map object) and a robot moving through the world (Vehicle object).
R
Robotics Toolbox 9 for MATLAB 82 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Methods
reading return a random range/bearing observation
h return the observation for vehicle state xv and feature xf
Hx return a Jacobian matrix dh/dxv
Hxf return a Jacobian matrix dh/dxf
Hw return a Jacobian matrix dh/dw
g return feature positin given vehicle pose and observation
Gx return a Jacobian matrix dg/dxv
Gz return a Jacobian matrix dg/dz
Properties (read/write)
Reference
See also
RangeBearingSensor.Gx
Jacobian dg/dx
J = S.Gx(xv, z) returns the Jacobian dg/dxv at the vehicle state xv, for measurement z.
J is 2 × 3.
See also
RangeBearingSensor.g
RangeBearingSensor.Gz
Jacobian dg/dz
J = S.Gz(xv, z) returns the Jacobian dg/dz at the vehicle state xv, for measurement z.
J is 2 × 2.
R
Robotics Toolbox 9 for MATLAB 83 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
RangeBearingSensor.g
RangeBearingSensor.Hw
Jacobian dh/dv
J = S.Hw(xv, J) returns the Jacobian dh/dv at the vehicle state xv, for map feature J. J
is 2 × 2.
See also
RangeBearingSensor.h
RangeBearingSensor.Hx
Jacobian dh/dxv
J = S.Hx(xv, J) returns the Jacobian dh/dxv at the vehicle state xv, for map feature J.
J is 2 × 3.
J = S.Hx(xv, xf) as above but for a feature at coordinate xf.
See also
RangeBearingSensor.h
RangeBearingSensor.Hxf
Jacobian dh/dxf
J = S.Hxf(xv, J) returns the Jacobian dh/dxv at the vehicle state xv, for map feature J.
J is 2 × 2.
J = S.Hxf(xv, xf) as above but for a feature at coordinate xf.
See also
RangeBearingSensor.h
R
Robotics Toolbox 9 for MATLAB 84 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
RangeBearingSensor.RangeBearingSensor
Range and bearing sensor constructor
Options
See also
RangeBearingSensor.g
Compute landmark location
p = S.g(xv, z) is the world coordinate of feature given observation z and vehicle state
xv.
See also
RangeBearingSensor.Gx, RangeBearingSensor.Gz
RangeBearingSensor.h
Landmark range and bearing
R
Robotics Toolbox 9 for MATLAB 85 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
RangeBearingSensor.reading
Landmark range and bearing
See also
RangeBearingSensor.h
Sensor
Sensor superclass
Methods
display print the parameters in human readable form
char convert the parameters to a human readable string
Properties
Reference
R
Robotics Toolbox 9 for MATLAB 86 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
Sensor.Sensor
Sensor object constructor
s = Sensor(vehicle, map) is a sensor mounted on the Vehicle object vehicle and ob-
serving the landmark map map.
Sensor.char
Convert sensor parameters to a string
Sensor.display
Display status of sensor object
Notes
• this method is invoked implicitly at the command line when the result of an
expression is a Sensor object and the command has no trailing semicolon.
See also
Sensor.char
R
Robotics Toolbox 9 for MATLAB 87 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Vehicle
Car-like vehicle class
This class models the kinematics of a car-like vehicle (bicycle model). For given steer-
ing and velocity inputs it updates the true vehicle state and returns noise-corrupted
odometry readings.
veh = Vehicle(v) creates a Vehicle object with odometry covariance v, where v is a
2 × 2 matrix corresponding to the odometry vector [dx dtheta].
Methods
init initialize vehicle state
f predict next state based on odometry
step move one time step and return noisy odometry
control generate the control inputs for the vehicle
update update the vehicle state
run run for multiple time steps
Fx Jacobian of f wrt x
Fv Jacobian of f wrt odometry noise
gstep like step() but displays vehicle
plot plot/animate vehicle on current figure
plot xy plot the true path of the vehicle
add driver attach a driver object to this vehicle
display display state/parameters in human readable form
char convert state/parameters to human readable string
Properties (read/write)
Examples
R
Robotics Toolbox 9 for MATLAB 88 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
now apply a speed (0.2m/s) and steer angle (0.1rad) for 1 time step
odo = v.update([0.2, 0.1])
where odo is the noisy odometry estimate, and the new true vehicle state
v
which will move the vehicle within the region -10<x<10, -10<y<10 which we can
see by
v.run(1000)
which will show an animation of the vehicle moving between randomly selected way-
oints.
Reference
See also
RandomPath, EKF
Vehicle.Fv
Jacobian df/dv
J = V.Fv(x, odo) returns the Jacobian df/dv at the state x, for odometry input odo. J is
3 × 2.
See also
Vehicle.F, Vehicle.Fx
R
Robotics Toolbox 9 for MATLAB 89 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Vehicle.Fx
Jacobian df/dx
J = V.Fx(x, odo) returns the Jacobian df/dx at the state x, for odometry input odo. J is
3 × 3.
See also
Vehicle.F, Vehicle.Fv
Vehicle.Vehicle
Vehicle object constructor
v = Vehicle(vact) creates a Vehicle object with actual odometry covariance vact, where
vact is a 2 × 2 matrix corresponding to the odometry vector [dx dtheta].
Default parameters are:
alphalim 0.5
maxspeed 5
L 1
robotdim 0.2
x0 (0,0,0)
and can be overridden by assigning properties after the object has been created.
Vehicle.add driver
Add a driver for the vehicle
V.add driver(d) adds a driver object d for the vehicle. The driver object has one public
method:
[speed, steer] = d.demand();
that returns a speed and steer angle.
See also
RandomPath
R
Robotics Toolbox 9 for MATLAB 90 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Vehicle.char
Convert vehicle parameters and state to a string
Vehicle.control
Compute the control input to vehicle
See also
RandomPath
Vehicle.display
Display vehicle parameters and state
V.display() display vehicle parameters and state in compact human readable form.
See also
Vehicle.char
Vehicle.f
Predict next state based on odometry
xn = V.f(x, odo) predict next state xn based on current state x and odometry odo. x is
3 × 1, odo is [distance,change heading].
xn = V.f(x, odo, w) predict next state xn based on current state x, odometry odo, and
odometry noise w.
R
Robotics Toolbox 9 for MATLAB 91 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Vehicle.init
Reset state of vehicle object
Vehicle.plot
Plot vehicle
V.plot() plots the vehicle on the current axes at a pose given by the current state. If the
vehicle has been previously plotted its pose is updated. The vehicle is depicted as a
narrow triangle that travels “point first” and has a length V.robotdim.
V.plot(x) plots the vehicle on the current axes at the pose x.
Vehicle.plot xy
plot true path followed by vehicle
V.plot xy() plots the true xy-plane path followed by the vehicle.
V.plot xy(ls) as above but the line style arguments ls are passed to plot.
Vehicle.run
Run the vehicle simulation
See also
Vehicle.step
R
Robotics Toolbox 9 for MATLAB 92 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Vehicle.step
Move the vehicle model ahead one time step
odo = V.step(speed, steer) updates the vehicle state for one timestep of motion at
specified speed and steer angle, and returns noisy odometry.
odo = V.step() updates the vehicle state for one timestep of motion and returns noisy
odometry. If a “driver” is attached then its DEMAND() method is invoked to compute
speed and steer angle. If no driver is attached then speed and steer angle are assumed
to be zero.
See also
Vehicle.update
Update the vehicle state
odo = V.update(u) returns noisy odometry readings (covariance V.V) for motion with
u=[speed,steer].
about
Compact display of variable type
about(x) displays a compact line that describes the class and dimensions of x.
about x as above but this is the command rather than functional form
See also
whos
R
Robotics Toolbox 9 for MATLAB 93 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
angdiff
Difference of two angles
d = angdiff(th1, th2) returns the difference between angles th1 and th2 on the circle.
The result is in the interval [-pi pi). If th1 is a column vector, and th2 a scalar then re-
turn a column vector where th2 is modulo subtracted from the corresponding elements
of th1.
d = angdiff(th) returns the equivalent angle to th in the interval [-pi pi).
Return the equivalent angle in the interval [-pi pi).
angvec2r
Convert angle and vector orientation to a rotation matrix
See also
eul2r, rpy2r
angvec2tr
Convert angle and vector orientation to a homogeneous trans-
form
Note
R
Robotics Toolbox 9 for MATLAB 94 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
circle
Compute points on a circle
Options
colnorm
Column-wise norm of a matrix
ctraj
Cartesian trajectory between two points
R
Robotics Toolbox 9 for MATLAB 95 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
tc = ctraj(T0, T1, s) as above but the elements of s (n × 1) specify the fractional dis-
tance along the path, and these values are in the range [0 1]. The i’th point corresponds
to a distance s(i) along the path.
See also
delta2tr
Convert differential motion to a homogeneous transform
See also
tr2delta
diff2
diff3(v)
compute 2-point difference for each point in the vector v.
e2h
Euclidean to homogeneous
R
Robotics Toolbox 9 for MATLAB 96 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
edgelist
Return list of edge pixels for region
E = edgelist(im, seed) return the list of edge pixels of a region in the image im starting
at edge coordinate seed (i,j). The result E is a matrix, each row is one edge point
coordinate (x,y).
E = edgelist(im, seed, direction) returns the list of edge pixels as above, but the direc-
tion of edge following is specified. direction == 0 (default) means clockwise, non zero
is counter-clockwise. Note that direction is with respect to y-axis upward, in matrix
coordinate frame, not image frame.
Notes
See also
ilabel
eul2jac
Euler angle rate Jacobian
Notes
R
Robotics Toolbox 9 for MATLAB 97 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
rpy2jac, SERIALlINK.JACOBN
eul2r
Convert Euler angles to rotation matrix
Options
Note
See also
eul2tr
Convert Euler angles to homogeneous transform
R
Robotics Toolbox 9 for MATLAB 98 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
T = eul2tr(eul, options) as above but the Euler angles are taken from consecutive
columns of the passed matrix eul = [phi theta psi].
Options
Note
See also
gauss2d
kernel
k = gauss2d(im, c, sigma)
Returns a unit volume Gaussian smoothing kernel. The Gaussian has a standard devi-
ation of sigma, and the convolution kernel has a half size of w, that is, k is (2W+1) x
(2W+1).
If w is not specified it defaults to 2*sigma.
h2e
Homogeneous to Euclidean
R
Robotics Toolbox 9 for MATLAB 99 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
homline
Homogeneous line from two points
L = homline(x1, y1, x2, y2) returns a 3 × 1 vectors which describes a line in homoge-
neous form that contains the two Euclidean points (x1,y1) and (x2,y2).
Homogeneous points X (3 × 1) on the line must satisfy L’*X = 0.
See also
plot homline
homtrans
Apply a homogeneous transformation
See also
e2h, h2e
R
Robotics Toolbox 9 for MATLAB 100 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
imeshgrid
Domain matrices for image
[u,v] = imeshgrid(im) return matrices that describe the domain of image im and can
be used for the evaluation of functions over the image. The element u(v,u) = u and
v(v,u) = v.
[u,v] = imeshgrid(w, H) as above but the domain is w × H.
[u,v] = imeshgrid(size) as above but the domain is described size which is scalar size×
size or a 2-vector [w H].
See also
meshgrid
ishomog
Test if argument is a homogeneous transformation
ishomog(T) is true (1) if the argument T is of dimension 4 × 4 or 4x4xN, else false (0).
ishomog(T, ‘valid’) as above, but also checks the validity of the rotation matrix.
See also
isrot, isvec
isrot
Test if argument is a rotation matrix
isrot(R) is true (1) if the argument is of dimension 3 × 3 or 3x3xN, else false (0).
isrot(R, ‘valid’) as above, but also checks the validity of the rotation matrix.
R
Robotics Toolbox 9 for MATLAB 101 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
ishomog, isvec
isvec
Test if argument is a vector
See also
ishomog, isrot
jtraj
Compute a joint space trajectory between two points
See also
ctraj, SerialLink.jtraj
R
Robotics Toolbox 9 for MATLAB 102 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
lspb
Linear segment with parabolic blend
Notes
See also
tpoly, jtraj
mdl Fanuc10L
Create kinematic model of Fanuc AM120iB/10L robot
mdl_fanuc10L
Script creates the workspace variable R which describes the kinematic characteristics
of a Fanuc AM120iB/10L robot using standard DH conventions.
Also defines the workspace vector:
q0 mastering position.
R
Robotics Toolbox 9 for MATLAB 103 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Author
Wynand Swart, Mega Robots CC, P/O Box 8412, Pretoria, 0001, South Africa [email protected]
See also
mdl MotomanHP6
Create kinematic data of a Motoman HP6 manipulator
mdl_motomanHP6
Script creates the workspace variable R which describes the kinematic characteristics
of a Motoman HP6 manipulator using standard DH conventions.
Also defines the workspace vector:
q0 mastering position.
Author:
Wynand Swart, Mega Robots CC, P/O Box 8412, Pretoria, 0001, South Africa [email protected]
See also
mdl S4ABB2p8
Create kinematic model of ABB S4 2.8robot
mdl_s4abb2P8
Script creates the workspace variable R which describes the kinematic characteristics
of an ABB S4 2.8 robot using standard DH conventions.
Also defines the workspace vector:
q0 mastering position.
R
Robotics Toolbox 9 for MATLAB 104 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Author
Wynand Swart, Mega Robots CC, P/O Box 8412, Pretoria, 0001, South Africa [email protected]
See also
mdl puma560
Create model of Puma 560 manipulator
mdl_puma560
Script creates the workspace variable p560 which describes the kinematic and dynamic
characteristics of a Unimation Puma 560 manipulator using standard DH conventions.
The model includes armature inertia and gear ratios.
Also define the workspace vectors:
qz zero joint angle configuration
qr vertical ‘READY’ configuration
qstretch arm is stretched out in the X direction
qn arm is at a nominal non-singular configuration
Reference
• “A search for consensus among model parameters reported for the PUMA 560
robot”,
P. Corke and B. Armstrong-Helouvry,
Proc. IEEE Int. Conf. Robotics and Automation, (San Diego),
pp. 1608-1613, May 1994.
See also
R
Robotics Toolbox 9 for MATLAB 105 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
mdl puma560akb
Create model of Puma 560 manipulator
mdl_puma560akb
Script creates the workspace variable p560m which describes the kinematic and dy-
namic characterstics of a Unimation Puma 560 manipulator modified DH conventions.
Also defines the workspace vectors:
qz zero joint angle configuration
qr vertical ‘READY’ configuration
qstretch arm is stretched out in the X direction
References
• “The Explicit Dynamic Model and Inertial Parameters of the Puma 560 Arm”
Armstrong, Khatib and Burdick 1986
See also
mdl stanford
Create model of Stanford arm
mdl_stanford
Script creates the workspace variable stanf which describes the kinematic and dynamic
characteristics of the Stanford (Scheinman) arm.
Also defines the vectors:
qz zero joint angle configuration.
Note
• Gear ratios not currently known, though reflected armature inertia is known, so
gear ratios are set to 1.
R
Robotics Toolbox 9 for MATLAB 106 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
References
See also
mdl twolink
Create model of a simple 2-link mechanism
mdl_twolink
Script creates the workspace variable tl which describes the kinematic and dynamic
characteristics of a simple planar 2-link mechanism.
Also defines the vector:
qz corresponds to the zero joint angle configuration.
Notes
References
See also
R
Robotics Toolbox 9 for MATLAB 107 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
mstraj
Multi-segment multi-axis trajectory
Notes
See also
R
Robotics Toolbox 9 for MATLAB 108 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
mtraj
Multi-axis trajectory between two points
and possible values of tfunc include @lspb for a trapezoidal trajectory, or @tpoly for
a polynomial trajectory.
[q,qd,qdd] = mtraj(tfunc, q0, qf, T) as above but specifies the trajectory length in
terms of the length of the time vector T (m × 1).
Notes
See also
numcols
Return number of columns in matrix
See also
numrows
R
Robotics Toolbox 9 for MATLAB 109 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
numrows
Return number of rows in matrix
See also
numcols
oa2r
Convert orientation and approach vectors to rotation matrix
R = oa2r(o, a) is a rotation matrix for the specified orientation and approach vectors
(3 × 1) formed from 3 vectors such that R = [N o a] and N = o x a.
Notes
See also
oa2tr
Convert orientation and approach vectors to homogeneous
transformation
R
Robotics Toolbox 9 for MATLAB 110 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Notes
See also
plot2
Plot trajectories
plot2(p) plots a line with coordinates taken from successive rows of p. p can be N × 2
or N × 3.
If p has three dimensions, ie. Nx2xM or Nx3xM then the M trajectories are overlaid in
the one plot.
plot2(p, ls) as above but the line style arguments ls are passed to plot.
See also
plot
plot box
a box on the current plot
PLOT BOX(b, ls) draws a box defined by b=[XL XR; YL YR] with optional Matlab
linestyle options ls.
PLOT BOX(x1,y1, x2,y2, ls) draws a box with corners at (x1,y1) and (x2,y2), and
optional Matlab linestyle options ls.
R
Robotics Toolbox 9 for MATLAB 111 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
PLOT BOX(’centre’, P, ‘size’, W, ls) draws a box with center at P=[X,Y] and with
dimensions W=[WIDTH HEIGHT].
PLOT BOX(’topleft’, P, ‘size’, W, ls) draws a box with top-left at P=[X,Y] and with
dimensions W=[WIDTH HEIGHT].
plot circle
Draw a circle on the current plot
PLOT CIRCLE(C, R, options) draws a circle on the current plot with centre C=[X,Y]
and radius R. If C=[X,Y,Z] the circle is drawn in the XY-plane at height Z.
Options
plot ellipse
Draw an ellipse on the current plot
PLOT ELLIPSE(a, ls) draws an ellipse defined by X’AX = 0 on the current plot, cen-
tred at the origin, with Matlab line style ls.
PLOT ELLIPSE(a, C, ls) as above but centred at C=[X,Y]. current plot. If C=[X,Y,Z]
the ellipse is parallel to the XY plane but at height Z.
R
Robotics Toolbox 9 for MATLAB 112 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
plot homline
Draw a line in homogeneous form
H = PLOT HOMLINE(L, ls) draws a line in the current figure L.X = 0. The current
axis limits are used to determine the endpoints of the line. Matlab line specification ls
can be set.
The return argument is a vector of graphics handles for the lines.
See also
homline
plot point
point features
PLOT POINT(p, options) adds point markers to a plot, where p is 2 × N and each
column is the point coordinate.
Options
See also
plot, text
R
Robotics Toolbox 9 for MATLAB 113 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
plot poly
Plot a polygon
options
See also
plot sphere
Plot spheres
PLOT SPHERE(C, R, color) add spheres to the current figure. C is the centre of the
sphere and if its a 3 × N matrix then N spheres are drawn with centres as per the
columns. R is the radius and color is a Matlab color spec, either a letter or 3-vector.
H = PLOT SPHERE(C, R, color) as above but returns the handle(s) for the spheres.
H = PLOT SPHERE(C, R, color, alpha) as above but alpha specifies the opacity of
the sphere were 0 is transparant and 1 is opaque. The default is 1.
NOTES
R
Robotics Toolbox 9 for MATLAB 114 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
plotbotopt
Define default options for robot plotting
A user provided function that returns a cell array of default plot options for the Seri-
alLink.plot method.
See also
SerialLink.plot
plotp
Plot trajectories
plotp(p) plots a set of points p, which by Toolbox convention are stored one per col-
umn. p can be N × 2 or N × 3. By default a linestyle of ‘bx’ is used.
plotp(p, ls) as above but the line style arguments ls are passed to plot.
See also
plot, plot2
qplot
Plot joint angles
R
Robotics Toolbox 9 for MATLAB 115 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
jtraj, plot
r2t
Convert rotation matrix to a homogeneous transform
Notes
See also
t2r
ramp
create a ramp vector
R
Robotics Toolbox 9 for MATLAB 116 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
linspace
rotx
Rotation about X axis
See also
roty
Rotation about Y axis
See also
rotz
Rotation about Z axis
R
Robotics Toolbox 9 for MATLAB 117 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
rpy2jac
Jacobian from RPY angle rates to angular velocity
Notes
See also
eul2jac, SerialLink.JACOBN
rpy2r
Roll-pitch-yaw angles to rotation matrix
R
Robotics Toolbox 9 for MATLAB 118 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Options
Note
• In previous releases (<8) the angles corresponded to rotations about ZYX. Many
texts (Paul, Spong) use the rotation order ZYX. This old behaviour can be en-
abled by passing the option ‘zyx’
See also
tr2rpy, eul2tr
rpy2tr
Roll-pitch-yaw angles to homogeneous transform
Options
Note
• In previous releases (<8) the angles corresponded to rotations about ZYX. Many
texts (Paul, Spong) use the rotation order ZYX. This old behaviour can be en-
abled by passing the option ‘zyx’
R
Robotics Toolbox 9 for MATLAB 119 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
rt2tr
Convert rotation and translation to homogeneous transform
Notes
See also
rtdemo
Robot toolbox demonstrations
R
Robotics Toolbox 9 for MATLAB 120 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
• inverse dynamics
• forward dynamics
Notes
• The scripts require the user to periodically hit <Enter> in order to move through
the explanation.
• Set PAUSE OFF if you want the scripts to run completely automatically.
se2
Create planar translation and rotation transformation
See also
trplot2
skew
Create skew-symmetric matrix
R
Robotics Toolbox 9 for MATLAB 121 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
See also
vex
startup rtb
Initialize MATLAB paths for Robotics Toolbox
Adds demos, examples to the MATLAB path, and adds also to Java class path.
t2r
Return rotational submatrix of a homogeneous transforma-
tion
Notes
See also
R
Robotics Toolbox 9 for MATLAB 122 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
tb optparse
Standard option parser for Toolbox functions
The allowable options are specified by the names of the fields in the structure opt. By
default if an option is given that is not a field of opt an error is declared.
Sometimes it is useful to collect the unassigned options and this can be achieved using
a second output argument
[opt,arglist] = tb_optparse(opt, varargin);
which is a cell array of all unassigned arguments in the order given in varargin.
The return structure is automatically populated with fields: verbose and debug. The
following options are automatically parsed:
‘verbose’ sets opt.verbose <- true
‘debug’, N sets opt.debug <- N
‘setopt’, S sets opt <- S
‘showopt’ displays opt and arglist
R
Robotics Toolbox 9 for MATLAB 123 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
tpoly
Generate scalar polynomial trajectory
Notes
tr2angvec
Convert rotation matrix to angle-vector form
Notes
See also
angvec2r, angvec2tr
R
Robotics Toolbox 9 for MATLAB 124 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
tr2delta
Convert homogeneous transform to differential motion
Notes
See also
delta2tr, skew
tr2eul
Convert homogeneous transform to Euler angles
eul = tr2eul(T, options) are the ZYZ Euler angles expressed as a row vector corre-
sponding to the rotational part of a homogeneous transform T. The 3 angles eul=[PHI,THETA,PSI]
correspond to sequential rotations about the Z, Y and Z axes respectively.
eul = tr2eul(R, options) are the ZYZ Euler angles expressed as a row vector corre-
sponding to the orthonormal rotation matrix R.
If R or T represents a trajectory (has 3 dimensions), then each row of eul corresponds
to a step of the trajectory.
Options
R
Robotics Toolbox 9 for MATLAB 125 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Notes
• There is a singularity for the case where THETA=0 in which case PHI is arbi-
trarily set to zero and PSI is the sum (PHI+PSI).
See also
eul2tr, tr2rpy
tr2jac
Jacobian for differential motion
See also
tr2rpy
Convert a homogeneous transform to roll-pitch-yaw angles
rpy = tr2rpy(T, options) are the roll-pitch-yaw angles expressed as a row vector corre-
sponding to the rotation part of a homogeneous transform T. The 3 angles rpy=[R,P,Y]
correspond to sequential rotations about the X, Y and Z axes respectively.
rpy = tr2rpy(R, options) are the roll-pitch-yaw angles expressed as a row vector cor-
responding to the orthonormal rotation matrix R.
If R or T represents a trajectory (has 3 dimensions), then each row of rpy corresponds
to a step of the trajectory.
Options
R
Robotics Toolbox 9 for MATLAB 126 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Notes
• There is a singularity for the case where P=pi/2 in which case R is arbitrarily set
to zero and Y is the sum (R+Y).
• Note that textbooks (Paul, Spong) use the rotation order ZYX.
See also
rpy2tr, tr2eul
tranimate
Animate a coordinate frame
Options
See also
trplot
R
Robotics Toolbox 9 for MATLAB 127 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
transl
Create translational transform
Notes
• Somewhat unusually this function performs a function and its inverse. An his-
torical anomaly.
See also
ctraj
trinterp
Interpolate homogeneous transformations
See also
ctraj, quaternion
R
Robotics Toolbox 9 for MATLAB 128 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
trnorm
Normalize a homogeneous transform
Notes
• Used to prevent finite word length arithmetic causing transforms to become ‘un-
normalized’.
See also
oa2tr
trotx
Rotation about X axis
Notes
See also
R
Robotics Toolbox 9 for MATLAB 129 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
troty
Rotation about Y axis
Notes
See also
trotz
Rotation about Z axis
Notes
See also
trplot
Draw a coordinate frame
R
Robotics Toolbox 9 for MATLAB 130 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
Options
Examples
trplot(T, ’frame’, ’A’)
trplot(T, ’frame’, ’A’, ’color’, ’b’)
trplot(T1, ’frame’, ’A’, ’text_opts’, {’FontSize’, 10, ’FontWeight’, ’bold’})
Notes
See also
trplot2, tranimate
unit
Unitize a vector
Note
R
Robotics Toolbox 9 for MATLAB 131 Copyright
Peter
c Corke 2011
CHAPTER 2. FUNCTIONS AND CLASSES
vex
Convert skew-symmetric matrix to vector
Notes
See also
skew
wtrans
Transform a wrench between coordinate frames
See also
tr2delta, tr2jac
R
Robotics Toolbox 9 for MATLAB 132 Copyright
Peter
c Corke 2011