From 3d8b5518a17955f402dc5c78eff1c9402f9f064c Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Wed, 5 Oct 2022 11:40:28 -0700 Subject: [PATCH] Document tf2::TimePoint vs rclcpp::Time (#3079) * Document tf2::TimePoint vs rclcpp::Time Signed-off-by: Shane Loretz --- .../Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst index 021016bf460..c1514802181 100644 --- a/source/Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst @@ -44,6 +44,14 @@ Open ``turtle_tf2_listener.cpp`` and take a look at the ``lookupTransform()`` ca tf2::TimePointZero); You can see that we specified a time equal to 0 by calling ``tf2::TimePointZero``. + +.. note:: + + The ``tf2`` package has it's own time type ``tf2::TimePoint``, which is different from ``rclcpp::Time``. + Many APIs in the package ``tf2_ros`` automatically convert between ``rclcpp::Time`` and ``tf2::TimePoint``. + + ``rclcpp::Time(0, 0, this->get_clock()->get_clock_type())`` could have been used here, but it would have been converted to ``tf2::TimePointZero`` anyways. + For tf2, time 0 means "the latest available" transform in the buffer. Now, change this line to get the transform at the current time, ``this->get_clock()->now()``: