xavierQiwei / autonomous_mobile_robots

This repository contains different aspects of autonomous mobile robots including motion, control, and estimation. PID, LQR controllers for differential drive robot are developed with ROS2. In addition, some filters are covered such as particle filter and ekf for localization.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autonomous Mobile Robots

This repository contains an implementation of the Autonomous Mobile Robots course for ROCV master's program at Innopolis University. The course is instructed by Geesara Prathap. So, this repository contains the course material besides my solutions for the assignments. In addition, I developed a PID, LQR controllers for the differential drive robot.

The course contents includes:

  • Motion control (Kinematics, control, and dubins path planning).
  • Estimation (Kalman filter, extended kalman filter, particle filter).
  • Localization (Monte carlo, and ekf localization).

Setup

  1. Install at least one simulator: Gazebo

  2. Install the appropriate ROS 2 version as instructed: here.

  3. Clone the repository:

    mkdir -p ~/ros2_ws/src
    cd ~/ros2_ws/src
    git clone https://github.com/Walid-khaled/autonomous_mobile_robots.git
    
  4. Install dependencies:

    cd ~/ros2_ws
    rosdep install --from-paths src --ignore-src -r -y
    
  5. Build and install:

    cd ~/ros2_ws
    colcon build
    

Run

Gazebo-classic

If you had Gazebo installed when compiling Hagen's packages, Gazebo support should be enabled.

  1. Setup environment variables (the order is important):

    . /usr/share/gazebo/setup.sh
    . ~/ros2_ws/install/setup.bash
    

    Tip: If the command ros2 pkg list | grep hagen_gazebo comes up empty after setting up the environment, Gazebo support wasn't correctly setup.

  2. Launch Hagen in a city (this will take some time to download models):

    ros2 launch hagen_gazebo hagen.launch.py world:=hagen_city.world
    
  3. Launch Hagen in an empty world:

    ros2 launch hagen_gazebo hagen.launch.py world:=hagen_empty.world
    

    To avoid these steps, in your terminal, naviagate to the repository directory and make the file "run.sh" executable, then run it to start the simulation directly.

    cd ~/ros2_ws/src/autonomous_mobile_robots
    chmod +x run.sh
    ./run.sh
    

Main results

Control Strategies:

In "hagen_control/hagen_control/hagen_control_strategy.py", specify one of the following controller at the main() and timer_callback() functions:

  • Control to reference pose
  • Control to reference pose via an intermediate point
  • Control to reference pose via an intermediate direction
  • Reference path control

After the simulation finish, a plot will be genereated to visualize the odometery data with respect to the actual one. For example this is the output for reference path control.

Figure_1

As shown, the odom data diverge by time when reaching the path points without any feedback from the odometery data.

PD Controller

A PD controller was developed to incorporate the odometery data as feedback. It is implemented in 2 stages; reaching yhe target position and correcting the orientation.

PD_control.mp4

Figure_1

PID Controller

Adding the integral term has affected the removed the steady state error and improved the response. With the parameter tuning, you can obtain better results. Check "hagen_control/hagen_control/diff_drive_PD_control.py".

PID_control.mp4

Linear-Quadratic Controller (LQR)

Two different approaches were developed to solve the LQR problem. Check the formulation and the explanation in the notebooks in "hagen_control/hagen_control/LQR/". However the approach of the notebook "hagen_control/hagen_control/LQR/lqr-02.ipynb" was adopted as it showed a better performance. This is because

  • K is recalculated at each timestamp unlike the previous approach.
  • The Discrete Algebraic Riccati Equation (DARE) is solved for each state (timestamp) using dynamic programming, instead of solving it once as in the previous approach.

So a ros node was developed for LQR implementation, and below are the results. Check "hagen_control/hagen_control/diff_drive_LQR.py".

LQR.mp4

Figure_1

Some notes:

  • There is an advantage of the LQR controller over the previous PID controller. In LQR, there is no need to control the position and the orientation in 2 separate controllers as we did in PID. In PID, we controlled position and after reaching the position, another controller was applied to correct the orientation which makes a shift in position again. But in LQR, only one controller corrects the position and orientation simultaneously until reaching the desired state (x,y, yaw).
  • However, I noted that changing the desired state requires to tweak the Q and R matrices again, which is extremely time consuming if it is done manually.

EKF Localization

Figure_1

Acknowledgement

https://github.com/GPrathap/autonomous_mobile_robots

About

This repository contains different aspects of autonomous mobile robots including motion, control, and estimation. PID, LQR controllers for differential drive robot are developed with ROS2. In addition, some filters are covered such as particle filter and ekf for localization.


Languages

Language:Jupyter Notebook 67.6%Language:Python 30.7%Language:GLSL 0.8%Language:MATLAB 0.5%Language:CMake 0.3%Language:Shell 0.1%