0
$\begingroup$

Rosanswers logo

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!


Originally posted by jxl on ROS Answers with karma: 252 on 2022-03-25

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by timRO with karma: 26 on 2022-03-25

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by jxl on 2022-03-28:
@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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.