ArduPilot / ardupilot_gz

Tools for ArduPilot ROS2 integration and testing on ROS 2 humble
GNU General Public License v3.0
31 stars 22 forks source link

Rviz reports invalid frame ID #30

Closed haavarpb closed 1 year ago

haavarpb commented 1 year ago

Hi,

when I do ros2 launch ardupilot_gz_bringup iris_runway.launch.py I get spammed by rviz with this message:

[rviz2-8] Warning: Invalid frame ID "iris/odom" passed to canTransform argument target_frame - frame does not exist
[rviz2-8]          at line 93 in ./src/buffer_core.cpp

Also, RVIZ starts misconfigured:

image

I could fix this by updating the Global Options Fixed Frame from iris/odom to base_link, and removing the Robot Model TF Prefix from iris to empty:

image

After this change the aforementioned spamming continues, but with a different message

[rviz2-8] [INFO] [1694529493.830705912] [rviz]: Message Filter dropping message: frame 'iris/odom' at time 113.380 for reason 'discarding message because the queue is full'

Either the .rviz-config file is not set up correctly or some topics are incorrectly mapped.

srmainwaring commented 1 year ago

Hi @haavarpb. I can replicate the issue. It appears that recent changes to the remapping of tf generated by robot_state_publisher and ros_gz_bridge and the dropping of tf_prefix is causing this issue. Will work on a fix.

Update

Some further details on why the odom -> base_link TF has been lost and what needs to happen to re-enable it.

  1. We want to have a TF tree that complies to REP 105. This states that the mobile base should contain a frame called base_link and that there should be a continuous in time transform from the frame odom: odom -> base_link.
  2. In the examples provided in this repo we are not using separate localisation or odometry systems - Gazebo can provide odometry for the robot by including the system gz::sim::systems::OdometryPublisher. The system publishes the pose from the frame given in <odom_frame> to <robot_base_frame> then adds to the poses published to the topic /model/{model_name}/pose. The initial version (15fb43c) uses TF prefixes and set the robot base to be the name given to the model in the world file, however this does not conform to REP 105.

Change required: modify the plugin XML in the model.sdf files to:

<plugin
  filename="gz-sim-odometry-publisher-system"
  name="gz::sim::systems::OdometryPublisher">
  <odom_frame>odom</odom_frame>
  <robot_base_frame>base_link</robot_base_frame>
  <dimensions>3</dimensions>
</plugin>
  1. The initial version (15fb43c) uses the TF published directly by Gazebo via the ros_gz_bridge to build the TF tree. The TF from the robot_state_publisher is mapped to /ignore/tf to avoid conflicts. The TF also used a prefix iris.
  2. The current version uses robot_state_publisher as the authority for TF. It obtains the joint state data from the /joint_states topic published by ros_gz_bridge, however this does not include odometry. No TF prefix is used.

Change required: we need to extract the TF odom -> base_link from /gz/tf and publish to tf. This will require a message filter of some sort.

topic_tools transform will do:

ros2 run topic_tools transform /gz/tf /tf tf2_msgs/msg/TFMessage "tf2_msgs.msg.TFMessage(transforms=[x for x in m.transforms if x.header.frame_id == 'odom'])" --import tf2_msgs geometry_msgs

The remaining issue to resolve is to remove any messages containing an empty transform from the filtered output as this causes the following warning in AP_DDS:

--sitl 127.0.0.1:5501 --non-interactive -5] AP: Received tf2_msgs/TFMessage: Insufficient size 

Figure: resulting TF tree with topic_tools transform filter tf-frames