引言
我们已经可以使用多台机器人一起进行SLAM,并把地图进行融合。这次,我们在已经构建好的地图中,让多台机器人定位并进行运动规划。详细的内容请到我的gitee上下载功能包,gitee在第一篇文章中
环境搭建
我们直接看launch文件,除了启动仿真环境放入机器人外,我们还加入了acml和move_base节点,acml可以使得机器人可以通过雷达扫描数据判断自身在地图中的位置,move_base可以进行路劲规划。
网上有很多教程,但是我这里的核心难度在于存在多个机器人,所以需要存在很多命名空间冲突的问题,需要搞清楚acml和move_base分别订阅了什么topic,才能把多个机器人之间的关系梳理清楚。
<launch>
<!--设置参数 -->
<arg name="simulation" default="true"/>
<arg name="move_forward_only" default="false"/>
<group if="$(arg simulation)" >
<!-- 开启仿真世界 -->
<include file="$(find gazebo_tutorials)/launch/create_world.launch" />
<!-- 放置机器人 -->
<include file="$(find gazebo_tutorials)/launch/place_robot.launch">
<arg name="robot_x_pos" value="0.0"/>
<arg name="robot_y_pos" value="0.0"/>
<arg name="robot_z_pos" value="0.0"/>
<arg name="robot_yaw" value="0"/>
<arg name="robot_name" value="tb3_0"/>
</include>
<!-- 放置机器人 -->
<include file="$(find gazebo_tutorials)/launch/place_robot.launch">
<arg name="robot_x_pos" value="1.0"/>
<arg name="robot_y_pos" value="0.0"/>
<arg name="robot_z_pos" value="0.0"/>
<arg name="robot_yaw" value="0"/>
<arg name="robot_name" value="tb3_1"/>
</include>
</group>
<!-- 导入地图 -->
<node name="map_server" pkg="map_server" type="map_server" args="$(find gazebo_tutorials)/map/map.yaml" output="screen">
<!-- <param name="frame_id" value="/map"/> -->
</node>
<!-- amcl定位-->
<include file="$(find gazebo_tutorials)/launch/amcl.launch" >
<arg name="ns" value="tb3_0" />
</include>
<include file="$(find gazebo_tutorials)/launch/amcl.launch" >
<arg name="ns" value="tb3_1" />
</include>
<!-- move_base导航-->
<include file="$(find gazebo_tutorials)/launch/move_base.launch">
<arg name="ns" value="tb3_0" />
<arg name="move_forward_only" value="$(arg move_forward_only)"/>
</include>
<include file="$(find gazebo_tutorials)/launch/move_base.launch">
<arg name="ns" value="tb3_1" />
<arg name="move_forward_only" value="$(arg move_forward_only)"/>
</include>
<!-- rviz -->
<include file="$(find gazebo_tutorials)/launch/rviz_two_robots.launch" />
</launch>
使用说明
使用命令roslaunch gazebo_tutorials navigate_with_map.launch
启动文件
2d pos estimate在这里不需要使用,因为我们的初始位置是我们自己设定的,基本是准确的。但是如果在使用中,我们可能会把机器人摆歪,那么激光雷达的扫描结果就和地图边缘不匹配,这时候就要使用这个工具调整位姿。发布位姿的时候要使用右上角的tool properties,这个在吗默认的rviz中是不会显示的,需要手动添加。然后目前的topic是没有命名空间的情况下,所以要在前面加上tb3_0/
代表是第一台机器人位姿估计。
2d Nav Goal就是发布希望机器人的目标地点,同样需要修改右上角topic来选定导航的机器人。