当前位置:网站首页>Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
2022-07-03 16:05:00 【Pony Baby】
List of articles
introduction
This is a relatively complete tutorial . The article will be divided into four parts :
- build gazebo Simulation environment , And run in a virtual environment slam Algorithm , Save the environment map
- Use map_merge, Multiple robots at the same time slam Drawing
- Use map_server Open the saved map , And make acml Positioning and move_base Perform autonomous navigation
- Use explore_lite The function package realizes the autonomous navigation of the robot , Edge construction map
PS: The article does not include the installation of the corresponding function package , The environment used is melodic, If there is a version inconsistency , Minor modifications may be required
gitee Address
The first part build gazebo Simulation environment
Use gazebo Of building_editor Build a map
- open building_editor

- Click on the left Wall, Draw a two-dimensional map on the whiteboard , It will automatically generate a three-dimensional map . If you want to build more complex , For example, a map with a slope , You can also use 3D modeling software to design , Import to gazebo I won't seriously introduce it here

- sign out editor And click the save, It is recommended to drag the 3D model , Make the coordinate origin in the map , Otherwise, it will be inconvenient to set the robot birth point later

- Finally exit gazebo And save the map as xxx.world file , If you use a virtual machine , You will encounter the situation that the save interface is stuck , At this time, minimizing the window and opening it again can solve the problem .
Use launch File loading world file
- First create the function package , I call it " gazebo_tutorials
- Add two folders launch and world, Save what you just saved world The file is kept in world In the folder
- establish launch file , I call it create_world.launch
<launch>
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(find gazebo_tutorials)/world/maze.world"/>
<arg name="paused" value="false"/>
<arg name="use_sim_time" value="true"/>
<arg name="gui" value="true"/>
<arg name="headless" value="false"/>
<arg name="debug" value="false"/>
</include>
</launch>
catkin_make Compile the , Use command roslaunch gazebo_tutorials create_world.launch You can start the simulation environment
The second part Put your robot
You can model your robot , export urdf Model , But for the sake of generality , We use it directly here turtlebot3 Model of .
Use turtlebot I referred to /opt/ros/melodic/share/turtlebot3_gazebo Files in the folder , It contains sample files of the distribution package , You search online gazebo Simulation allows you to run these files directly , Learn to read these documents by yourself , imitation , Then you can use it in your own projects .
- Write a name for place_robot.launch File placement robot ,TURTLEBOT3_MODEL You set it up by yourself turtlebot species , You can use
export TURTLEBOT3_MODEL=bugerSet the robot type as buger, Corresponding burger Model of
<launch>
<!-- Robot initialization position parameters -->
<arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
<arg name="robot_name" default="tb3_0"/>
<arg name="robot_x_pos" default="0.0"/>
<arg name="robot_y_pos" default="0.0"/>
<arg name="robot_z_pos" default=" 0.0"/>
<arg name="robot_yaw" default=" 0.0"/>
<!-- Create robots -->
<group ns = "$(arg robot_name)">
<!-- Import robot parameters -->
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" />
<!-- Robot position publishing node -->
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen">
<param name="publish_frequency" type="double" value="50.0" />
<param name="tf_prefix" value="$(arg robot_name)" />
</node>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model $(arg robot_name) -x $(arg robot_x_pos) -y $(arg robot_y_pos) -z $(arg robot_z_pos) -Y $(arg robot_yaw) -param robot_description" />
</group>
</launch>
roslaunch gazebo_tutorials place_robot.launch You can see that the robot was born at the origin 
Use rostopic list、rqt_graph、rosrun rqt_tf_tree rqt_tf_tree Wait for the order to observe , Later debugging can often use these things for observation 


