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

ros2 lookupTransform() to get latest transform

asked 2022-03-25 02:47:50 -0500

jxl gravatar image

updated 2022-03-25 02:48:49 -0500

Hello all,

In foxy tf2_ros::Buffer::lookupTransform(),

geometry_msgs::msg::TransformStamped 
tf2_ros::Buffer::lookupTransform(const std::string&     target_frame,
                  const std::string&    source_frame,
                  const tf2::TimePoint& time,
                  const tf2::Duration   timeout ) const
 @param time:   The time at which the value of the transform is desired. (0 will get the latest)

We can use tf2::TimePoint(std::chrono::nanoseconds(0)) to get the latest transform. In foxy tf2 namespace

using tf2::Duration = typedef std::chrono::nanoseconds
using tf2::TimePoint = typedef std::chrono::time_point<std::chrono::system_clock, Duration>

tf2::TimePoint use system_clock. Although we can use tf2::TimePoint fromRclcpp(const rclcpp::Time & time) to convert a rclcpp::Time into tf2::TimePoint, rclcpp::Time may be use a ROS time, such as RCL_ROS_TIME time source

inline tf2::TimePoint fromRclcpp(const rclcpp::Time & time)
{
  // tf2::TimePoint is a typedef to a system time point, but rclcpp::Time may be ROS time.
  // Ignore that, and assume the clock used from rclcpp time points is consistent.
  return tf2::TimePoint(std::chrono::nanoseconds(time.nanoseconds()));
}

My question is:
1: Could we directly use rclcpp::Time lookupTransform() version to get latest transform, no need to convert into tf2::TimePoint ?

2: AutowareArchitectureProposal: Replacing tf2_ros::Buffer says there is some bug in tf2_ros::Buffter, is it true ?

Thanks for your help and time!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-03-25 12:19:14 -0500

timRO gravatar image

Hello,

1) I use "tf2::TimePointZero", it give me the last transform. This tutorial can help you : link text

2) I don't have any problems with my foxy version with timeout = 0.

edit flag offensive delete link more

Comments

@timRO, thanks for your help :). tf2::TimePointZero is defined here line=50 btw. Did you meet tf net delay is very big when playing bag data, as this question

jxl gravatar image jxl  ( 2022-03-28 21:22:23 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2022-03-25 02:47:50 -0500

Seen: 3,147 times

Last updated: Mar 25 '22