<launch>
  <arg 
    name="world_name" 
    default="c_corridor" />
  <arg
    name="use_multi_robot"
    default="true" />
  <arg
    name="rvizconfig"
    value="$(find rois_2dnav_gazebo)/rviz/multi_navigation.rviz" />

  <arg
    name="robot1_init_x"
    default="0" />
  <arg
    name="robot1_init_y"
    default="0" />
  <arg
    name="robot2_init_x"
    default="10" />
  <arg
    name="robot2_init_y"
    default="0" />
  <arg
    name="robot3_init_x"
    default="0" />
  <arg
    name="robot3_init_y"
    default="10" />

  <node 
    name="map_server" 
    type="map_server" 
    pkg="map_server"
    args="$(find rois_2dnav_gazebo)/map/$(arg world_name)/$(arg world_name).yaml" />

  <include file="$(find rois_gazebo)/launch/setup_gazebo.launch">
    <arg
      name="rvizconfig"
      value="$(arg rvizconfig)" />
    <arg
      name="use_multi_robot"
      value="$(arg use_multi_robot)" />
    <arg
      name="world_name"
      value="$(find rois_description)/world/$(arg world_name).sdf" />
    <arg
      name="robot1_init_x"
      default="$(arg robot1_init_x)" />
    <arg
      name="robot1_init_y"
      default="$(arg robot1_init_y)" />
    <arg
      name="robot2_init_x"
      default="$(arg robot2_init_x)" />
    <arg
      name="robot2_init_y"
      default="$(arg robot2_init_y)" />
    <arg
      name="robot3_init_x"
      default="$(arg robot3_init_x)" />
    <arg
      name="robot3_init_y"
      default="$(arg robot3_init_y)" />
  </include>

  <group ns="robot1">
    <include file="$(find rois_2dnav_gazebo)/launch/amcl.launch">
      <arg
        name="robot_name"
        value="robot1" />
        <arg
          name="init_x"
          value="$(arg robot1_init_x)" />
        <arg
          name="init_y"
          value="$(arg robot1_init_y)" />
    </include>
    <include file="$(find rois_2dnav_gazebo)/launch/move_base.launch">
      <arg
        name="robot_name"
        value="robot1" />
    </include>
  </group>
  <group if="$(arg use_multi_robot)">
    <group ns="robot2">
      <include file="$(find rois_2dnav_gazebo)/launch/amcl.launch">
        <arg
          name="robot_name"
          value="robot2" />
        <arg
          name="init_x"
          value="$(arg robot2_init_x)" />
        <arg
          name="init_y"
          value="$(arg robot2_init_y)" />
      </include>
      <include file="$(find rois_2dnav_gazebo)/launch/move_base.launch">
        <arg
          name="robot_name"
          value="robot2" />
      </include>
    </group>
    <group ns="robot3">
      <include file="$(find rois_2dnav_gazebo)/launch/amcl.launch">
        <arg
          name="robot_name"
          value="robot3" />
        <arg
          name="init_x"
          value="$(arg robot3_init_x)" />
        <arg
          name="init_y"
          value="$(arg robot3_init_y)" />
      </include>
      <include file="$(find rois_2dnav_gazebo)/launch/move_base.launch">
        <arg
          name="robot_name"
          value="robot3" />
      </include>
    </group>
  </group>
</launch>
