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

simplest multiple-robot scenario

asked 2017-06-07 18:50:48 -0500

mogumbo gravatar image

updated 2017-06-07 18:51:28 -0500

Was having trouble getting multiple robots to work, so I tried to boil it down to the simplest possible scenario. Here's what I have for a launch file:

<?xml version="1.0" encoding="utf-8"?>
<launch>
  <group ns="ns0">
    <param name="robot_description" command="cat '$(find urdf_tutorial)/urdf/01-myfirst.urdf'"/>
    <node name="my_stp" pkg="tf" type="static_transform_publisher" args="-1 0 0 0 0 0 /map base_link 100"/>
    <node name="my_jsp" pkg="joint_state_publisher" type="joint_state_publisher"/>
    <node name="my_rsp" pkg="robot_state_publisher" type="state_publisher"/>
  </group>

  <group ns="ns1">
    <param name="robot_description" command="cat '$(find urdf_tutorial)/urdf/02-multipleshapes.urdf'"/>
    <node name="my_stp" pkg="tf" type="static_transform_publisher" args="1 0 0 0 0 0 /map base_link 100"/>
    <node name="my_jsp" pkg="joint_state_publisher" type="joint_state_publisher"/>
    <node name="my_rsp" pkg="robot_state_publisher" type="state_publisher"/>
  </group>

  <node name="rviz" pkg="rviz" type="rviz" respawn="false" output="screen" args="-d $(find xxx)/config/xxx.rviz"/>
</launch>

And my xxx.rviz is the same as default.rviz with the addition of two RobotModels:

- Alpha: 1
      Class: rviz/RobotModel
      Collision Enabled: false
      Enabled: true
      Links:
        All Links Enabled: true
        Expand Joint Details: false
        Expand Link Details: false
        Expand Tree: false
        Link Tree Style: Links in Alphabetic Order
      Name: RobotModel
      Robot Description: ns0/robot_description
      TF Prefix: ""
      Update Interval: 0
      Value: true
      Visual Enabled: true
    - Alpha: 1
      Class: rviz/RobotModel
      Collision Enabled: false
      Enabled: true
      Links:
        All Links Enabled: true
        Expand Joint Details: false
        Expand Link Details: false
        Expand Tree: false
        Link Tree Style: ""
      Name: RobotModel
      Robot Description: ns1/robot_description
      TF Prefix: ""
      Update Interval: 0
      Value: true
      Visual Enabled: true

I would expect this to show 01-myfirst.urdf at position (-1,0,0) and 02-multipleshapes.urdf at position (1,0,0). However, it shows 02-multipleshapes.urdf flickering back and forth between the two positions. 01-myfirst.urdf is not shown at all. Can anyone explain what I'm missing?

edit retag flag offensive close merge delete

Comments

Are the link names (and thus tf frame ids) different between your 2 robots? If you had 2 identical robots and did not set a robot name prefix via something like a xacro argument (or hardcoded) then I would expect to see this behaviour. TF doesn't namespace without a lot of work by the user.

Dale McConachie gravatar image Dale McConachie  ( 2017-06-07 19:51:29 -0500 )edit

I should add that with your specific example, I would look at the name of the "root" of the 2 robots, and see if they have the same TF frame id. You could try http://wiki.ros.org/rqt_tf_tree as a debug tool.

Dale McConachie gravatar image Dale McConachie  ( 2017-06-07 19:55:57 -0500 )edit

The root is called "base_link" in both models. If I change the name of one of them then this scenario behaves as expected. Thank you. I guess I'll read about how to deal with namespaces in TF. Or is there are alternative to doing this sort of thing that works better?

mogumbo gravatar image mogumbo  ( 2017-06-08 10:01:57 -0500 )edit

I would recommend against using namespaces to resolve this sort of problem, nothing in TF is designed to be namespaced.

Dale McConachie gravatar image Dale McConachie  ( 2017-06-08 10:50:07 -0500 )edit

I would suggest looking at http://wiki.ros.org/urdf/Tutorials/Us... for how to use prefixes in XACRO files as a way to keep naming consistent for the tyepes of joints, but on different robots.

Dale McConachie gravatar image Dale McConachie  ( 2017-06-08 10:50:31 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-06-08 19:00:49 -0500

mogumbo gravatar image

Thank you for the comments. Based on those and some help from a local ROS expert, I have gotten things working like so:

<?xml version="1.0" encoding="utf-8"?>
<launch>
  <group ns="ns0">
    <param name="tf_prefix" value="ns0"></param>
    <param name="robot_description" command="cat '$(find urdf_tutorial)/urdf/01-myfirst.urdf'"/>
    <node name="my_stp" pkg="tf" type="static_transform_publisher" args="-1 0 0 0 0 0 map ns0/base_link 100"/>
    <node name="my_rsp" pkg="robot_state_publisher" type="state_publisher"/>
  </group>

  <group ns="ns1">
    <param name="tf_prefix" value="ns1"></param>
    <param name="robot_description" command="cat '$(find urdf_tutorial)/urdf/02-multipleshapes.urdf'"/>
    <node name="my_stp" pkg="tf" type="static_transform_publisher" args="1 0 0 0 0 0 map ns1/base_link 100"/>
    <node name="my_rsp" pkg="robot_state_publisher" type="state_publisher"/>
  </group>

  <node name="rviz" pkg="rviz" type="rviz" respawn="false" output="screen" args="-d $(find xxx)/config/xxx.rviz"/>
</launch>

The tf_prefix params make the link names unique in each .urdf (almost as if they respected namespaces). And in the .rviz file I just added "TF Prefix: ns0" and "TF Prefix: ns1" to their respective RobotModel sections.

These changes take care of the problem of TF not handling namespaces, but it sure would be simpler if namespaces just worked across all of ROS. There's probably a good reason for it I'm not seeing yet, but I just started using ROS a few weeks ago.

I have not yet tried Dale's suggestion of using prefixes in a .xacro file. From what I have read I believe it's a very similar solution to what I have here.

edit flag offensive delete link more

Comments

1

I don't know a whole lot about the differences between TF and TF2, but using TF prefixes instead of XACRO prefixs may cause you trouble down the road: http://wiki.ros.org/tf2/Migration . I don't expect problems, just thought I'd point it out so you are aware of it should it ever become relevant.

Dale McConachie gravatar image Dale McConachie  ( 2017-06-09 00:16:20 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-06-07 18:50:48 -0500

Seen: 3,024 times

Last updated: Jun 08 '17