I want to launch N robots using single xacro file by passing N (number of robots)and x,y,z (location of robot )as arguments. Please help me how can do this.
I started with only one argument i.e N. This please my launch file. Please let me know if I'm wrong somewhere. Thanks in Advance
<launch>
<!-- these are the arguments you can pass this launch file, for example paused:=true -->
<arg name="paused" default="false"/>
<arg name="use_sim_time" default="true"/>
<arg name="gui" default="true"/>
<arg name="headless" default="false"/>
<arg name="debug" default="false"/>
<!-- We resume the logic in empty_world.launch -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="debug" value="$(arg debug)" />
<arg name="gui" value="$(arg gui)" />
<arg name="paused" value="$(arg paused)"/>
<arg name="use_sim_time" value="$(arg use_sim_time)"/>
<arg name="headless" value="$(arg headless)"/>
</include>
<!-- urdf xml robot description loaded on the Parameter Server-->
<arg name="nr" />
<param name="param" value="$(arg nr)"/>
<param name="robot_description" command="$(find xacro)/xacro.py '$(find ros_robotics)/urdf/robots_des/diff_wheeled_robot_with_sensor_$(arg nr).xacro'" />
<param name="robot_description" command="$(find xacro)/xacro.py '$(find ros_robotics)/urdf/robots_des/diff_wheeled_robot_with_sensor_$(eval arg nr-1).xacro'" />
<group ns="robot_$(arg nr)">
<param name="tf_prefix" value="robot_$(arg nr)_tf" />
<arg name="init_pose" value="-x 3 -y 1 -z 0" />
<arg name="robot_name" value="Robot_$(arg nr)" />
<node name="urdf_spawner_$(arg nr)" pkg="gazebo_ros" type="spawn_model"
args="$(arg init_pose) -urdf -param /robot_description -model $(arg robot_name)"
respawn="false" output="screen" />
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node>
<!-- start robot state publisher -->
<node pkg="robot_state_publisher" type="state_publisher" name="robot_state_publisher" output="screen" >
<param name="publish_frequency" type="double" value="50.0" />
</node>
<group ns="robot_$(eval arg (nr)-1)">
<param name="tf_prefix" value="robot_$(eval arg (nr)-1)_tf" />
<arg name="init_pose" value="-x 3 -y 1 -z 0" />
<arg name="robot_name" value="Robot_$(eval arg (nr)-1)" />
<node name="urdf_spawner_$(eval arg (nr)-1)" pkg="gazebo_ros" type="spawn_model"
args="$(arg init_pose) -urdf -param /robot_description -model $(arg robot_name)"
respawn="false" output="screen" />
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node>
<!-- start robot state publisher -->
<node pkg="robot_state_publisher" type="state_publisher" name="robot_state_publisher" output="screen" >
<param name="publish_frequency" type="double" value="50.0" />
</node>
</group>
</launch>