in addition , We can use roslaunch gazebo_tutials place_robot.launch robot_name:=tb3_1 robot_x_pos:=1.0 Command to create a second in a different location 、 Three robots , We'll do these things until the last article , Now keep a robot .
The third part start-up SLAM
I configured gmapping and cartorgrapher Algorithm configuration file , Only the most commonly used gmapping Algorithm configuration file , See the terminal start printing data , That is, it is opened successfully .
<launch>
<arg name="ns" default="tb3_0"/>
<!-- Gmapping -->
<node pkg="gmapping" type="slam_gmapping" name="turtlebot3_slam_gmapping" output="screen" ns="$(arg ns)">
<param name="base_frame" value="$(arg ns)/base_footprint"/>
<param name="odom_frame" value="$(arg ns)/odom"/>
<param name="map_frame" value="$(arg ns)/map"/>
<param name="map_update_interval" value="2.0"/>
<param name="maxUrange" value="4.0"/>
<param name="minimumScore" value="100"/>
<param name="linearUpdate" value="0.2"/>
<param name="angularUpdate" value="0.2"/>
<param name="temporalUpdate" value="0.5"/>
<param name="delta" value="0.05"/>
<param name="lskip" value="0"/>
<param name="particles" value="120"/>
<param name="sigma" value="0.05"/>
<param name="kernelSize" value="1"/>
<param name="lstep" value="0.05"/>
<param name="astep" value="0.05"/>
<param name="iterations" value="5"/>
<param name="lsigma" value="0.075"/>
<param name="ogain" value="3.0"/>
<param name="srr" value="0.01"/>
<param name="srt" value="0.02"/>
<param name="str" value="0.01"/>
<param name="stt" value="0.02"/>
<param name="resampleThreshold" value="0.5"/>
<param name="xmin" value="-10.0"/>
<param name="ymin" value="-10.0"/>
<param name="xmax" value="10.0"/>
<param name="ymax" value="10.0"/>
<param name="llsamplerange" value="0.01"/>
<param name="llsamplestep" value="0.01"/>
<param name="lasamplerange" value="0.005"/>
<param name="lasamplestep" value="0.005"/>
</node>
</launch>
Run at terminal rviz, Click on the bottom left corner add, stay by topic Find map Add in , You can see the built map ,rviz You can also save the configuration , Don't save it here , I'll talk more about it later when there are more robots , Including the display of coordinates 、 Selection of coordinate system, etc .
fixed_frame Choose as tb3_0/map, Set the world coordinate system as the map coordinate 
We can see , yes gazebo This environment directly gives gmapping Nodes provide scan This radar data topic
The fourth part Use keyboard control to build the map and save
Keyboard controlled robot
Use command ROS_NAMESPACE=tb3_0 rosrun teleop_twist_keyboard teleop_twist_keyboard.py that will do , Those without this control package can install one , Follow the instructions , If the robot movement is different from what you expect , You can slow down the robot and try again .
Save the map
Use the command to ROS_NAMESPACE=tb3_0 rosrun map_server map_saver -f ~/catkin_ws/src/gazebo_tutorials/map/map Save the built map 
There are two files saved , One is pgm file , Is the map built , It's a 0-255 The gray image . the other one yaml The file describes the map ,resolution=0.05 Represents an image primed case 0.05 rice ,origin Represents the coordinates represented by the pixels at the bottom left of the picture .
such , Our first lesson is finished .
边栏推荐
- Microservice API gateway
- [redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)
- Why can't strings be directly compared with equals; Why can't some integers be directly compared with the equal sign
- “用Android复刻Apple产品UI”(2)——丝滑的AppStore卡片转场动画
- Go语言自学系列 | golang中的if else语句
- Redis installation under windows and Linux systems
- Create gradle project
- A Fei's expectation
- Calibre LVL
- Unity功能——Unity离线文档下载及使用
猜你喜欢

From the 18th line to the first line, the new story of the network security industry

深度学习之三维重建

Detailed pointer advanced 1
![[200 opencv routines] 217 Mouse interaction to obtain polygon area (ROI)](/img/04/460734209ec315c5c02cb3fae4bf0e.png)
[200 opencv routines] 217 Mouse interaction to obtain polygon area (ROI)

Semi supervised learning

Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword

Download and install common programs using AUR

Reading notes of "micro service design" (Part 2)

App移动端测试【3】ADB命令

Stm32f103c8t6 firmware library lighting
随机推荐
Under VC, Unicode and ANSI are converted to each other, cstringw and std:: string are converted to each other
How to thicken the brush in the graphical interface
How idea starts run dashboard
MB10M-ASEMI整流桥MB10M
Get the executable path through the process PID (queryfullprocessimagename)
Automatic generation of client code from flask server code -- Introduction to flask native stubs Library
Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword
Subclass hides the function with the same name of the parent class
Uploads labs range (with source code analysis) (under update)
Unity function - unity offline document download and use
"Remake Apple product UI with Android" (2) -- silky Appstore card transition animation
Distributed task scheduling XXL job
[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)
[200 opencv routines] 217 Mouse interaction to obtain polygon area (ROI)
Salary 3000, monthly income 40000 by "video editing": people who can make money never rely on hard work!
Rk3399 platform development series explanation (WiFi) 5.54. What is WiFi wireless LAN
六月 致 -.-- -..- -
Microservice - declarative interface call openfeign
Semi supervised learning
Mb10m-asemi rectifier bridge mb10m