<!--
  FileName: stdr_move_base.launch
  Copyright: 2016-2018 ROS小课堂 www.corvin.cn
  Author: corvin
  Description:
    启动move_base节点，加载各个配置文件。
  History:
    20180528: initial this file.
    20180530: add arg param to rename all kinds of frames,topics,add load params file.
-->
<launch>
  <group ns="/robot0">
    <arg name="odom_frame_id"   default="/map_static"/>
    <arg name="base_frame_id"   default="/robot0"/>
    <arg name="global_frame_id" default="/map"/>

    <arg name="odom_topic"      default="/robot0/odom"/>
    <arg name="cmd_vel_topic"   default="/robot0/cmd_vel"/>
    <arg name="map_topic"       default="/amcl/map"/>

    <node pkg="move_base" type="move_base" name="stdr_robot0_move_base" output="screen">
      <rosparam file="$(find stdr_move_base)/config/costmap_common_params.yaml" command="load" ns="global_costmap" />
      <rosparam file="$(find stdr_move_base)/config/costmap_common_params.yaml" command="load" ns="local_costmap" />
      <rosparam file="$(find stdr_move_base)/config/local_costmap_params.yaml"  command="load" />
      <rosparam file="$(find stdr_move_base)/config/global_costmap_params.yaml" command="load" />
      <rosparam file="$(find stdr_move_base)/config/move_base_params.yaml"            command="load" />
      <rosparam file="$(find stdr_move_base)/config/global_planner_params.yaml"       command="load" />
      <rosparam file="$(find stdr_move_base)/config/dwa_local_planner_params.yaml"    command="load" />

    <param name="global_costmap/global_frame"     value="$(arg global_frame_id)"/>
    <param name="global_costmap/robot_base_frame" value="$(arg base_frame_id)"/>
    <param name="local_costmap/global_frame"      value="$(arg odom_frame_id)"/>
    <param name="local_costmap/robot_base_frame"  value="$(arg base_frame_id)"/>
    <param name="DWAPlannerROS/global_frame_id"   value="$(arg odom_frame_id)"/>

      <!-- move base default publish cmd to /cmd_vel topic,now remap to /robot0/cmd_vel -->
      <remap from="/cmd_vel" to="$(arg cmd_vel_topic)"/>

      <!-- move_base default subscribe odom topic,now remap to /robot0/odom -->
      <remap from="/odom" to="$(arg odom_topic)"/>

      <!-- move_base default subscribe map topic,now remap to /amcl/map -->
      <remap from="/map" to="$(arg map_topic)"/>
    </node>
  </group>

  <group ns="/robot1">
    <arg name="odom_frame_id"   default="/map_static"/>
    <arg name="base_frame_id"   default="/robot1"/>
    <arg name="global_frame_id" default="/map"/>

    <arg name="odom_topic"      default="/robot1/odom"/>
    <arg name="cmd_vel_topic"   default="/robot1/cmd_vel"/>
    <arg name="map_topic"       default="/amcl/map"/>

    <node pkg="move_base" type="move_base" name="stdr_robot1_move_base" output="screen">
      <rosparam file="$(find stdr_move_base)/config/costmap_common_params.yaml" command="load" ns="global_costmap" />
      <rosparam file="$(find stdr_move_base)/config/costmap_common_params.yaml" command="load" ns="local_costmap" />
      <rosparam file="$(find stdr_move_base)/config/local_costmap_params.yaml"  command="load" />
      <rosparam file="$(find stdr_move_base)/config/global_costmap_params.yaml" command="load" />
      <rosparam file="$(find stdr_move_base)/config/move_base_params.yaml"            command="load" />
      <rosparam file="$(find stdr_move_base)/config/global_planner_params.yaml"       command="load" />
      <rosparam file="$(find stdr_move_base)/config/dwa_local_planner_params.yaml"    command="load" />

    <param name="global_costmap/global_frame"     value="$(arg global_frame_id)"/>
    <param name="global_costmap/robot_base_frame" value="$(arg base_frame_id)"/>
    <param name="local_costmap/global_frame"      value="$(arg odom_frame_id)"/>
    <param name="local_costmap/robot_base_frame"  value="$(arg base_frame_id)"/>
    <param name="DWAPlannerROS/global_frame_id"   value="$(arg odom_frame_id)"/>

      <!-- move base default publish cmd to /cmd_vel topic,now remap to /robot1/cmd_vel -->
      <remap from="/cmd_vel" to="$(arg cmd_vel_topic)"/>

      <!-- move_base default subscribe odom topic,now remap to /robot1/odom -->
      <remap from="/odom" to="$(arg odom_topic)"/>

      <!-- move_base default subscribe map topic,now remap to /amcl/map -->
      <remap from="/map" to="$(arg map_topic)"/>
    </node>
  </group>
</launch>

