Controller Architecture¶
The rocket controller architecture implements a cascaded controller with a high-level and a low-level controller.
The general idea of the cascaded structure is that the high level controller takes as input a trajectory and the current state and produces an attitude setpoint \(q\) and a desired thrust along the body \(x\)-axis \(T_x\), whereas the low level controller controls the attitude and attitude rate respectively at a higher rate compared to the high level controller by producing a desired torque around the centre of mass.
Furthermore, the rocket controller posesses an allocation object which is responsible for converting the desired thrust and torque vectors into a thrust vector which is realizable by the rocket.

Configuration¶
Configuration follows the same structure as for the car controllers. However, we also need to specify which high level controller and which allocation we wish to use:
# Description of configuration files can be found on the "ROS configuration" page of this documentation
state_type: rocket
input_type: rocket
controller_type: ROCKET_ALTITUDE
allocation_type: BASE
max_rate: 1000.0 # loop rate of the attitude controller
# visualization_rate: 10
controller_params:
low_level_controller:
# low level parameters (see below)
high_level_controller:
# high level parameters (see below)
allocator_params:
# allocation parameters (see below)
High Level Control¶
The implementation of the high level controller should follow the interface as defined by RocketHighLevelControllerBase. The list of current controllers is:
RocketHighLevelPidController
The base class provides the boolean flags is_armed_ and is_in_autonomous_mode_. They allow the developer to bypass the control loop or set/reset specific attributes of the controller if it is inactive (such as reset the integrators)
Rocket PID¶
This controller is a simple PID controller which controls the altitude and the position of the rocket. While the altitude can be easily controller by the PID, the lateral error is compensated by commanding a quaternion setpoint which tilts the rocket towards the desired position. This is similar to conventional position controllers which are used for quadcopters.
Example parameters are (NOTE: these gains have not been verified on hardware):
high_level_controller:
loop_rate: 50.0
altitude_p_gain_x: 0.05
altitude_p_gain_y: 0.1
altitude_p_gain_z: 0.1
altitude_i_gain_x: 0.0
altitude_i_gain_y: 0.0
altitude_i_gain_z: 0.0
altitude_d_gain_x: 0.4
altitude_d_gain_y: 0.2
altitude_d_gain_z: 0.2
max_angle: 20.0
Low Level Control¶
The low level controller consists of a P-controller which takes as arguments the current and the desired attitude and produces a desired attitude rate. The attitude rate controller is a PID-controller which takes as arguemnt the current and the desired rate and produces a torque around the body center of mass.
The attitude controller also posesses flags is_armed_ and is_in_autonomous_mode_. which can be used to set/reset the controller state.
Example parameters are (NOTE: these gains have not been verified on hardware):
low_level_controller:
loop_rate: 1000.0 # Make sure that this is the same as max_rate
attitude_p_gain_x: 5.0
attitude_p_gain_y: 5.0
attitude_p_gain_z: 5.0
rate_p_gain_x: 7.0
rate_p_gain_y: 7.0
rate_p_gain_z: 7.0
rate_i_gain_x: 0.0
rate_i_gain_y: 0.0
rate_i_gain_z: 0.0
rate_d_gain_x: 0.001
rate_d_gain_y: 0.001
rate_d_gain_z: 0.001
Allocation¶
The allocation converts the force and torque vector produced by the two controllers and converts them from acting on the center of mass to an equivalent force which can be produced by the gimbaled rotors. It then computes the servo angles necessary to achieve said force vector. It also takes care of limiting the servo angles and motor speeds if they violate the actuator constraints. Specifically, if the desired force and torque vector of the rotor group are outside of the realizable envelope, they are projected onto the envelope by prioritizing the force component and reducing the torque until the command is feasible.
The parameters are:
allocator_params:
constraint_coefficients: [
0.01566232, 0.0038805,
-0.01405059, 0.30435571,
0.01536903, -0.32219933,
-0.01182221, 0.00391584
]
pwm_thrust_mapping_identification.ipynb notebook from the rocket_actuator_testing tooling. That tool is not part of this repository.
Development¶
To develop a new high level controller for the rocket, you simply need to create a class which inherits from RocketHighLevelControllerBase and implements the specified virtual functions. Furthermore, depending on the implementation of your controller, you will need to specify the relevant type specializations of the RocketController class as seen in the rocket_controller_specializations.h file in the rocket_pid package.