Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RViz fails to display messages with timestamps slightly in the future #1284

Open
rayferric opened this issue Oct 6, 2024 · 0 comments
Open
Assignees

Comments

@rayferric
Copy link

RViz fails to display messages with timestamps slightly in the future

RViz skips displaying messages with timestamps a few milliseconds into the future, showing a vague error message:

void Display::setMissingTransformToFixedFrame(
const std::string & frame, const std::string & additional_info)
{
std::string error_string =
"Could not transform " + (additional_info.empty() ? "from [" : additional_info + " from [") +
frame + "] to [" + fixed_frame_.toStdString() + "]";
setStatusStd(properties::StatusProperty::Error, "Transform", error_string);
}

Upon investigation, I traced the issue to the TFWrapper class, where TF2 is queried without any fallback in case of an ExtrapolationError:

void TFWrapper::transform(
const geometry_msgs::msg::PoseStamped & pose_in,
geometry_msgs::msg::PoseStamped & pose_out,
const std::string & frame)
{
buffer_->transform(pose_in, pose_out, frame);
}

RViz handles messages slightly in the past correctly, so it’s unclear why messages with timestamps slightly in the future are not displayed. While TF2 may seem like the cause, it is reasonable to expect users to handle extrapolation themselves.

Possible Solutions

  1. Message History: RViz could maintain a history of messages and display the most recent message that can be transformed without extrapolation.
  2. Extrapolation by RViz: RViz could extrapolate the transform itself.
  3. Skip Extrapolation: If TF2 fails with tf2::ExtrapolationException, simply use the latest available transform in the TF buffer.

Proposed Solution (Option 3)

Here’s a potential fix using the third approach:

void TFWrapper::transform(
  const geometry_msgs::msg::PoseStamped & pose_in,
  geometry_msgs::msg::PoseStamped & pose_out,
  const std::string & frame)
{
  try {
    buffer_->transform(pose_in, pose_out, frame);
  } catch (const tf2::ExtrapolationException & exception) {
    (void) exception;
    geometry_msgs::msg::PoseStamped zero_pose = pose_in;
    zero_pose.header.stamp = rclcpp::Time(0);
    buffer_->transform(zero_pose, pose_out, frame);
  }
}

Similar changes would need to be applied to other TFWrapper methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants