Skip to content

canTransform does not suppress warning when called with error_msg #405

Open
@mattforestyoung

Description

@mattforestyoung

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions