ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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.

asked 2020-11-18 23:17:28 -0600

poojakurdekar3@gmail.com gravatar image

updated 2020-11-25 14:29:41 -0600

jayess gravatar image

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>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-11-24 21:15:41 -0600

achmad_fathoni gravatar image

As stated in this the github issue and this, this problem is fixed in newer release of ROS such as ROS lunar, ROS Melodic or ROS2 Foxy. I recommend you to upgrade your ROS to Melodic which is closest LTS ROS to ROS kinetic.

edit flag offensive delete link more

Comments

chandu@chanduPC:~/pooja/robo_ws/src/ros_robotics/launch$ python multi20.py ... logging to /home/chandu/.ros/log/46ba9132-2ee8-11eb-95d3-983b8fe03071/roslaunch-chanduPC-11092.log Traceback (most recent call last): File "multi20.py", line 13, in <module> parent.start() AttributeError: 'list' object has no attribute 'start'

poojakurdekar3@gmail.com gravatar image poojakurdekar3@gmail.com  ( 2020-11-25 00:54:12 -0600 )edit

I'm getting above error , Please look into this.

my code

!/usr/bin/python

import rospy import roslaunch

uuid = roslaunch.rlutil.get_or_generate_uuid(None, False) roslaunch.configure_logging(uuid)

cli_args = ['/home/chandu/pooja/robo_ws/src/ros_robotics/launch/diff_wheeled_gazebo_full13.launch','mav_name:=robot'] roslaunch_args = cli_args[1:] # empty but doesn't affect the outcome roslaunch_file = roslaunch.rlutil.resolve_launch_arguments(cli_args) parent = [(roslaunch.rlutil.resolve_launch_arguments(cli_args)[0], roslaunch_args)] parent.start() rospy.sleep(60000) # prevent from immediately shutting down

poojakurdekar3@gmail.com gravatar image poojakurdekar3@gmail.com  ( 2020-11-25 00:56:36 -0600 )edit

@poojakurdekar3gmailcom I am sorry but recently I am not using ROS anymore so I forget most of the concept.

achmad_fathoni gravatar image achmad_fathoni  ( 2020-11-26 21:22:29 -0600 )edit

Question Tools

Stats

Asked: 2020-11-18 23:17:28 -0600

Seen: 237 times

Last updated: Nov 25 '20