Gazebo | Ignition | Community
Ask Your Question
0

How do you run multiple hector_quadrotors without separate urdf files?

asked 2013-08-17 16:38:41 -0500

Anders gravatar image

updated 2013-08-21 16:16:50 -0500

I'm currently trying to launch multiple hector_quadrotors with a single roslaunch command with ros-hydro. I have got it "working", I have two drones that hover and listen to different 'cmd_vel's.

But to get this to work I had to make my own versions of: aw_quadrotor.urdf.xacro
aw_quadrotor_base.urdf.xacro
aw_quadrotor_plugins.gazebo.xacro
aw_quadrotor_sensors.gazebo.xacro
aw_quadrotor_simple_controller.gazebo.xacro

And one of these for each drone.
drone0_aw_quadrotor.gazebo.xacro
drone1_aw_quadrotor.gazebo.xacro

When I look at I see that some of the commits it looks like hector_quadrotor should support multiple drones without having to edit all the urdf files.
https://github.com/tu-darmstadt-ros-pkg/hector_quadrotor/commits/hydro-devel

What am I missing? How can I make sure the plugins for gazebo don't confuse drones with the same base_link name with each other? Using namespaces doesn't seem to propagate down into the xacro macros/gazebo plugins.

My files currently look like this.

aw_spawn_two_drones_gazebo.launch

<launch>
  <param name="/use_sim_time" value="true"/>

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
  </include>

  <group ns="drone0">
    <include file="$(find aw_hector_quadrotor)/launch/spawn_quadrotor.launch">
      <arg name="name" value="drone0"/>
      <arg name="pos_x" value="0.2"/>
      <arg name="namespace_arg" value="drone0"/>
    </include>
  </group>

  <group ns="drone1">
    <include file="$(find aw_hector_quadrotor)/launch/spawn_quadrotor.launch">
      <arg name="name" value="drone1"/>
      <arg name="pos_x" value="2.0"/>
      <arg name="namespace_arg" value="drone1"/>
    </include>
  </group>
</launch>

spawn_quadrotor.launch

<launch>
  <!-- push robot_description to factory and spawn robot in gazebo -->
  <arg name="name" default="quadrotor"/>
  <arg name="pos_x" default="0.0"/>
  <arg name="pos_y" default="0.0"/>
  <arg name="pos_z" default="0.5"/>
  <arg name="namespace_arg" default=""/>

  <arg name="model" default="$(find aw_hector_quadrotor)/urdf/$(arg namespace_arg)_aw_quadrotor.gazebo.xacro"/>
  <!-- send the robot XML to param server -->
  <param name="robot_description" command="$(find xacro)/xacro.py '$(arg model)'" />
  <param name="tf_prefix" value="$(arg namespace_arg)" />
  <node name="spawn_robot" pkg="gazebo_ros" type="spawn_model"
        args="-param robot_description
              -urdf
              -x $(arg pos_x)
              -y $(arg pos_y)
              -z $(arg pos_z)
              -model $(arg name)"
        respawn="false" output="screen">
  </node>
</launch>

drone0_aw_quadrotor.gazebo.xacro

<robot name="quadrotor" xmlns:xacro="http://ros.org/wiki/xacro">
  <xacro:include filename="$(find aw_hector_quadrotor)/urdf/aw_quadrotor.urdf.xacro" />
  <xacro:include filename="$(find aw_hector_quadrotor)/urdf/aw_quadrotor_plugins.gazebo.xacro" />

  <!-- Instantiate quadrotor_base_macro once (has no parameters atm) -->
  <xacro:quadrotor_base_macro prefix="drone0"/>
  <xacro:quadrotor_sensors_gazebo prefix="drone0"/>
  <xacro:quadrotor_sensors/>
  <xacro:quadrotor_simple_controller prefix="drone0" state_topic="ground_truth/state" imu_topic="raw_imu"/>
</robot>

aw_quadrotor_base.urdf.xacro

<robot xmlns:xacro="http://ros.org/wiki/xacro">
  <xacro:include filename="$(find aw_hector_quadrotor)/urdf/sonar_sensor.urdf.xacro" />
  <xacro:property name="pi" value="3.1415926535897931" />

  <!-- Main quadrotor link -->
  <xacro:macro name="quadrotor_base_macro" params="prefix" >
    <link name="${prefix}/base_link">
      <inertial>
        <mass value="1.477" />
        <origin xyz="0 0 0" />
        <inertia ixx="0.01152" ixy="0.0" ixz="0.0" iyy="0.01152" iyz="0.0" izz="0.0218" />
      </inertial>

      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://hector_quadrotor_description/meshes/quadrotor/quadrotor_base.dae"/>
        </geometry>
      </visual>

      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://hector_quadrotor_description/meshes/quadrotor/quadrotor_base.stl"/>
        </geometry>
      </collision>
    </link ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2013-08-21 08:57:54 -0500

Johannes Meyer gravatar image

ROS groovy: Normally the namespace in which the spawn_model node is run in should be propagated to all plugins automatically. For some reason this feature is commented out in the ROS API plugin (see gazebo_ros_api_plugin.cpp#532) in the current version 1.7.12 released in groovy. There is no other option than to modify each plugin description and add the <robotNamespace> tags manually.

ROS hydro: In the gazebo_ros_pkgs repository, which replaces simulator_gazebo in hydro, the namespace feature is implemented correctly and I am able to launch two quadrotors in different namespaces with a simple additional launch file:

<launch>
   <arg name="model" default="$(find hector_quadrotor_description)/urdf/quadrotor.gazebo.xacro" />

   <group ns="uav1">
     <include file="$(find hector_quadrotor_gazebo)/launch/spawn_quadrotor.launch">
       <arg name="name" value="uav1" />
       <arg name="tf_prefix" value="uav1" />
       <arg name="model" value="$(arg model)" />
       <arg name="y" value="-1.0" />
     </include>
   </group>

   <group ns="uav2">
     <include file="$(find hector_quadrotor_gazebo)/launch/spawn_quadrotor.launch">
       <arg name="name" value="uav2" />
       <arg name="tf_prefix" value="uav2" />
       <arg name="model" value="$(arg model)" />
       <arg name="y" value="1.0" />
     </include>
   </group>

</launch>

I also committed this version (with slight additional modifications in spawn_quadrotor.launch) in ef43f5d today.

The namespace attribute specified in <group ns="..."> specifies the namespace used for nodes, topics, services and parameters. The name argument is the name of the quadrotor in the gazebo model list. The tf_prefix is the prefix used for all non-global tf frames. x, y, z and model arguments should be self-explanatory.

Note: The tf_prefix parameter has been deprecated in ROS hydro. You currently need an updated version of the message_to_tf package from the hector_localization stack. I hope that backwards compatibility will be reestablished until the final release. hector_common is no longer maintained in hydro.

edit flag offensive delete link more

Comments

Thanks, got it working now without my modified urdfs. I'm not sure what fixed it but things I did:<br> sudo apt-get install ros-hydro-gazebo-ros-pkgs ros-hydro-gazebo-ros-control<br> sudo apt-get update<br> sudo apt-get upgrade<br> git clone https://github.com/ros/xacro.git<br> git clone https://github.com/tu-darmstadt-ros-pkg/hectorlocalization.git<br> And got these from source:<br> hectorquadrotor<br> hectorgazebo<br> hectorlocalization<br> hector_models<br> And rebuilt everthing.

Anders gravatar imageAnders ( 2013-08-21 16:04:11 -0500 )edit

Hi Johannes, can you give me an example how to modify the plugin description and add the <robotNamespace> tags manually? I want to use 2 youbots but because of the namespace-bug I can't.

koellsch gravatar imagekoellsch ( 2013-09-25 05:11:27 -0500 )edit

Is there anyway for fuerte too? I am working on tum_simulator right now. However, I was able to spawn second ardrone, but I can't control that. Could you give me any recommendation approach idea that I can solve this problem? I really want to control second ardrone too. First ardrone works, but second ardrone doesn't work after I spawn that.

Yonggun gravatar imageYonggun ( 2014-08-15 15:41:14 -0500 )edit

I work on Indigo and the Johannes launch works fine, the problem appears when you try to visualize the sonar sensors on rviz, the robots’ namespace don’t propagate automatically to the sonar sensor's frameId of the robots. An error appears: Transform [sender=unknown_publisher] For frame [sonar_link]: Frame [sonar_link] does not exist I resolve the problem modifying the plugin adding manually the robot’s namespace in line 63 of sonar_sensor.urdf.xacro.I think that exist and elegant way to do that

fermendi gravatar imagefermendi ( 2016-01-31 15:54:44 -0500 )edit

Did you manage to fix the sensor problem? I can't get the cameras to work

trA gravatar imagetrA ( 2018-01-26 21:10:34 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2013-08-17 16:38:41 -0500

Seen: 7,685 times

Last updated: Aug 21 '13