ros2 / ros2/geometry2

canTransform does not suppress warning when called with error_msg

Open
#405 2 comments 1 reaction 1 assignee View on GitHub

@ahcorde is already working on this.

Since May 13, 2021.

Dominant language
C++
Stars
153
Forks
256
Avg merge
3d 23h
Merged PRs (30d)
14

Description

Bug report

Required Info:

  • Operating System:
    • Ubuntu 18.04
  • Installation type:
    • ROS2 Foxy, installed in Docker container osrf/ros:foxy-desktop from hub.docker.com
  • Version or commit hash:

I'm trying to find a work-around for the issue described in several Github issues, and addressed in issue #396, where calling canTransform directly or indirectly through lookupTransform results in an error message being spammed to the terminal.

In the process of looking for a way to suppress this output, I found this comment by tfoote in issue #358. The error is generated by function fillOrWarnMessageForInvalidFrame in buffer_core.cpp, and tfoote's comment suggests that calling canTransform with the error_msg parameter != nullptr will result in the function filling the error_msg string instead of generating the error message (i.e. the error message is no longer spammed to terminal and is instead handed to the caller to deal with). And if we look at the code for this:

if (error_msg != nullptr) {
  *error_msg = s;
} else {
  CONSOLE_BRIDGE_logWarn("%s", s.c_str());
}

unless I am missing something, this does seem to be how this code should work. But it doesn't. I still see the error (see below)

Steps to reproduce issue
std::string suppressed_error = "dummy_str";
if (buffer->canTransform(
    target_frame,
    source_frame,
    rclcpp::Time(0),
    frame_timeout,
    &suppressed_error))
{
    std::cout<< "Found " << target_frame << " -> " << source_frame << " transform" << std::endl;
}
Expected behavior

I expect the call to CONSOLE_BRIDGE_logWarn to not be printed because the error_msg is non-null. So I expect to just see this:

[tf_broadcaster_exe-1] Found base_link -> map transform
Actual behavior

Instead I see the same error message being spammed until the transform is found:

[tf_broadcaster_exe-1] Warning: Invalid frame ID "map" passed to canTransform argument target_frame - frame does not exist
[tf_broadcaster_exe-1]          at line 133 in /tmp/binarydeb/ros-foxy-tf2-0.13.9/src/buffer_core.cpp
[tf_broadcaster_exe-1] Warning: Invalid frame ID "map" passed to canTransform argument target_frame - frame does not exist
[tf_broadcaster_exe-1]          at line 133 in /tmp/binarydeb/ros-foxy-tf2-0.13.9/src/buffer_core.cpp
[tf_broadcaster_exe-1] Warning: Invalid frame ID "map" passed to canTransform argument target_frame - frame does not exist
[tf_broadcaster_exe-1]          at line 133 in /tmp/binarydeb/ros-foxy-tf2-0.13.9/src/buffer_core.cpp
[tf_broadcaster_exe-1] Warning: Invalid frame ID "map" passed to canTransform argument target_frame - frame does not exist
[tf_broadcaster_exe-1]          at line 133 in /tmp/binarydeb/ros-foxy-tf2-0.13.9/src/buffer_core.cpp
[tf_broadcaster_exe-1] Found base_link -> map transform

I'm sure this is a bug, but I haven't yet identified the cause.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.