Skip to content

Autonomous navigation(Gazebo)

Hint

The operating environment and software and hardware configurations are as follows:

  • PC:Ubuntu (≥20.04) + ROS2 (≥Foxy)

Configure the map

Autonomous navigation will be completed on the map created by SLAM (Gazebo) before, and before navigation, it needs to be modified to a map of your own environment, and the modification method is as follows:

  • Copy the map file(*.pgm) and map configuration file(*.yaml)created by your SLAM and place them in the originbot_navigation/maps directory.

image-20230705220131082

  • Change the name of the map called in the originbot_navigation/launch/nav_bringup_gazebo.launch.py file to make sure that it is the same as the name of the map configuration file copied in the previous step:

image-20230705220247550

  • After the modification is complete, the terminal returns to the root directory of the workspace and recompiles it.

At this point, the map is configured, and you can use your own map to navigate.

Start the Gazebo simulation environment

Open a new terminal on the PC and enter the following command in the terminal to start the Gazebo simulation environment:

$ ros2 launch originbot_gazebo originbot_navigation_gazebo.launch.py

Wait a few moments, and once the launch is successful, you will see the simulation environment containing the robot model:

image-20230705220357301

Start the navigation feature

Enter the following command in the terminal to start the Nav2 navigation package:

$ ros2 launch originbot_navigation nav_bringup_gazebo.launch.py

image-20230705220546505

After the startup is successful, you will see the continuous output information in the terminal, this is because the initial pose of the robot is not set, and it can be solved after setting the initial position in the future.

Hint

If you can't find the Navigation2 plugin here, please use "sudo apt install ros-${ROS_DISTRO}-nav2*" to install it.

Set the initial position

Configure the display item in the open Rviz, click the "2D Pose Estimate" button in the toolbar, select the initial pose of the robot in the map, and click Confirm, the warning in the previous terminal will also stop.

image-20230705220806874

Single-target point navigation

Click the target location and select the "2D Goal Pose" button, and then select the navigation target point on the map to start autonomous navigation.

image-20230705220916560

图片1