osrf / vrx

Virtual RobotX (VRX) resources.
Apache License 2.0
390 stars 180 forks source link

TF frames are inconsistent #681

Closed j-herman closed 11 months ago

j-herman commented 1 year ago

Placeholder issue for some problems with how the Ros bridge is re-publishing the wamv TF messages. I will add detail and a recommendation for correction. This has become evident while working on the RVIZ tutorial and finishing that work will be dependent on closing this issue. More specifically, we seem to have an extra "wamv/" inserted into some frames but not all, which breaks the TF tree when read from ROS. Still early in troubleshooting, so this may not actually be the problem.

j-herman commented 1 year ago

Describe the bug The transforms published by gz::sim::systems::PosePublisher do not match the tree created in the WAM-V URDF. Behavior is correct within Gazebo but this causes problems when visualizing the vehicle in RVIZ, and could be an issue for other consumers of TF2 data. The major differences noted:

Expected behavior I expect the TF tree published by the simulation to match the URDF, both in frame names and in parent-child relationships.

To Reproduce Run VRX: ros2 launch vrx_gz competition.launch.py world:=stationkeeping_task

Echo the gz or ros topics to see which transforms are published: ros2 topic echo /tf ros2 topic echo /tf_static gz topic --echo --topic /model/wamv/pose gz topic --echo --topic /model/wamv/pose_static

To generate the transform tree from the URDF, try: ros2 run robot_state_publisher robot_state_publisher ~/vrx_ws/install/share/vrx_gazebo/models/wamv/tmp/model.urdf'

Visualize both sets of frames: ros2 run tf2_tools view_frames

System Configuration: Tell us about your system.

Screenshots What I see in RViz when using robot_state_publisher (joints do not follow motion from Gazebo - all static) Screenshot from 2023-06-26 06-12-39 What I see in Rviz using the transforms from PosePublisher (propellers move correctly following motion in Gazebo) Screenshot from 2023-06-26 09-40-46

Additional notes I am updating the RViz tutorial and related PR to work with only the PosePublisher transforms. I will add notes on how to hide the non-published links from the visualization, because that doesn't seem to be something that loads correctly from the RViz config file. This will work as an interim solution while we decide whether we do want to publish the whole tree and how best to do that.

j-herman commented 1 year ago

I have a temporary fix that will allow RViz to work correctly - added to the RViz PR.
This fix uses the robot_state_publisher to add the missing frames, in the convention (extra wamv/) of PosePublisher.
This is not an ideal solution as we now have multiple nodes publishing the same transform, which is a bad practice, and for the non-static transforms we will occasionally publish incorrect information. I have set the publication frequency very low, and so in practice this seems to work out just fine. See the new TF tree for full, if slightly hack-y, connectivity.

j-herman commented 1 year ago

Light background reading: