当前位置:网站首页>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 .
边栏推荐
- [combinatorics] combinatorial identity (sum of combinatorial identity products 1 | sum of products 1 proof | sum of combinatorial identity products 2 | sum of products 2 proof)
- Why can't strings be directly compared with equals; Why can't some integers be directly compared with the equal sign
- Problems of CString in multithreading
- How to use annotations such as @notnull to verify and handle global exceptions
- Intelij idea efficient skills (III)
- Three dimensional reconstruction of deep learning
- 首发!!lancet饿了么官方文档
- The difference between RAR and zip files
- 【OpenCV 例程200篇】217. 鼠标交互获取多边形区域(ROI)
- Microservice sentinel flow control degradation
猜你喜欢

The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)

About text selection in web pages and counting the length of selected text

VS2017通过IP调试驱动(双机调试)
![[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix](/img/d6/3c21c25f1c750f17aeb871124e80f4.png)
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
![[系统安全] 四十三.Powershell恶意代码检测系列 (5)抽象语法树自动提取万字详解](/img/cd/00954b9c592c253d42e6a3b8298999.jpg)
[系统安全] 四十三.Powershell恶意代码检测系列 (5)抽象语法树自动提取万字详解

Principles of several common IO models
![[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display](/img/46/c7f566f8fd46d383b055582d680bb7.png)
[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display

几种常见IO模型的原理

ASEMI整流桥UMB10F参数,UMB10F规格,UMB10F封装

Function introduction of JMeter thread group
随机推荐
Why can't strings be directly compared with equals; Why can't some integers be directly compared with the equal sign
2022年Q2加密市场投融资报告:GameFi成为投资关键词
[200 opencv routines] 217 Mouse interaction to obtain polygon area (ROI)
Go language self-study series | if else statement in golang
Large CSV split and merge
Nine ways to define methods in scala- Nine ways to define a method in Scala?
Go language self-study series | if else if statement in golang
[list to map] collectors Tomap syntax sharing (case practice)
App移动端测试【3】ADB命令
Redis在Windows以及Linux系统下的安装
【OpenCV 例程200篇】217. 鼠标交互获取多边形区域(ROI)
找映射关系
The difference between calling by value and simulating calling by reference
QT use qzxing to generate QR code
How idea starts run dashboard
Microservice sentinel flow control degradation
App mobile terminal test [5] file writing and reading
Uploads labs range (with source code analysis) (under update)
Salary 3000, monthly income 40000 by "video editing": people who can make money never rely on hard work!
子类隐藏父类的同名函数