This sub-library contains control classes for robots. At present, it contains the SerialLinkBase
class, and the SerialKinematicControl
class for real-time velocity control. A SerialDynamicControl
class is in development.
✨ Key Features:
- Joint feedback, and Cartesian feedback control.
- Seemless integration with the Trajectory sub-library.
- Optimisation using Quadratic Programming (QP) to satisfy joint limits.
- Automatic redundancy resolution for singularity avoidance, and energy minimisation.
This class provides a standardised structure to all serial link control classes, and polymorphism to implement different controllers for the same task.
Note
SerialLinkBase
inherits the QPSolver
which can be used to optimise the Cartesian control. It is automatically downloaded by RobotLibrary
from this repository.
- A pointer to a
RobotLibrary::Model::KinematicTree
object, - The name of a valid reference frame (i.e. the endpoint of the robot) in said model for Cartesian control purposes, and
- Optional
RobotLibrary::Control::Parameters
(feedback gains, etc.).
This is done deliberately so that:
- Two serial link controllers can control different endpoints on the same robot (e.g. a controller for each arm on a humanoid robot), and
- The model can update the kinematics & dynamics independently in a separate thread.
Note
Many of these are virtual methods and must be defined in any derived class.
update
: Computes a new Jacobian matrix to the specified endpoint.resolve_endpoint_motion
: Computes the joint control required to achieve a given motion (velocity or acceleration) of the endpoint.resolve_endpoint_twist
: The same as above, but assumes the input is a twist (linear & angular velocity),track_endpoint_trajectory
: Computes the joint control needed to follow a Cartesian trajectory.track_joint_trajectory
: Computes the joint control needed to follow a joint trajectory.
Note
You should always call update_state()
on the RobotLibrary::Model::KinematicTree
object first, before calling update()
on the controller.
This builds upon the SerialLinkBase
class to implement algorithms for real-time velocity control.
Tip
You can check out my ROS2 action server to see this class in action.
The same as SerialLinkBase
.
The same as SerialLinkBase
.
track_joint_trajectory
:
This method computes:
where:
-
are the joint velocities to command the robot, -
is the desired joint position and joint velocity, -
is the current joint position, and -
is the joint position gain.
track_cartesian_trajectory
:
This method computes
where:
-
is the command twist (Cartesian velocity) for the endpoint of the robot, -
is the desired pose & twist, -
is the current pose of the endpoint, and -
is the Cartesian stiffness matrix.
then immediately calls the method below.
resolve_endpoint_motion
:
For a non-redundant robot, this solves:
where:
-
is the Jacobian matrix, -
and are lower and upper bounds on the joint speed based on joint limits (both position and speed), -
is the measure of manipulability (proximity to a singularity), and -
is the minimum manipulability threshold.
If the robot is redundant it solves,
where:
-
is a redundant task, and -
is the joint inertia matrix.
Note
Weighting the joint velocities by the inertia matrix instantaneously minimises the kinetic energy needed to move the robot.
Tip
You can set the redundant task with the set_redundant_task()
method. If none is provided, it automatically uses the gradient projection method to move away from singularities (where possible).
Note
If the singularity avoidance fails and the manipulability