This is repo shows an example of epsilon point control of the smooth differential drive model. The controller is implemented in python and simulations are done in three forms. The first is a basic integration simulation to show that the system is working as expected. The second is a matplotlib animation of the system. The third is a simulation in gazebo and ROS2.
The unicycle model is a common state space representation to express a differential drive robot.
The unicycle model state consists of its x and y positions
The dynamics of this system are then defined by
The difficulty with controlling this system is that it contains what is called "non-holonomic" constraints which are non integratable constraints.
The constraint with this system is that it cannot move orthogonal to it's current orientation.
To alleviate this we utilize something called epsilon point control.
This basic idea is that if a robot is traveling on a path there is a point
We can define the point that is
To get the full state we must also take the first and second derivatives of
using this we can create an feed back linearized system.
Now that we have a linearized system we can find the control gains for the system. This can be done with either pole placement or LQR. However, since I will eventually be controlling a turtlbot3 robot there and the maimum linear velocity is 0.26 m/s and the maximum angular velocity is 1.82 rad/s I will use LQR to find the control gains. This lends itself to using bryson's method to define our Q matrix. The gain matrix is found with the following.
The control input for the linearized system is then
This control can then be converted to the control for the unicycle model by the following equations.
The unicycle model is not the most realistic model of a differential drive robot. In reality we need to control the rotation for each of the robots wheels. The smooth differential drive model is similar to the unicycle model but just swaps the velocity terms for left and right wheel velocities. The smooth differential drive model is defined by the following equations.
The conversion can be done by solving for the setting
Skipping some algebra the control inputs for the smooth differential drive model are
Trajectory tracking is done by defining the desired state of the
Before using a simulation of the system a basic integration simulation was done to make sure that the system was working as expected. The results of this simulation are shown below.
This is shows that behavior of the system is as expected as time goes on the trajectory converges.
Next i created a basic animation using matplotlib where I utilize the state of the integrated system to move an arrow around on a blank plot. The results of this simulation are shown below.
A little more interesting than a plot but still not very exciting.
Next I took the controller code and implemented into the ROS2 framework and simulated it in gazebo. I used a basic turtle bot and recalulated the forward and angular velocity of the turtle bot using the smooth differential drive model and published this on the cmd_vel topic. The results of this simulation are shown below.
This was a fun project and I learned a lot about differential drive robots and how to control them. I also learned a lot about ROS2 and gazebo. I think that this is a good way to control a differential drive robot and I think that it would be interesting to see how this would work on a real robot.
The ros simulation requires ROS2 humble and gazebo 11. To install ROS2 follow the instructions here. To install gazebo 11 follow the instructions here. Once these are installed you can clone this repo into your ros workspace and run the following commands.
To download the package create a ros workspace and clone this repo into the src folder.
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone https://github.com/timdodge54/epsilon_point_control.git
Install python dependencies
pip3 install -r requirements.txt
Then build the package
cd ../..
colcon build --symlink-install
Then source the package
source install/setup.bash
Then run the ros2 simulation
export TURTLEBOT3_MODEL=burger
ros2 launch epsilon_control launch_controller_turtle_sim.launch.py