Robotics Toolbox
for MATLAB
Release 10
Peter Corke
2
Release
Release date
10.2
November 2017
Licence
Toolbox home page http://www.petercorke.com/robot
Discussion group
LGPL
http://groups.google.com.au/group/robotics-tool-box
Copyright c2017 Peter Corke
peter.i.corke@gmail.com
http://www.petercorke.com
Preface
This, the tenth major release of the Toolbox, represent-
ing over twenty five years of continuous development
and a substantial level of maturity. This version corre-
sponds to the second edition of the book “Robotics, Vi-
sion & Control, second edition” published in June 2017
– RVC2.
This MATLAB R Toolbox has a rich collection of func-
tions that are useful for the study and simulation of
robots: arm-type robot manipulators and mobile robots.
For robot manipulators, functions include kinematics,
trajectory generation, dynamics and control. For mobile
robots, functions include path planning, kinodynamic
planning, localization, map building and simultaneous
localization and mapping (SLAM).
The Toolbox makes strong use of classes to represent robots and such things as sen-
It includes Simulink R models to describe the evolution of arm or
sors and maps.
mobile robot state over time for a number of classical control strategies. The Tool-
box also provides functions for manipulating and converting between datatypes such
as vectors, rotation matrices, unit-quaternions, quaternions, homogeneous transforma-
tions and twists which are necessary to represent position and orientation in 2- and
3-dimensions.
The code is written in a straightforward manner which allows for easy understanding,
perhaps at the expense of computational efficiency. If you feel strongly about computa-
tional efficiency then you can always rewrite the function to be more efficient, compile
the M-file using the MATLAB compiler, or create a MEX version.
The bulk of this manual is auto-generated from the comments in the MATLAB code
itself. For elaboration on the underlying principles, extensive illustrations and worked
examples please consult “Robotics, Vision & Control, second edition” which provides
a detailed discussion (720 pages, nearly 500 figures and over 1000 code examples) of
how to use the Toolbox functions to solve many types of problems in robotics.
Robotics Toolbox 10.2 for MATLAB
3
Copyright cPeter Corke 2017
Robotics Toolbox 10.2 for MATLAB
4
Copyright cPeter Corke 2017
Functions by category
transforma-
Homogeneous
tions 3D
angvec2r . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
angvec2tr . . . . . . . . . . . . . . . . . . . . . . . . . . 20
eul2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
eul2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
ishomog . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
isrot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
isunit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
oa2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
oa2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
rotx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
roty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
rotz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
rpy2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
rpy2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
tr2angvec . . . . . . . . . . . . . . . . . . . . . . . . . 341
tr2eul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
tr2rpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
transl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
trchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
trexp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .350
trinterp . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
tripleangle . . . . . . . . . . . . . . . . . . . . . . . . 353
trlog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
trnorm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
trotx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
troty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
trotz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
trprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
trscale . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
Homogeneous
tions 2D
ishomog2 . . . . . . . . . . . . . . . . . . . . . . . . . . 80
transforma-
isrot2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
rot2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
transl2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
trchain2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
trexp2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
trinterp2 . . . . . . . . . . . . . . . . . . . . . . . . . . 353
trot2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
trprint2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
transforma-
Homogeneous
tion utilities
r2t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
rt2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
t2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
tr2rt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
and
Homogeneous points
lines
e2h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
h2e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
homline . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
homtrans . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Differential motion
delta2tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
eul2jac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
rpy2jac . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
skewa. . . . . . . . . . . . . . . . . . . . . . . . . . . . .314
skew. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314
tr2delta . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
tr2jac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
vexa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Robotics Toolbox 10.2 for MATLAB
5
Copyright cPeter Corke 2017
vex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
wtrans . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
Trajectory generation
ctraj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
jtraj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
lspb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
mstraj . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
mtraj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
tpoly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
trinterp2 . . . . . . . . . . . . . . . . . . . . . . . . . . 353
trinterp . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Pose representation classes
Quaternion . . . . . . . . . . . . . . . . . . . . . . . . 200
RTBPose. . . . . . . . . . . . . . . . . . . . . . . . . .234
SE2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
SE3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
SO2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
SO3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Twist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
UnitQuaternion . . . . . . . . . . . . . . . . . . . . 372
mdl_coil . . . . . . . . . . . . . . . . . . . . . . . . . . 103
mdl_hyper2d . . . . . . . . . . . . . . . . . . . . . . 104
mdl_hyper3d . . . . . . . . . . . . . . . . . . . . . . 105
mdl_irb140_mdh . . . . . . . . . . . . . . . . . . 106
mdl_irb140. . . . . . . . . . . . . . . . . . . . . . . .106
mdl_jaco . . . . . . . . . . . . . . . . . . . . . . . . . . 107
mdl_mico . . . . . . . . . . . . . . . . . . . . . . . . . 110
mdl_nao . . . . . . . . . . . . . . . . . . . . . . . . . . 111
mdl_p8 . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
mdl_phantomx . . . . . . . . . . . . . . . . . . . . 114
mdl_planar1 . . . . . . . . . . . . . . . . . . . . . . . 115
mdl_planar2 . . . . . . . . . . . . . . . . . . . . . . . 116
mdl_planar3 . . . . . . . . . . . . . . . . . . . . . . . 117
mdl_puma560akb . . . . . . . . . . . . . . . . . . 118
mdl_puma560 . . . . . . . . . . . . . . . . . . . . . 117
mdl_quadrotor . . . . . . . . . . . . . . . . . . . . . 119
mdl_stanford_mdh . . . . . . . . . . . . . . . . . 122
mdl_stanford . . . . . . . . . . . . . . . . . . . . . . 121
mdl_twolink_mdh . . . . . . . . . . . . . . . . . 123
mdl_twolink_sym . . . . . . . . . . . . . . . . . . 125
mdl_twolink. . . . . . . . . . . . . . . . . . . . . . .123
mdl_ur10 . . . . . . . . . . . . . . . . . . . . . . . . . 126
mdl_ur3 . . . . . . . . . . . . . . . . . . . . . . . . . . 127
mdl_ur5 . . . . . . . . . . . . . . . . . . . . . . . . . . 128
models. . . . . . . . . . . . . . . . . . . . . . . . . . . .128
Serial-link manipulator
DHFactor . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
PrismaticMDH . . . . . . . . . . . . . . . . . . . . 193
Prismatic. . . . . . . . . . . . . . . . . . . . . . . . . .190
RevoluteMDH . . . . . . . . . . . . . . . . . . . . . 221
Revolute . . . . . . . . . . . . . . . . . . . . . . . . . . 219
SerialLink.friction . . . . . . . . . . . . . . . . . 281
SerialLink.nofriction . . . . . . . . . . . . . . . 301
SerialLink.perturb . . . . . . . . . . . . . . . . . 303
SerialLink.plot . . . . . . . . . . . . . . . . . . . . 304
SerialLink.teach . . . . . . . . . . . . . . . . . . . 311
SerialLink. . . . . . . . . . . . . . . . . . . . . . . . .271
Kinematics
DHFactor . . . . . . . . . . . . . . . . . . . . . . . . . . 39
ETS2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
ETS3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
SerialLink.fkine . . . . . . . . . . . . . . . . . . . 281
SerialLink.ikine6s . . . . . . . . . . . . . . . . . 288
SerialLink.ikine . . . . . . . . . . . . . . . . . . . 285
SerialLink.jacob0 . . . . . . . . . . . . . . . . . . 296
SerialLink.jacobe . . . . . . . . . . . . . . . . . . 297
SerialLink.maniplty . . . . . . . . . . . . . . . . 299
jsingu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
trchain2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
trchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Models
mdl_KR5 . . . . . . . . . . . . . . . . . . . . . . . . . 108
mdl_LWR. . . . . . . . . . . . . . . . . . . . . . . . .109
mdl_S4ABB2p8 . . . . . . . . . . . . . . . . . . . 120
mdl_ball . . . . . . . . . . . . . . . . . . . . . . . . . . 101
mdl_baxter . . . . . . . . . . . . . . . . . . . . . . . . 101
mdl_cobra600 . . . . . . . . . . . . . . . . . . . . . 102
Dynamics
SerialLink.accel . . . . . . . . . . . . . . . . . . . 274
SerialLink.cinertia . . . . . . . . . . . . . . . . . 276
SerialLink.coriolis . . . . . . . . . . . . . . . . . 277
SerialLink.fdyn . . . . . . . . . . . . . . . . . . . . 279
SerialLink.gravload . . . . . . . . . . . . . . . . 284
SerialLink.inertia . . . . . . . . . . . . . . . . . . 293
Robotics Toolbox 10.2 for MATLAB
6
Copyright cPeter Corke 2017
SerialLink.itorque. . . . . . . . . . . . . . . . . .295
SerialLink.rne . . . . . . . . . . . . . . . . . . . . . 310
wtrans . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
Mobile robot
Bicycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
LandmarkMap . . . . . . . . . . . . . . . . . . . . . . 83
Navigation . . . . . . . . . . . . . . . . . . . . . . . . 132
RandomPath . . . . . . . . . . . . . . . . . . . . . . 211
RangeBearingSensor . . . . . . . . . . . . . . . 214
Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Unicycle . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Vehicle . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
plot_vehicle . . . . . . . . . . . . . . . . . . . . . . . 175
Localization
EKF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
ParticleFilter . . . . . . . . . . . . . . . . . . . . . . 142
PoseGraph . . . . . . . . . . . . . . . . . . . . . . . . 189
Path planning
Bug2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
DXform. . . . . . . . . . . . . . . . . . . . . . . . . . . .46
Dstar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Lattice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
PRM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
RRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Graphics
circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
mplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
plot2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
plot_arrow . . . . . . . . . . . . . . . . . . . . . . . . 167
plot_box . . . . . . . . . . . . . . . . . . . . . . . . . . 168
plot_circle . . . . . . . . . . . . . . . . . . . . . . . . 169
plot_ellipse. . . . . . . . . . . . . . . . . . . . . . . .170
plot_homline . . . . . . . . . . . . . . . . . . . . . . 171
plot_point . . . . . . . . . . . . . . . . . . . . . . . . . 172
plot_poly . . . . . . . . . . . . . . . . . . . . . . . . . 173
plot_sphere. . . . . . . . . . . . . . . . . . . . . . . .174
plotp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
plotvol . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
qplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
tranimate2 . . . . . . . . . . . . . . . . . . . . . . . . 346
tranimate. . . . . . . . . . . . . . . . . . . . . . . . . .345
trplot2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
trplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
xaxis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
xyzlabel . . . . . . . . . . . . . . . . . . . . . . . . . . 432
yaxis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
Utility
PGraph . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Plucker . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Polygon. . . . . . . . . . . . . . . . . . . . . . . . . . .184
RTBPlot . . . . . . . . . . . . . . . . . . . . . . . . . . 233
about . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
angdiff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
bresenham . . . . . . . . . . . . . . . . . . . . . . . . . 34
chi2inv_rtb . . . . . . . . . . . . . . . . . . . . . . . . . 36
colnorm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
diff2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
distancexform . . . . . . . . . . . . . . . . . . . . . . 41
edgelist . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
gauss2d . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
isunit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
isvec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
numcols . . . . . . . . . . . . . . . . . . . . . . . . . . 140
numrows . . . . . . . . . . . . . . . . . . . . . . . . . . 141
peak2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
peak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
pickregion . . . . . . . . . . . . . . . . . . . . . . . . 166
polydiff . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
randinit . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
runscript . . . . . . . . . . . . . . . . . . . . . . . . . . 243
stlRead . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
tb_optparse. . . . . . . . . . . . . . . . . . . . . . . .339
unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
Demonstrations
rtbdemo. . . . . . . . . . . . . . . . . . . . . . . . . . .232
Examples
plotbotopt . . . . . . . . . . . . . . . . . . . . . . . . . 176
Robotics Toolbox 10.2 for MATLAB
7
Copyright cPeter Corke 2017
Robotics Toolbox 10.2 for MATLAB
8
Copyright cPeter Corke 2017