ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

lookupTransform - builtin_interfaces/Time to tf2::TimePoint?

asked 2018-12-04 14:03:53 -0600

lucasw gravatar image

I'd like to use the header stamp in a call to lookupTransform and assume that a conversion would happen automatically, but I'm getting no matching function call build errors. Is there a header to include that will handle this, or is it not implemented yet and I have to convert it manually?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2018-12-04 18:52:08 -0600

lucasw gravatar image

The manual conversion:

builtin_interfaces::msg::Time time_stamp = msg->header.stamp;
tf2::TimePoint time_point = tf2::TimePoint(
    std::chrono::seconds(time_stamp.sec) +
    std::chrono::nanoseconds(time_stamp.nanosec));
geometry_msgs::msg::TransformStamped tf = buffer_.lookupTransform(
    frame1, frame2, time_point)
edit flag offensive delete link more
2

answered 2019-12-18 10:53:51 -0600

ahcorde gravatar image

You can use these functions form tf2_ros/buffer_interface.h:

  • TimePoint to builtin_interfaces::msg::Time

    inline builtin_interfaces::msg::Time toMsg(const tf2::TimePoint & t)

  • builtin_interfaces::msg::Time to TimePoint

    inline const tf2::TimePoint& fromMsg(const builtin_interfaces::msg::Time & time_msg)

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-12-04 14:03:53 -0600

Seen: 2,455 times

Last updated: Dec 04 '18