Forrest-Z / Autonomous-Robot-Navigation

A.K.A. NUS ME5413 Final Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NUS ME5413 Final Project - Group 8

Task Description: please refer to ./docs/ME5413_Final_Project.pdf.

Demo:

For the insturcitons of the original simulation environment that this project relies on, please refer to ME5413_Final_Project-Github.

If you have any questions, please feel free to contact us: smkk00715@gmail.com

Features

  • SLAM
    • Cartographer
    • Fast-LIO2
    • Map Fusion
  • Planning and Control (PnC)
    • A*
    • Theta*
    • DWA
    • TEB
    • Model Predictive Control (MPC)
  • Perception: EasyOCR
  • Decision and Exploration
    • Finite State Machine (FSM)
    • Frontier and occupancy grid map-based exploration
  • Pipeline: Highly modular, automated, and configurable

Structure

.
├── final_fsm # Finite State Machine package
├── final_percep # Perception package
├── final_pnc # Navigation package
├── final_slam # SLAM package
├── interactive_tools # Interactive tools for rviz
├── jackal # Jackal package
├── jackal_description # Modified Jackal model package
├── me5413_world # Gazebo simulation package
└── third_party # Third-party packages. We have modified or tailored some of them.

Installation

System dependencies

  • Ubuntu 20.04
  • ROS Noetic
  • C++11 and above
sudo apt install ros-noetic-rviz-imu-plugin ros-noetic-move-base ros-noetic-navfn tmux python3-catkin-tools python3-wstool python3-rosdep ninja-build stow ffmpeg

python -m pip install Pillow markupsafe==1.1.1 ipdb
  • Some useful commands

    In your .bashrc or .zshrc file, add the following lines:

    alias rosk='rosnode kill -a ; killall -9 roscore rosmaster gzserver gazebo rviz ; kill -9 $(pgrep -f rqt)' # kill all ROS processes immediately
    alias gazebok="pkill -P $(pgrep -f gazebo.launch) ; pkill -9 gzserver ; pkill -9 gzclient" # kill gazebo immediately
    alias rqtg="rosrun rqt_graph rqt_graph"
    alias rqttf="rosrun rqt_tf_tree rqt_tf_tree"
    alias rqtrecon="rosrun rqt_reconfigure rqt_reconfigure"

Repository setup

mkdir ~/me5413_final_ws/ && cd ~/me5413_final_ws/
git clone https://github.com/brian00715/Autonomous-Robot-Navigation src
catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=RelWithDebInfo

# package ros dependencies
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

Someone may encounter the issue that the RViz runs extremely slow when visualizing the point cloud. To accelerate the point cloud processing, you can edit the Velodyne description file:

roscd velodyne_description/urdf

Open the VLP-16.urdf.xacro and HDL-32E.urdf.xacro, change the gpu:=false to gpu:=true on line 4.

Perception

Please install conda first.

conda create -n me5413 python=3.8
conda activate me5413
conda install pytorch==2.1.1 torchvision==0.16.1 pytorch-cuda=12.1 -c pytorch -c nvidia
conda install -c conda-forge opencv rosdep rospkg easyocr decorator pexpect numpy defusedxml ipdb
export PYTHONPATH=$PYTHONPATH:/usr/lib/python3.8/dist-packages

SLAM

Note: You can choose to install the relied SLAM packages. No need to install all of them.

1. Cartographer (Recommended)

Please open a terminal in your workspace and execute the following commands to install Cartographer.

  • Install Abseil-cpp Library

    Cartographer requires the abseil-cpp library, which needs to be manually installed using the provided script. Run the install_abseil.sh script:

    ~/me5413_final_ws/src/third_party/cartographer/cartographer/scripts/install_abseil.sh
  • Build and Install:

    catkin build cartographer*

2. Fast-LIO

Fast-LIO relies on Livox-SDK and livox_ros_driver, please satisify prerequisites first before compile Fast-LIO.

For Ubuntu 18.04 or higher, with ROS >= Melodic, the default PCL and Eigen is enough for FAST-LIO to work normally.

  • Livox-SDK Livox SDK is the software development kit designed for all Livox products and required by Fast-LIO. To install and compile the SDK, please follow:

    cd ~/me5413_final_ws/src/third_party/Livox-SDK
    cd build && cmake ..
    make -j
    sudo make install
  • livox_ros_driver

    livox_ros_driver is a ROS package used to connect LiDAR products produced by Livox, and is necessary for Fast-LIO. This package can be compiled by running

    cd ~/me5413_final_ws
    catkin build livox_ros_driver
  • Build

    If all the prerequisites are satisfied, Fast-LIO can be easily complied by running

    cd ~/me5413_final_ws
    catkin build fast_lio

Build

Note: the SLAM packages should be built before this step.

catkin build final_slam final_pnc final_percep final_fsm jackal* interactive_tools me5413_world
echo "source ~/me5413_final_ws/devel/setup.bash" >> ~/.bashrc

Running

One-click launch

Note: please confirm the conda environment and Cartographer have already been installed and built scuccessfully before running the one-click launch.

rosrun final_fsm start.sh
rosrun final_fsm start.sh -e -r # enable EKF and enable screen recording

Step-by-step launch

Gazebo simulation

export ENABLE_EKF=false # set to false means using the ground truth odometry, otherwise the EKF odometry fusing IMU the wheel odometry
roslaunch me5413_world me5413_world.launch

Mapping

  • Cartographer

    roslaunch final_slam mapping_carto.launch # default Mapping configuration
    roslaunch final_slam mapping_carto_2d.launch # 2D Cartographer Mapping
    roslaunch final_slam mapping_carto_3d.launch # 3D Cartographer Mapping

    An example of mapping by 2D Cartographer is shown as follows:

    carto_map

  • Fast-LIO

    source ~/me5413_final_ws/devel/setup.bash
    roslaunch final_slam mapping_fast_lio.launch

    An example of point cloud by FastLIO is shown as follows:

    fast_lio_pcd

    • Point Cloud to Map

      After mapping with Fast-LIO, we offer a ROS package called pcd2pgm to convert the .pcd files generated by Fast-Lio (located in src/third_party/FAST_LIO/PCD) into standard .pgm map files. To compile this package, please execute:

      cd ~/me5413_final_ws
      catkin build pcd2pgm

      To generate the map, run the following command:

      source ~/me5413_final_ws/devel/setup.bash
      roslaunch pcd2pgm pcd2pgm.launch

      After seeing 'data size =' displayed in the terminal, open a new terminal in your map folder and execute:

      rosrun map_server map_saver

      Then you can obtain the .pgm map file. An example is shown as follows:

      fast_lio_map

  • Map Fusion

    To fully utilize the maps generated both by Cartographer and Fast-LIO, we provide a simple Python script that uses image processing methods to fuse these two high-quality maps into one. To perform this, execute:

    cd ~/me5413_final_ws/src/final_slam/scripts
    chmod +x map_fusion.py
    python3 map_fusion

    You will obtain the fused map named fusion_map.pgm in final_slam/maps. The result is shown as follows:

    fusion_map

Localization (With built map)

roslaunch final_slam localization_carto.launch # cartographer by default

Navigation

  • With Gazebo, cartographer, and navigation

    rosrun final_pnc debug.sh
  • Only navigation

    roslaunch final_pnc pnc.launch

FSM

roslaunch final_fsm fsm.launch

Configuration

Localization

To change to map used for localization, modify the map_file parameter in final_slam/launch/localization_carto.launch.

Planning and control

You can choose which global planner or local planner to use in final_pnc/launch/pnc.launch.

Note: For the current version, if you want to use the DWA or TEB local planner, you should set arg local_planner to a value other than mpc. Uncomment the corresponding local planner from lines 40-47 and comment out lines 49-50 in final_pnc/launch/pnc.launch.

You can modify the parameters in final_pnc/config/*/*.yaml to adjust the performance. For exmaple, you can adjust the max_vel in final_pnc/config/nav_params/mpc.yaml to change the maximum velocity of MPC local planner.

Acknowledgement

We would like to thank the following open-source projects:


About

A.K.A. NUS ME5413 Final Project

License:MIT License


Languages

Language:Python 41.7%Language:C++ 31.8%Language:CMake 13.1%Language:Lua 11.1%Language:Shell 2.0%Language:Batchfile 0.5%