A Model Predictive Controller (MPC) for spacecraft position and attitude tracking with the Basilisk astrodynamics framework via the Basilisk-ROS 2 Bridge, built on the acados optimization framework.
The controller receives spacecraft states from a running Basilisk simulation over the bridge and publishes optimal thrust commands back in real time. It supports both direct thruster allocation and wrench-level (force/torque) control, and can optionally be operated interactively through RViz.
Leader-follower formation flying with three spacecraft controlled via identical ROS 2-based MPC, running in Basilisk simulation (left) and on the ATMOS free-flyers at KTH (right). See the paper for details.
cd your_ros2_workspace/src
git clone https://github.com/DISCOWER/bsk-ros2-mpc.git
cd ..
colcon build --packages-up-to bsk-ros2-mpc
source install/setup.bashBefore launching any MPC controller, ensure the Basilisk simulation and the Basilisk-ROS 2 Bridge are both running (see bridge Quick Start).
ros2 launch bsk-ros2-mpc mpc.launch.py| Argument | Default | Description |
|---|---|---|
namespace |
bskSat |
ROS 2 namespace for the agent |
use_sim_time |
False |
Synchronize with /clock topic |
type |
wrench |
wrench (force/torque) or da (direct allocation) |
use_hill |
True |
Use Hill frame for MPC (when in orbit) |
use_rviz |
True |
Launch RViz for visualization and interactive control |
name_leader |
"" |
Leader namespace (used by follower_wrench) |
name_others |
"" |
Space-separated namespaces of other agents for collision avoidance |
skip_build |
False |
Skip acados solver codegen/build and reuse an existing compiled solver |
Notes:
name_othersenables multi-agent avoidance by passing other agents' positions into MPC constraints. Leave it empty for single-agent runs.skip_build:=Trueis useful for faster startup when the solver has already been generated for the same controller/model configuration.
Example:
Single-agent
ros2 launch bsk-ros2-mpc mpc.launch.py namespace:=bskSat0 type:=wrench use_hill:=True use_rviz:=True skip_build:=FalseMulti-agent avoidance example (track bskSat1 and bskSat2)
ros2 launch bsk-ros2-mpc mpc.launch.py namespace:=bskSat0 type:=wrench name_others:="bskSat1 bskSat2"Missing acados dependencies: If the launch fails during solver generation, ensure the Python package acados_template is installed and that $ACADOS_SOURCE_DIR is correctly exported in your .bashrc.
Shared library error: If you encounter ImportError: libacados.so: cannot open shared object file, ensure your $LD_LIBRARY_PATH includes $ACADOS_SOURCE_DIR/lib.
Missing message types: If you receive errors about unknown types, ensure bsk_msgs and bsk_mpc_msgs are built and your workspace is fully sourced.