|
controls
3.0.0
|
Converts a 6DOF body force vector to per-thruster PWM commands. More...
#include <ThrustAllocator.h>
Public Member Functions | |
| ThrustAllocator (std::unique_ptr< ThrusterLookupInterface > thruster_lookup, std::unique_ptr< ThrustAllocationSolverInterface > solver, const std::string &yaml_config_filename) | |
| Constructs the allocator, loads YAML config, and initialises the QP solver. More... | |
| std::tuple< bb_controls_msgs::msg::Thrusters, bb_controls_msgs::msg::ThrusterForces, Vector6d > | allocate (const Vector6d &force, float battery_voltage) |
| Allocates a body force to per-thruster commands at the given battery voltage. More... | |
| void | update_cg_offset (const Vector3d &updated_cg_offset) |
| Updates the centre-of-gravity offset applied to all thruster positions. More... | |
Converts a 6DOF body force vector to per-thruster PWM commands.
Loads thruster geometry from a YAML configuration file, delegates force allocation to a pluggable QP solver, and converts resulting thruster force magnitudes to integer commands via a ThrusterLookupInterface. The centre- of-gravity offset can be updated at runtime and will trigger an automatic re-initialisation on the next allocate() call.
| ThrustAllocator::ThrustAllocator | ( | std::unique_ptr< ThrusterLookupInterface > | thruster_lookup, |
| std::unique_ptr< ThrustAllocationSolverInterface > | solver, | ||
| const std::string & | yaml_config_filename | ||
| ) |
Constructs the allocator, loads YAML config, and initialises the QP solver.
| thruster_lookup | [in] Voltage-dependent thrust lookup table implementation |
| solver | [in] QP thrust allocation solver implementation |
| yaml_config_filename | [in] Path to the YAML file describing the thruster layout |
| std::runtime_error | if the YAML file cannot be parsed |
| std::tuple< bb_controls_msgs::msg::Thrusters, bb_controls_msgs::msg::ThrusterForces, Vector6d > ThrustAllocator::allocate | ( | const Vector6d & | force, |
| float | battery_voltage | ||
| ) |
Allocates a body force to per-thruster commands at the given battery voltage.
Re-initialises the solver if the CG offset has changed since the last call.
| force | [in] Desired 6DOF body force/torque vector in N and Nm |
| battery_voltage | [in] Battery voltage in volts (used to look up force limits) |
| void ThrustAllocator::update_cg_offset | ( | const Vector3d & | updated_cg_offset | ) |
Updates the centre-of-gravity offset applied to all thruster positions.
The solver is lazily re-initialised on the next allocate() call.
| updated_cg_offset | [in] New CG offset in the body frame (m) |