Turtlebot mobile robot gazebo simulation and automatic navigation (detailed level)

Purpose: Control Turtlebot3 Burger movement, slam and automatic navigation environment in the simulation environment
: ROS is noetic under the dual system. (For other versions of ROS, please change to your own ROS when downloading the software package)
Steps:
(1). Create a simulation environment:
1. Open gazebo:
two methods: one is roscoreto open it inside rosrun gazebo_ros gazeboand the other is directly in the terminal Open gazebo
2. Select Edit > Building Editor from the menu bar, or use the shortcut key Ctrl+B to open the environment editor 3.
insert image description hereSelect the left area Wall (wall), and the two-dimensional view area on the upper right side of the interface Click the left mouse button to start drawing the wall, move the mouse to drag the wall, the wall and its length will be displayed in orange height, click the left mouse button again to confirm the end point of the wall. You can choose to continue to move the mouse to the end point of the previous wall to start drawing the next wall, or you can click the right mouse button to end the drawing of this wall.
insert image description here4. Draw a closed simulation environment. After the drawing is completed, the walls can be edited and adjusted. Double-click the wall to be edited with the left mouse button to pop up the inspector. In the inspector, parameters such as the position, length, thickness and height of the wall can be adjusted. edit. Here, the length setting of the outer wall can not be changed. The height of the inner and outer walls is set to 1.5m, and the default thickness is 0.15m.
insert image description here5. Add material and texture features to the wall, select the Bricks (bricks) option in Add Texture (Add Texture) at the bottom of the left area, and then click the outer wall of the 3D view area with the left mouse button to add bricks to the outer wall Grain and texture. We add bricks to the exterior walls and wood to the interior walls
insert image description here6. Select File > Save As in the menu bar to save the currently edited simulation environment file, select a save path (you can create a file first) and name it my_building (customizable name) , after saving, you can see that a folder named my_building is generated, which contains two files, model.config and model.sdf.

insert image description here(2) Mobile robot gazebo simulation:
1. Install dependent packages:

sudo apt-get install ros-noetic-joy ros-noetic-teleop-twist-joy ros-noetic-teleop-twist-keyboard ros-noetic-laser-proc ros-noetic-rgbd-launch ros-noetic-depthimage-to-laserscan ros-noetic-rosserial-arduino ros-noetic-rosserial-python ros-noetic-rosserial-server ros-noetic-rosserial-client ros-noetic-rosserial-msgs ros-noetic-amcl ros-noetic-map-server ros-noetic-move-base ros-noetic-urdf ros-noetic-xacro ros-noetic-compressed-image-transport ros-noetic-rqt-image-view ros-noetic-gmapping ros-noetic-navigation ros-noetic-interactive-markers

(Note, I am using noetic, you have to change to your own ROS version)
2. Create a ROS workspace and download the Turtlebot mobile robot software package:

mkdir -p ~/turtlebot_ws/src/ 
cd ~/turtlebot_ws/src/
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd ~/turtlebot_ws 
catkin_make

If there is a problem with the download, pay attention to change to a mobile hotspot.
After no problem

export TURTLEBOT3_MODEL=burger  

(can be put into .bashrc file)

source ~/turtlebot_ws/devel/setup.bash
roslaunch turtlebot3_gazebo turtlebot3_world.launch

Then import the simulation environment created by yourself and save it (find it in the insert, usually at the bottom)
insert image description hereand save it as (save world as), save it in ~/tutlebot_ws/src/turtlebot3_simulations/turtlebot3_gazebo/worlds/The name of
insert image description heremine is myworld1.world** (the suffix must be .world)**
Open the ~/tutlebot_ws/src/turtlebot3_simulations/turtlebot3_gazebo/launch/turtlebot3_world.launch file, and change the command to load the simulation environment to:

<arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/myworld1.world"/>

Modify the initial position of loading the Turtlebot3 model in the simulation environment in this file:

 <arg name="x_pos" default="0.6"/>
  <arg name="y_pos" default="-0.5"/>
  <arg name="z_pos" default="0.0"/>

(Keep the robot inside the map)
insert image description here3. The keyboard controls the movement of the robot in the simulation environment:

export TURTLEBOT3_MODEL=burger      
source ~/turtlebot_ws/devel/setup.bash
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

4. Map construction and saving:
Keep the simulation environment and keyboard control window running, open a new terminal window to run the slam file:

export TURTLEBOT3_MODEL=burger
source ~/turtlebot_ws/devel/setup.bash
roslaunch turtlebot3_slam turtlebot3_slam.launch

The keyboard controls the robot to move in the environment, and after creating a satisfactory map, save the map with the command:

rosrun map_server map_saver -f ~tutlebot_ws/src/turtlebot3/turtlebot3_navigation

(3) Automatic navigation:
Keep the simulation environment running, close the files running in other windows, and run the automatic navigation file:

export TURTLEBOT3_MODEL=burger
source ~/turtlebot_ws/devel/setup.bash
roslaunch turtlebot3_navigation turtlebot3_navigation.launch

The left mouse button selects "2D Pose Estimate" on the rviz toolbar to relocate the robot's position in the simulation environment to be consistent with that on the map, then select the "2D Nav Goal" option in the rviz toolbar, and long press the left mouse button to specify a position for the robot on the map. Navigation target point. After releasing the mouse, an optimal path is planned in a short time, and the robot starts to move towards the target point.

insert image description here
insert image description hereIt ends here. create workspace

Guess you like

Origin blog.csdn.net/m0_56895840/article/details/127766039
Recommended