astomodynamics/casadi_mpc
This package implements a Model Predictive Control (MPC) node using CasADi in a ROS2 environment.
CasadiMPCNode ROS2 Package
This package implements a Model Predictive Control (MPC) node using CasADi for optimization in a ROS2 environment.
Prerequisites
- ROS2 (tested with Humble)
- Python 3.10+
- CasADi
- NumPy
Installation
-
Create a ROS2 workspace if you haven't already:
mkdir -p ~/ros2_ws/src cd ~/ros2_ws/src -
Clone this package into your workspace:
git clone https://github.com/astomodynamics/casadi_mpc.git -
Install the required Python packages:
cd casadi_mpc pip install -r requirements.txt -
Build the ROS2 package:
cd ~/ros2_ws colcon build --packages-select casadi_mpc -
Source the setup file:
source ~/ros2_ws/install/setup.bash
Usage
-
Run the CasadiMPCNode:
ros2 run casadi_mpc casadi_mpc -
The node subscribes to the
/robot_id/posetopic for state updates, the/robot_id/goal_posetopic for goal updates, and publishes control inputs to the/robot_id/cmd_veltopic.
Customization
- Adjust MPC parameters in the
CasadiMPCNode.__init__method. - Modify the system model in
setup_mpcmethod to match your specific use case.
Contributing
Contributions to improve the package are welcome. Please feel free to submit pull requests or open issues for bugs and feature requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
