Home » Turtlebot3多机建图教程 » Turtlebot3多机建图教程-遥控建图

Turtlebot3多机建图教程-遥控建图

Turtlebot3多机建图教程-遥控建图

说明:

  • 介绍如何实现多机的遥控建图

步骤:

  • [remotePC]启动roscore
roscore
  • [turtlebot3]启动底盘
ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_bringup turtlebot3_robot.launch multi_robot_name:="tb3_0" set_lidar_frame_id:="tb3_0/base_scan"
  • 启动第二台底盘,替代tb3_0为tb3_1
  • [remotePC]启动slam建图
ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_slam turtlebot3_gmapping.launch set_base_frame:=tb3_0/base_footprint set_odom_frame:=tb3_0/odom set_map_frame:=tb3_0/map
  • 启动第一台slam建图,替换tb3_0为tb3_1
  • [remotePC]启动地图合并
roslaunch turtlebot3_slam  turtlebot3_map_merge.launch
  • 没有对应文件就建立一个,具体turtlebot3_map_merge.launch内容如下:
<launch>
  <arg name="first_tb3"  default="tb3_0"/>
  <arg name="second_tb3" default="tb3_1"/>

  <arg name="first_tb3_x_pos" default="-7.0"/>
  <arg name="first_tb3_y_pos" default="-1.0"/>
  <arg name="first_tb3_z_pos" default=" 0.0"/>
  <arg name="first_tb3_yaw"   default=" 0.0"/>

  <arg name="second_tb3_x_pos" default=" 7.0"/>
  <arg name="second_tb3_y_pos" default="-1.0"/>
  <arg name="second_tb3_z_pos" default=" 0.0"/>
  <arg name="second_tb3_yaw"   default=" 0.0"/>

  <group ns="$(arg first_tb3)/map_merge">
    <param name="init_pose_x"   value="$(arg first_tb3_x_pos)"/>
    <param name="init_pose_y"   value="$(arg first_tb3_y_pos)"/>
    <param name="init_pose_z"   value="$(arg first_tb3_z_pos)"/>
    <param name="init_pose_yaw" value="$(arg first_tb3_yaw)"  />
  </group>

  <group ns="$(arg second_tb3)/map_merge">
    <param name="init_pose_x"   value="$(arg second_tb3_x_pos)"/>
    <param name="init_pose_y"   value="$(arg second_tb3_y_pos)"/>
    <param name="init_pose_z"   value="$(arg second_tb3_z_pos)"/>
    <param name="init_pose_yaw" value="$(arg second_tb3_yaw)"  />
  </group>


  <node pkg="multirobot_map_merge" type="map_merge" respawn="false" name="map_merge" output="screen">
    <param name="robot_map_topic" value="map"/>
    <param name="robot_namespace" value="tb3"/>
    <param name="merged_map_topic" value="map"/>
    <param name="world_frame" value="map"/>
    <param name="known_init_poses" value="true"/>
    <param name="merging_rate" value="0.5"/>
    <param name="discovery_rate" value="0.05"/>
    <param name="estimation_rate" value="0.1"/>
    <param name="estimation_confidence" value="1.0"/>
  </node>

  <node pkg="tf" type="static_transform_publisher" name="world_to_$(arg first_tb3)_tf_broadcaster"  args="0 0 0 0 0 0 /map /$(arg first_tb3)/map 100"/>
  <node pkg="tf" type="static_transform_publisher" name="world_to_$(arg second_tb3)_tf_broadcaster" args="0 0 0 0 0 0 /map /$(arg second_tb3)/map 100"/>
</launch>
       
  • [remotePC]启动rviz
rosrun rviz rviz -d `rospack find turtlebot3_slam`/rviz/multi_turtlebot3_slam.rviz
ROS_NAMESPACE=tb3_0 rosrun turtlebot3_teleop turtlebot3_teleop_key
  • [remotePC]启动第二台机器人键盘控制,替代tb3_0为tb3_1
  • 随后分别遥控机器人在环境里面走动进行建图。
  • 保存地图:
rosrun map_server map_saver -f ~/map

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: turtlebot3多机建图教程