This header file contains a class called turtlebot3_MPC that implements a simple Model Predictive Controller (MPC) for the TurtleBot3 robot. The MPC is used to control the robot's velocity and orientation to follow a given trajectory. The class controller also includes a Proportional-Integral-Derivative (PID) component for compare the robot's motion.
eigen3
: a C++ template library for linear algebra.rclcpp
: the ROS 2 C++ client library.std_msgs
: a ROS 2 package for standard message definitions.geometry_msgs
: a ROS 2 package for geometry-related message definitions.nav_msgs
: a ROS 2 package for navigation-related message definitions.sensor_msgs
: a ROS 2 package for sensor-related message definitions.
- Clone the repository to your ROS2 workspace:
cd ~/your_ros2_ws/src` git clone https://github.com/JuanCarlos-TiqueRangel/turtlebot3_cpp.git
- Build the package:
cd ~/your_ros2_ws colcon build --packages-select turtlebot3_cpp
The turtlebot3_MPC class has the following member functions:
- A simple model predictive control (MPC) function that controls the robot's movement.
- Takes three arguments:
- w - Desired angular velocity of the robot.
- yaw - Current orientation of the robot in radians.
- ref - Desired orientation of the robot in radians.
- Returns the control action uk_mpc. This control tecnique comes from the MPC strategy from Predictive Control With Constraints: MacIejowski book. Also there is a related paper of a real implementation in a skid-steering robot here.
- A simple proportional-integral-derivative (PID) function that controls the robot's movement.
- Takes one argument:
- error - Error in the orientation of the robot.
- Returns the control action uk_pid.
constraints and MIMO controller will be add.
- This file assumes that the robot is using ROS2 as the middleware.
- This file has been tested with the TurtleBot3 robot platform.
This code is released under the MIT License. Feel free to modify and use it in your own projects.