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

Revision history [back]

click to hide/show revision 1
initial version

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.