Robot Definition and Direct Kinematic
It’s possible to define a robot in different ways. Every representation has its advantages in terms of simplicity, environment compatibility, modelling convenience.
A mathematical model is the simplest possible representation of the robot. It represents the robot’s kinematics and dynamics through equations to predict physical behavior. It calculates how joint movements and actuator forces translate into spatial positioning, giving a starting point for developing simulations, deciding how to control the robot’s movements and studying stability and dinamics.
It is possible to represent a robot using proprietary softwares such as SolidWorks, Fusion360, Matworks’s Simscape Multibody trought a model. We can refer to this representations with the names Digital Twins, Simulation Model, Virtual Model.
It is also possible to have a textual representation of the robot. ROS uses URDF (Unified Robot Description Format), an XML-like format. Another popular environment, WeBots, uses PROTO as language to define robots. It exists tools able to convert CAD Models to textual representation, presenving and integrating 3D meshes.
Formulas
\[ A_i^{i-1} =\left\lbrack \begin{array}{cccc} \cos \theta_i & -\sin \theta_i \cos \alpha_i & \sin \theta_i \sin \alpha_i & a_i \cos \theta_i \newline \sin \theta_i & \cos \theta_i \cos \alpha_i & -\cos \theta_i \sin \alpha_i & a_i \sin \theta_i \newline 0 & \sin \alpha_i & \cos \alpha_i & d_i \newline 0 & 0 & 0 & 1 \end{array}\right\rbrack \]
One Link Robot Definition using Peter Corke’s toolbox (RTB)
One Link Robot Math
DH-parametets
| Link | \(a_i\) | \(alpha_i\) | \(theta_i\) | \(d_i\) |
|---|---|---|---|---|
| Link 1 | 1 | 0 | \(\displaystyle \theta_1\) | 0 |
Transfer matrix
\[ A_1^0 =\left\lbrack \begin{array}{cccc} \cos \theta_1 & -\sin \theta_1 & 0 & \cos \theta_1 \newline \sin \theta_1 & \cos \theta_1 & 0 & \sin \theta_1 \newline 0 & 0 & 1 & 0\newline 0 & 0 & 0 & 1 \end{array}\right\rbrack \]
It’s easy to demonstrate
|
|
ans = 4x4
0.0000 -1.0000 0 0.0000
1.0000 0.0000 0 1.0000
0 0 1.0000 0
0 0 0 1.0000
It is possible to show the robot structure using the method teach
|
|
Python version
It exsist a Python version called roboticstoolbox. Below a code example that do the same but in Python.
It’s important to use a virtual environments and install specific versions of dependant libraries (numpy==1.26.4 matplotlib==3.5.0)
|
|
Six Link Robot using Peter Corke’s toolbox - Arm
Below a 6-DoF robot designed to mimic the human arm structure (shoulder, elbow, and wrist joints).
|
|
ans = 6
|
|
ans = 'RRRRRR'
|
|
ans = 4x4
1 0 0 0
0 1 0 0
0 0 1 2
0 0 0 1
|
|
|
|
Robot definition using Rigid Body Tree
MATLAB implements some native tools too. The class rigidBodyTree gives the possibility to build robot models by connecting rigidBody objects through rigidBodyJoints. It is a versatile tool for defining a robot’s architecture and it may be preferred because it’s better integrated with the MatWorks ecosystem.
|
|
--------------------
Robot: (3 bodies)
Idx Body Name Joint Name Joint Type Parent Name(Idx) Children Name(s)
--- --------- ---------- ---------- ---------------- ----------------
1 link1 joint1 revolute base_link(0) link2(2)
2 link2 joint2 revolute link1(1) link3(3)
3 link3 joint3 fixed link2(2)
--------------------
|
|
|
|
T = 4x4
0.7071 -0.7071 0 1.0000
0.7071 0.7071 0 0
0 0 1.0000 0
0 0 0 1.0000
Converting Peter Corke’s Toolbox Robot to RigidBodyTree
It is possible to convert an ETS3 object (Peter Corke’s Toolbox) to a MATLAB standard rigidBodyTree object. Despite the RTB is simpler to use, it’s generically considered better to use the standard implementation.
|
|
Using DH Parameters - MATLAB’s Toolbox
Using this aproach it-s possible to define a robot starting from the DH parameters.
The main code requires the definition of the rigidBodyTree object, then creating bodies and connecting to the base in the end.
Here an example.
| Link | \(a_i\) | \(alpha_i\) | \(theta_i\) | \(d_i\) |
|---|---|---|---|---|
| 1 | 0 | 0 | 0 | \(\displaystyle q_1\) |
| 2 | 0 | \(\displaystyle -\frac{\pi }{2}\) | \(\displaystyle q_2\) | 0 |
| 3 | 0 | 0 | \(\displaystyle q_3\) | 0 |
|
|
--------------------
Robot: (3 bodies)
Idx Body Name Joint Name Joint Type Parent Name(Idx) Children Name(s)
--- --------- ---------- ---------- ---------------- ----------------
1 link1 joint1 revolute base_link(0) link2(2)
2 link2 joint2 prismatic link1(1) link3(3)
3 link3 joint3 prismatic link2(2)
--------------------
|
|
Puma 560 Robot
The PUMA (Programmable Universal Machine for Assembly) is one of the most iconic and influential industrial robots in history. Originally designed for General Motors to assemble small automobile components, now it’s commonly used as a didactic example.
| DH Puma 560 | \(\displaystyle a\) | \(\displaystyle \alpha\) | \(\displaystyle d\) | \(\displaystyle \theta\) |
|---|---|---|---|---|
| 1 | 0 | \(\displaystyle \frac{\pi }{2}\) | 0 | q1 |
| 2 | 0.4318 | 0 | 0 | q2 |
| 3 | 0.0203 | \(\displaystyle -\frac{\pi }{2}\) | 0.15005 | q3 |
| 4 | 0 | \(\displaystyle \frac{\pi }{2}\) | 0.4318 | q4 |
| 5 | 0 | \(\displaystyle -\frac{\pi }{2}\) | 0 | q5 |
| 6 | 0 | 0 | 0 | q6 |
|
|
Loading Existing Models
Custom or OEM robot models can be loaded in to the MATLAB workspace.
It is possible to find some opensource models about the most popular ones following this link.
Matlab’s Robotics System Toolbox has a lot of models that can be loaded using the function loadrobot, including meshes, inertia, mechanical limitations and more.
Documentation about the function can be found here.
|
|
--------------------
Robot: (6 bodies)
Idx Body Name Joint Name Joint Type Parent Name(Idx) Children Name(s)
--- --------- ---------- ---------- ---------------- ----------------
1 link2 j1 revolute link1(0) link3(2)
2 link3 j2 revolute link2(1) link4(3)
3 link4 j3 revolute link3(2) link5(4)
4 link5 j4 revolute link4(3) link6(5)
5 link6 j5 revolute link5(4) link7(6)
6 link7 j6 revolute link6(5)
--------------------
|
|
It is possible to interact with the robot using:
|
|