This package contains an MPC integrated with with PX4 Autopilot and ROS 2.
The MPC uses the acados framework
If you find this package useful in an academic context, please consider citing the paper
- Roque, Pedro, Sujet Phodapol, Elias Krantz, Jaeyoung Lim, Joris Verhagen, Frank Jiang, David Dorner, Roland Siegwart, Ivan Stenius, Gunnar Tibert, Huina Mao, Jana Tumova, Christer Fuglesang, Dimos V. Dimarogonas. "Towards Open-Source and Modular Space Systems with ATMOS." arXiv preprint arXiv:2501.16973 (2025). . [preprint]
@article{roque2025towards,
title={Towards Open-Source and Modular Space Systems with ATMOS},
author={Roque, Pedro and Phodapol, Sujet and Krantz, Elias and Lim, Jaeyoung and Verhagen, Joris and Jiang, Frank and Dorner, David and Siegwart, Roland and Stenius, Ivan and Tibert, Gunnar and others},
journal={arXiv preprint arXiv:2501.16973},
year={2025}
}
The MPC formulation uses acados. In order to install acados, follow the following instructions To build the code, clone the following repositories into a ros2 workspace Dependencies
- px4_msgs
- px4-offboard (Optional): Used for RViz visualization
colcon build --packages-up-to px4_mpc
In order to run the SITL(Software-In-The-Loop) simulation, the PX4 simulation environment and ROS2 needs to be setup. For instructions, follow the documentation
Run PX4 SITL
make px4_sitl gazebo
Run the micro-ros-agent
micro-ros-agent udp4 --port 8888
In order to launch the mpc quadrotor in a ros2 launchfile,
ros2 launch px4_mpc mpc_quadrotor_launch.py
First, make sure that you have followed the instructions in the ATMOS guide. To control the vehicle with this package, make sure to switch the vehicle to Offboard mode in QGroundControl (see QGroundControl in ATMOS guide.
The mpc_spacecraft_launch.py file includes optional arguments:
- mode: Control mode (wrench by default). Options: wrench, rate, direct_allocation.
- namespace: Spacecraft namespace ('' by default).
- setpoint_from_rviz: Use RViz for setpoints (True by default).
Example with no namespace:
ros2 launch px4_mpc mpc_spacecraft_launch.py mode:=wrench setpoint_from_rviz:=False
Example with namespace: For this example to work, make sure you have run the PX4 SITL with the same namespace. Here goes an example
PX4_UXRCE_DDS_NS=pop make px4_sitl gz_spacecraft_2d
On another terminal, run
micro-ros-agent udp4 --port 8888
Lastly, start PX4-MPC
ros2 launch px4_mpc mpc_spacecraft_launch.py mode:=wrench namespace:=pop setpoint_from_rviz:=False