File Exchange

## Rigid motions and robotics toolbox

version 1.1 (493 KB) by Antonio Tristán Vega

### Antonio Tristán Vega (view profile)

3D rigid transforms and robotics with quaternions and dual quaternions (OO interface)

Updated 28 Mar 2017

This toolbox provides a set of functions for modelling 3-D rigid motions including
Euler angles, rotation and homogeneous matrixes, quaternions and dual quaternions, and
axis/angle representations. Before using the toolbox, you should run the script:
>> setup__robotics_toolbox
that will temporarily fix your path to include all the required folders (you can otherwise
include the line above in your 'startup.m' Matlab's config file).
The toolbox currently features these blocks:
- quaternions, dual numbers, and dual quaternions algebra. Corresponding classes have
been programmed for each one using Matlab's object oriented interface, allowing
to use them in the same way real or complex numbers (or matrixes) are used. For
example, a 3xN matrix xyz comprising N 3-D column vectors can be translated to its
quaternion representation just by typing:
>> myquaternions = [ii,jj,kk]*xyz; % 1xN array of quaternions
Or you can compute the rotation angle they represent as:
>> angle(myquaternions),
Or you can compute their squares or compare them:
>> myquaternions.*myquaternions == myquaternions.^2
Get started:
demo_quaternion
demo_dualnumber
demo_dualquaternion
- Conversions between the different representations of 3-D rotations (quaternions,
Euler angles with different conventions, axis/angle, rotation matrixes) and 3-D
rigid motions (homogeneous matrixes, dual quaternions), back and forth. All the
related functions are meant to work over N-dimensional arrays, so that you can
convert, for example, 8x7x6 quaternions to their corresponding rotation matrixes
(returned in a 3x3x8x7x6 array) with just one call to quat2rot.
Get started:
demo_conversions3x3
demo_conversions4x4
- Robot kinematics. This toolbox is meant to analyze any kind of generic serial robot
described by just its Denavit-Hartenberg parameters (i.e. a Gx4 table, with G the
number of d.o.f. of the robot). The capabilities of the toolbox include:
+ analysis of forward kinematics, i.e., determining the position of the end
effector (as either a homogeneous matrix or a dual quaternion) as a function
of joint variables.
+ analysis of velocity kinematics, i.e., determining the Jacobian matrix that
linearly relates joint velocities with end effector velocities.
+ analysis of inverse kinematics, i.e., determining the joint values needed to
recover a desired position and orientation of the end effector (given as
either a known dual quaternion or a known homogeneous matrix). Since the
toolbox is intended for a generic robot, the approach has to be numeric (we
use a Newton-Raphson solver based on the Jacobian matrix).
Get started:
demo_kinematics
demo_inversekinematics
- Robot dynamics. This works also for any generic serial robot, as long as the D-H
table and, of course, mass geometry parameters (masses, mass centers, inertia
moments) are known. The capabilities of the toolbox include:
+ Newton-Euler recursive dynamics, i.e. finding forces and torques at each
joint from known kinematics.
+ Lagrange-Euler dynamics, i.e. matrix relations between generalized forces
and d.o.f. positions, velocities, and accelerations.
+ A simple ad-hoc solver for forward dynamics, i.e., computing positions,
velocities and accelerations from known forces and torques of the actuators.
Get started:
demo_dynamics
The aim when designing this code was mainly to provide an intuitive and flexible
interface to work with different representations of rigid motions. This means the
software is not particularly optimized for performance/execution speed. However, an
effort has been made to take advantage of Matlab's efficiency in matrix computations.
AUTHOR: Antonio Tristan-Vega (atriveg@eii.uva.es)
Dept. Mechanical Engineering,
Feel free to contact the author to report bugs or in case you miss some obvious functionality.

### Cite As

Antonio Tristán Vega (2020). Rigid motions and robotics toolbox (https://www.mathworks.com/matlabcentral/fileexchange/56758-rigid-motions-and-robotics-toolbox), MATLAB Central File Exchange. Retrieved .

Gonzalo Vegas Sánchez-Ferrero

TienAnh Nguyen

### TienAnh Nguyen (view profile)

 28 Mar 2017 1.1 This update improves the rtarrayMatrixCheckUnitary.m function that finds the rotation matrix closest to a given matrix. Singularities when the rotation matrix approaches a 180º degrees turn are now avoided. 13 Mar 2017 1.1.0.0 Minor changes to the description. 5 Mar 2017 1.1.0.0 This update corresponds to a bug fix: the previous version returned wrong axis-angle representations for certain 3-D rotations. "quat2aa.m" has been changed to fix this behavior. 22 Jun 2016 1.1.0.0 Added serial robot dynamics module, including Newton-Euler and Lagrange-Euler dynamics. 27 Apr 2016 1.0.0.0 Minor changes to the description 26 Apr 2016 1.0.0.0 zip fil re-uploaded 26 Apr 2016 1.0.0.0 Minor changes to the description 26 Apr 2016 1.0.0.0 Minor changes to the description
##### MATLAB Release Compatibility
Created with R2013b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Acknowledgements

Inspired: Robotics DQ Toolbox