This sub-library enables physical modeling of serial-link robot structures to compute kinematics & dynamics.
✨ Key Features:
- Full forward kinematics & inverse dynamics of branching, rigid-body structures.
- Able to compute Jacobians to any point on a structure, and evaluate its partial & time derivatives.
- Able to compute the inverse dynamics of floating-base structures.
This class represents position & orientation in 3D space (i.e. the Special Euclidean group $\mathbb{SE}(3)$). Whilst the Eigen::Isometry3d
class uses a 4x4 matrix RobotLibrary::Model::Pose
class combines an Eigen::Vector3d
object for translation, and an Eigen::Quateriond
for orientation. This is in line with transforms in ROS2.
- An
Eigen::Vector3d
object for the position/translation, and - An
Eigen::Quaterniond
object for the orientation/rotation.
operator* (const Pose &other)
: Multiply two poses together,operator* (const Eigen::Vector<double,3> &other)
: Rotate a vector,as_matrix
: Convert the object to anEigen::Matrix<double,4,4>
object.error
: Compute the position & orientation error between this pose, and another (useful for feedback control!)
This represents a single, solid (physical) object in 3D space. It can be used to compute the dynamic forces as it moves:
where:
-
$\mathbf{f}\in\mathbb{R}^3$ are the linear forces (N), -
$\mathbf{m}\in\mathbb{R}^3$ are the moments (Nm), -
$m\in\mathbb{R}^+$ is the mass (kg), -
$\mathbf{I}, \dot{\mathbf{I}}\in\mathbb{R}^{3\times 3}$ is the inertia matrix (kg*m^2), and its derivative -
$\mathbf{v},\dot{\mathbf{v}}\in\mathbb{R}^3$ is its linear velocity (m/s) & acceleration (m/s/s), and -
$\boldsymbol{\omega}, \dot{\boldsymbol{\omega}}$ is its angular velocity (rad/s) & acceleration (rad/s/s).
- A name (as a unique identifier),
- Its mass,
- Its inertia matrix (in its origin coordinate frame)
- The location of its center of mass relative to its origin coordinate frame.
-
update_state
: Updates$\mathbf{I},\dot{\mathbf{I}}$ . -
mass
gets the mass (duh!), -
inertia
gets the inertia$\mathbf{I}$ in the global reference frame, -
inertia_derivative
get$\dot{\mathbf{I}}$ in the global reference frame, -
combine_inertia
lets you merge two masses together.
Represents an actuated joint on a robot. It can be used for modeling, but also for control, since it provides details on position & velocity limits.
- Its name (a unique identifier),
- Its type (revolute or prismatic),
- Its (local) axis of rotation,
- Its origin relative to the previous link or body in a kinematic chain,
- Its position, speed, and effort (torque) limits,
- Its damping & friction properties.
Honestly, it's not that interesting or useful outside the Link
class. You can always read that if you like.
This class combines a RigidBody
with a Joint
to compute the kinematic & dynamic contributions of the link of a robot to its overall structure.
- A
RigidBody
, and - A
Joint
object.
update_state
updates the kinematics & dynamics of theRigidBody
given its new pose and velocity.parent_link
returns a point to the previous link in a kinematic chain so it can be traversed backwards,child_links
gives an array of links proceeding this one in a kinematic chain,merge
can combine the kinematic & dynamic properties of links connected by a fixed joint, to eliminate the latter from the model.
This is the core of the model sub-library. It represents a branching structure of serial, rigid bodies connected by actuated joints. It has 2 important features:
- Computing the forward kinematics (of a branch):
where
- Computing the inverse dynamics (of the whole structure):
where:
-
$\boldsymbol{\tau}\in\mathbb{R}^n$ is the joint torque (that you compute), -
$\mathbf{M}(\mathbf{q})\in\mathbb{R}^{n\times n}$ is the inertia matrix, -
$\mathbf{C}(\mathbf{q},\dot{\mathbf{q}})\in\mathbb{R}^{n\times n}$ is the Coriolis matrix, -
$\mathbf{g}(\mathbf{q})\in\mathbb{R}^n$ is the gravitational torque vector, and -
$\mathbf{d}(\dot{\mathbf{q}})\in\mathbb{R}^n$ is the torque vector from viscous friction.
A URDF file. That's it! 😎
-
update_state
computes the forward kinematics & inverse dynamics for a given joint state (positions & velocities). -
joint_inertia_matrix
gives$\mathbf{M}$ , -
joint_coriolis_matrix
gives$\mathbf{C}$ , -
joint_gravity_vector
gives$\mathbf{g}$ , -
joint_damping_vector
gives$\mathbf{d}$ , -
jacobian
gives$\mathbf{J} = \partial\mathbf{k}/\partial\mathbf{q}$ , -
partial_derivative
gives$\partial\mathbf{J}/\partial q_i$ for a given joint number$i$ , and -
time_derivative
gives$d\mathbf{J}/dt$ .
Note
There are also methods for computing the dynamic coupling with the base of the robot as well (useful for floating base systems).