ROS and ROS2 Navigation - ashBabu/Utilities GitHub Wiki

Notes about configuring Nav2 config file

  • An example config file can be seen here. Here, if we specify static_layer, then a SLAM package is used to populate the map. If we dont specify this, robot will avoid obstacles in its immediate visinity and travel. More on Static Layer

ROS2 Navigation

Full ROS2 tutorial

  • sudo apt install ros-humble-navigation2 ros-humble-nav2-bringup ros-humble-turtlebot3*
  • In bashrc, add export TURTLEBOT3_MODEL=waffle
  • ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py # terminal 1
  • ros2 run turtlebot3_teleop teleop_keyboard # terminal 2
  • ros2 launch turtlebot3_cartographer cartographer.launch.py use_sim_time:=True # to generate map (SLAM) using teleop
  • ros2 run nav2_map_server map_saver_cli -f maps/my_map # to save map (will save both my_map.pgm and my_map.yaml)

ROS2 humble does not load maps correctly as on 9th Aug 2023. To fix this

  • sudo apt install ros-humble-rmw-cyclonedds-cpp
  • In bashrc, add export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
  • sudo gedit /opt/ros/humble/share/turtlebot3_navigation2/param/waffle.yaml, replace robot_model_type: nav2_amcl::DifferentialMotionModel"
  • ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
  • ros2 launch turtlebot3_navigation2 navigation2.launch.py use_sim_time:=True map:=path/to/my_map.yaml # use_sim_time=true only for gazebo

ROS1 Navigation

A very good tutorial can be found at MooreRobots

prerequisites

sudo apt-get install ros-kinetic-openslam-gmapping

sudo apt-get install ros-kinetic-navigation ros-kinetic-turtlebot ros-kinetic-turtlebot-apps ros-kinetic-turtlebot-interactions ros-kinetic-turtlebot-simulator ros-kinetic-turtlebot-msgs ros-kinetic-kobuki-ftdi ros-kinetic-ar-track-alvar-msgs

git clone https://github.com/ros-perception/slam_gmapping.git # in your catkin_ws/src folder

cd .. catkin_make

Creating the Map

Run the following commands below. Use the teleop to move the robot around to create an accurate and thorough map.

In Terminal 1, launch the Gazebo world

roslaunch mybot_gazebo mybot_world.launch

In Terminal 2, start map building

roslaunch mybot_navigation gmapping_demo.launch

In Terminal 3, launch rviz and set the following parameters:

roslaunch mybot_description mybot_rviz_gmapping.launch

In Terminal 4, start teleop

roslaunch mybot_navigation mybot_teleop.launch

Saving the Map

In Terminal 5, save the map to some file path

rosrun map_server map_saver -f ~/mybot_ws/src/mybot_navigation/maps/test_map

Loading the Map

Close all previous terminals and run the following commands below. Once loaded, use rviz to set navigation waypoints (2D Nav Goal on top panel) and the robot should move autonomously.

In Terminal 1, launch the Gazebo world

roslaunch mybot_gazebo mybot_world.launch

In Terminal 2, start map building

roslaunch mybot_navigation amcl_demo.launch

In Terminal 3, launch rviz

roslaunch mybot_description mybot_rviz_amcl.launch

3D Map creation

  1. rtabmap_ros
  2. orb_slam2_ros

RTAB-MAP

  • sudo apt-get install ros-melodic-imu-filter-madgwick
  • roslaunch realsense2_camera rs_camera.launch align_depth:=true unite_imu_method:="linear_interpolation" enable_gyro:=true enable_accel:=true
  • rosrun imu_filter_madgwick imu_filter_node _use_mag:=false _publish_tf:=false _world_frame:="enu" /imu/data_raw:=/camera/imu /imu/data:=/rtabmap/imu
  • roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" depth_topic:=/camera/aligned_depth_to_color/image_raw rgb_topic:=/camera/color/image_raw camera_info_topic:=/camera/color/camera_info approx_sync:=false rviz:=true

Turtlebot3 navigation with Rtabmap

  • Install [turtlebot3(https://automaticaddison.com/how-to-launch-the-turtlebot3-simulation-with-ros/) or as below

  • cd ~/catkin_ws/src/

  • git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git

  • git clone https://github.com/ROBOTIS-GIT/turtlebot3.git

  • cd ~/catkin_ws && catkin_make

  • gedit ~/.bashrc

  • export TURTLEBOT3_MODEL=burger # or Waffle or WafflePi

  • source ~/.bashrc

  • cd ~/catkin_ws/src/

  • git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git

  • cd ~/catkin_ws && catkin_make

Install Rtabmap

  • sudo apt install ros-$ROS_DISTRO-rtabmap-ros
  • sudo apt-get install ros-noetic-octomap-rviz-plugins

From the bottom here

  • roslaunch turtlebot3_gazebo turtlebot3_world.launch
  • roslaunch rtabmap_ros demo_turtlebot3_navigation.launch

Use 2D Nav Goal in Rviz to send the robot to the target.