Skip to content

brian00715/Autonomous-Robot-Navigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NUS ME5413 Final Project - Group 8

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

You can read our report for more details.

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

Recommend to use the following script if you haven't installed ROS yet:

wget http://fishros.com/install -O fishros && . fishros

Super simple installation! Just run:

cd ~; git clone https://github.com/brian00715/Autonomous-Robot-Navigation me5413_final_ws
cd ~/me5413_final_ws; bash ./install.sh
  • Some useful commands installed

    • gazebok: kill gazebo immediately.
    • rosk: kill all ros-related programs immediately.

Repository setup

cp -r ~/me5413_final_ws/src/me5413_world/models/* ~/.gazebo/models
cd ~/me5413_final_ws
catkin init
catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=RelWithDebInfo

1. Build SLAM packages

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

Cartographer (Recommended)

  • Install Abseil-cpp Library

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

    cd ~/me5413_final_ws
    catkin build cartographer*

Fast-LIO (optional)

  • Build

    cd ~/me5413_final_ws
    catkin build fast_lio

2. Build extra packages

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

catkin build
echo "source ~/me5413_final_ws/devel/setup.bash" >> ~/.bashrc
bash

3. Prepare perception packages (optional)

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

Running

One-click launch (recommend)

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

You can simply kill all the programs immediately by running:

tmux kill-server

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 (only if you want to build new maps)

  • 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

roslaunch final_pnc pnc.launch

FSM (optional)

roslaunch final_fsm fsm.launch

Configuration

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.

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: