Controllers Overview#
Kangaroo uses ros2_control as its hardware abstraction and controller management framework. This page explains the architecture and how it is applied to Kangaroo, before diving into the individual controllers documented in this section.
ros2_control Architecture#
ros2_control separates robot software into three layers that communicate through a shared in-memory data bus called the hardware resource interface:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Controller Manager โ
โ loads, starts, stops, and switches controllers โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ command / state interfaces
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Resource Manager โ
โ owns the hardware interface data bus โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ read() / write()
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Hardware Interface Plugin โ
โ talks to the actual hardware or simulator โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Key Components#
Controller Manager#
The controller_manager node is the central orchestrator. It loads controller plugins at runtime, manages their lifecycle (configure โ activate โ deactivate โ cleanup), and enforces that only one controller claims each hardware interface at any given time.
Hardware Interface#
The hardware interface plugin implements the read() / write() cycle that bridges the ros2_control data bus to the real actuators (or simulator). Kangarooโs hardware interface handles the EtherCAT communication to the actuator drives and exposes interfaces for two distinct component types: joints (joint-space values, after the transmission) and actuators (motor-side values, before the transmission).
Joint interfaces: joint-space quantities, transmission applied:
Interface type |
Direction |
Description |
|---|---|---|
|
state |
Current joint angle (rad) |
|
state |
joint angle projected from the absolute encoder (rad) |
|
state |
Current joint velocity (rad/s) |
|
state |
Current joint torque (Nm) |
|
command |
Desired joint angle |
|
command |
Desired joint velocity |
|
command |
Desired joint torque |
Actuator interfaces: motor-side quantities, transmission bypassed:
Interface type |
Direction |
Description |
|---|---|---|
|
state |
Current actuator position (m) |
|
state |
Actuator position from the absolute encoder (m) |
|
state |
Current actuator velocity (m/s) |
|
state |
Current actuator force (N) |
|
state |
Actual motor phase current (A) |
|
state |
Force from the internal load cell (N) |
|
command |
Desired actuator position (m) |
|
command |
Desired actuator velocity (m/s) |
|
command |
Desired actuator force (N) |
|
command |
Desired motor current (A) |
Controllers and Broadcasters#
Controllers are plugins that read information from the state interfaces and then write the commands to the command interfaces. They run in the same real-time control loop as the hardware interface. Multiple controllers can be active simultaneously as long as they claim disjoint sets of command interfaces. For example, joint_trajectory_controller, actuator_pid_controllers, forward_command_controller, pid_controllers etc.
Broadcasters are the set of controller plugins that only claim a set of state interfaces and use the information to manipulate and publish the information. For example, joint_state_broadcaster, imu_sensor_broadcaster, force_torque_sensor_broadcaster.
How ros2_control is Used in Kangaroo#
At startup the following sequence takes place:
The hardware interface plugins connects to the actuator drives over EtherCAT and initialises all the sensors and actuators.
The
pid_command_controllerruns once to upload the per-actuator PID gains for every control mode (position, velocity, current): see Actuator PID Controller.The Controller Manager loads the set of controllers/broadcasters dynamically launched via different pal modules.
The operator (or launch file) activates the appropriate controller for the current task.
Controllers can be switched at runtime without restarting the robot using the Controller Manager service API or the ros2 control CLI:
# List all loaded controllers and their state
ros2 control list_controllers
# Switch active controllers
ros2 control switch_controllers \
--activate <controller_to_start> \
--deactivate <controller_to_stop>
Different Interfaces on the Robot#
Kangaroo exposes hardware interfaces through the ros2_control resource manager. Each interface is addressed as <component>/<interface_name>. There are two categories: command interfaces (written by controllers to drive actuators) and state interfaces (read-only feedback from sensors and actuators).
Use ros2 control list_hardware_interfaces on the robot to see the live status of every interface.
The lower-body hardware is organized into the following components:
Component pattern |
Count |
Description |
|---|---|---|
|
6 per side |
Leg linear actuators (N = 1โ5, length), covering hip yaw, hip roll, hip pitch, ankle pitch, ankle roll, and leg length |
|
6 per side |
Joint-space view of the same leg linear actuators (after transmission) |
|
1 per side |
Derived femur joint position from the parallel linkage mechanism (state only) |
|
1 per side |
Derived knee joint position from the parallel linkage mechanism (state only) |
|
2 |
Pelvis roll and pitch actuators |
|
2 |
Joint-space view of the pelvis actuators |
|
1 |
IMU mounted on the torso |
|
1 |
Global safety flag |
The _actuator interfaces expose raw motor-side quantities (current, internal force sensor, PID gains applied on the drive), while the _joint interfaces expose the corresponding joint-space values after the gearbox and transmission.
Command Interfaces#
Command interfaces are claimed exclusively by an active controller. An interface marked [claimed] is in use; [unclaimed] is available.
Per leg linear actuators (leg_{left|right}_{1-5|length}_actuator):
Interface |
Description |
|---|---|
|
Target actuator position (m) |
|
Target actuator velocity (m/s) |
|
Target actuator effort (N) |
|
Target motor current (A) |
|
Target force from the internal force sensor loop (N) |
|
Control mode selector (position / velocity / current / force) |
|
Additive offset applied on top of the position command |
|
Additive offset applied on top of the force command |
|
P gain for the on-drive position PID |
|
I gain for the on-drive position PID |
|
D gain for the on-drive position PID |
|
Feedforward term for the on-drive position PID |
|
P gain for the on-drive velocity PID |
|
I gain for the on-drive velocity PID |
|
D gain for the on-drive velocity PID |
|
Feedforward term for the on-drive velocity PID |
|
P gain for the on-drive current PID |
|
I gain for the on-drive current PID |
|
D gain for the on-drive current PID |
|
Feedforward term for the on-drive current PID |
|
P gain for the on-drive force PID |
|
I gain for the on-drive force PID |
|
D gain for the on-drive force PID |
|
Feedforward term for the on-drive force PID |
|
Raw encoder input channel (present but not used) |
|
Stiffness gain for impedance control |
|
Damping gain for impedance control |
Per leg joint (leg_{left|right}_{1-5|length}_joint):
Interface |
Description |
|---|---|
|
Target joint position (rad or m) |
|
Target joint velocity (rad/s or m/s) |
|
Target joint effort (Nm or N) |
|
Target joint torque/force (Nm or N) |
Pelvis actuators (pelvis_{1|2}_actuator) expose the same interface set as leg actuators. The corresponding pelvis_{1|2}_joint expose position, velocity, and effort.
Safety interface:
Interface |
Description |
|---|---|
|
Boolean flag ( |
State Interfaces#
State interfaces are read-only and can be claimed by any number of controllers/broadcasters simultaneously.
Per leg rotary actuator and leg-length actuator (leg_{left|right}_{1-5|length}_actuator):
Interface |
Description |
|---|---|
|
Current actuator position (rad or m) |
|
Crank/joint position referenced to the absolute encoder (rad or m) |
|
Current actuator velocity (rad/s or m/s) |
|
Current actuator effort/torque (Nm or N) |
|
Actual motor phase current (A) |
|
Force measured by the internal load cell / force sensor (N) |
|
Current force offset applied by the drive (N) |
|
Active control mode reported by the drive |
|
Active position offset reported by the drive |
|
Drive electronics board temperature (ยฐC) |
|
Motor winding temperature (ยฐC) |
|
Active position PID gains echoed back from the drive |
|
Active velocity PID gains echoed back from the drive |
|
Active current PID gains echoed back from the drive |
|
Active force PID gains echoed back from the drive |
|
Raw encoder input channel (present but not used) |
|
Stiffness gain for impedance control echoed back from the drive |
|
Damping gain for impedance control echoed back from the drive |
Per leg joint (leg_{left|right}_{1-5|length}_joint):
Interface |
Description |
|---|---|
|
Current joint position (rad or m) |
|
Joint position from the absolute encoder perspective (rad or m) |
|
Current joint velocity (rad/s or m/s) |
|
Current joint effort (Nm or N) |
Derived parallel-linkage joints (state only: no command interfaces):
Interface |
Description |
|---|---|
|
Femur joint angle computed from the parallel four-bar linkage (rad) |
|
Femur joint velocity (rad/s) |
|
Femur joint effort (Nm) |
|
Knee joint angle computed from the parallel four-bar linkage (rad) |
|
Knee joint velocity (rad/s) |
|
Knee joint effort (Nm) |
Pelvis actuators and joints follow the same state interface layout as leg actuators and joints respectively.
IMU sensor (torso_imu_sensor):
Interface |
Description |
|---|---|
|
Torso orientation as a quaternion |
|
Angular velocity in the torso frame (rad/s) |
|
Linear acceleration in the torso frame (m/sยฒ) |
Safety interface:
Interface |
Description |
|---|---|
|
Boolean flag reporting the current safety status ( |
Transmissions#
Transmissions play a crucial role in robotics by converting motion and force between actuators and joints. In Kangaroo, custom transmissions are implemented to handle complex kinematic relationships, particularly for leg mechanisms. They map the motion from the high-speed, low-torque actuators to the desired joint movements, often involving mechanical linkages that provide mechanical advantage or convert linear motion to rotary motion, or vice-versa.
The transmissions map the following interfaces between the actuator space and the joint space:
Interface |
Direction |
Description |
|---|---|---|
|
Bidirectional |
Maps actuator position (m) to joint position (rad) and vice-versa |
|
Bidirectional |
Maps actuator velocity (m/s) to joint velocity (rad/s) and vice-versa |
|
Bidirectional |
Maps actuator force (N) to joint torque (Nm) and vice-versa |
|
Bidirectional |
Maps actuator force sensor readings (N) to joint torque (Nm) and vice-versa |
|
Actuator โ Joint |
Maps absolute encoder position from actuator to joint |
Some transmissions, such as HipXYTransmission and AnkleXYTransmission, are differential transmissions: they combine the motion of two actuators to produce two output joint motions, and vice-versa. Among these, the AnkleXYTransmission is the most complex, as it additionally incorporates the states of the femur and knee derived from the parallel linkage to solve the forward kinematics of the ankle mechanism.
Transmission Type |
Actuators Involved |
Corresponding Joints (Commandable) |
Read-only/Derived Components |
|---|---|---|---|
HipZTransmission |
Hip Actuator 1 |
Hip Yaw (Jont 1) |
- |
HipXYTransmission |
Hip Actuator 2, Hip Actuator 3 |
Hip Pitch (Joint 2), Hip Roll (Joint 3) |
- |
LegLengthTransmission |
Leg Length Actuator |
Leg Length |
- |
LegLengthStateTransmission |
Leg Length Actuator |
- |
Femur, Knee |
AnkleXYTransmission |
Ankle Actuator 4, Ankle Actuator 5, Leg Length Actuator(read-only) |
Ankle Pitch (Joint 4) , Ankle Roll (Joint 5) |
- |
Claiming Command Interfaces: Rules and Restrictions#
Command interfaces for a given joint or actuator are mutually exclusive: only one control type can be active at a time. For instance, if leg_left_1_actuator is already commanded via its position interface, attempting to additionally claim velocity or effort will fail. The same rule applies to joint interfaces.
A joint interface and its corresponding actuator interface cannot be claimed simultaneously, nor can one be claimed while the other is already active. This restriction applies only to the
position,velocity,effort, andforce/torqueinterfaces, not to gain interfaces.Joints and actuators that share a transmission must be claimed together. Claiming only one side of a transmission pair will cause the controller switch to fail.
The diagram below illustrates how the command path differs depending on which interface type is claimed:
Joint interface: Joint Command โโโบ Transmission โโโบ Actuator (hardware)
Actuator interface: Actuator Command โโโโโโโโโโโโโโโโโโโบ Actuator (hardware)
(transmission skipped)
When a joint interface is claimed, the command passes through the transmission layer, which maps joint-space values to actuator-space values. When an actuator interface is claimed directly, the transmission is bypassed entirely and the command is sent straight to the hardware.
The table below shows which actuator control mode is activated based on the combination of command interfaces claimed:
Claimed interface(s) |
Actuator control mode |
Notes |
|---|---|---|
|
Position |
|
|
Velocity |
|
|
Current |
Nm (joint) / N (actuator) converted to A |
|
Current |
Direct current command in A |
|
Force |
Force-loop on internal force sensor |
|
Force |
Nm converted to N via transmission |
|
Impedance (current) |
Stiffness/damping control, output in current |
|
Impedance (force) |
Impedance with feed-forward force term |
Available Controllers#
The table below summarises every controller available on Kangaroo and its primary use case.
Controller |
Use Case |
|---|---|
Execute pre-planned joint trajectories (MoveIt, playback) |
|
Replay named motions stored in the parameter server |
|
Hierarchical task-space control with joint-limit awareness |
|
Upload per-actuator PID gains at startup |
|
Direct joint torque / effort commanding |
|
Compensate for gravity to allow compliant backdrivable operation |
|
Reconstruct the external foot wrench from actuator forces via the full model, no FT sensor required |