simplest multiple-robot scenario
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?
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.
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.
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?
I would recommend against using namespaces to resolve this sort of problem, nothing in TF is designed to be namespaced.
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.