tf2
master
tf2 maintains the relationship between coordinate frames in a tree structure buffered in time, and lets the user transform points, vectors, etc between any two coordinate frames at any desired point in time.
|
A Class which provides coordinate transforms between any two frames in a system. More...
#include <buffer_core.h>
Public Types | |
using | TransformableCallback = std::function< void(TransformableRequestHandle request_handle, const std::string &target_frame, const std::string &source_frame, TimePoint time, TransformableResult result)> |
Public Member Functions | |
BufferCore (tf2::Duration cache_time_=BUFFER_CORE_DEFAULT_CACHE_TIME) | |
virtual | ~BufferCore (void) |
void | clear () override |
Clear all data. More... | |
bool | setTransform (const geometry_msgs::msg::TransformStamped &transform, const std::string &authority, bool is_static=false) |
Add transform information to the tf data structure. More... | |
geometry_msgs::msg::TransformStamped | lookupTransform (const std::string &target_frame, const std::string &source_frame, const TimePoint &time) const override |
Get the transform between two frames by frame ID. More... | |
geometry_msgs::msg::TransformStamped | lookupTransform (const std::string &target_frame, const TimePoint &target_time, const std::string &source_frame, const TimePoint &source_time, const std::string &fixed_frame) const override |
Get the transform between two frames by frame ID assuming fixed frame. More... | |
bool | canTransform (const std::string &target_frame, const std::string &source_frame, const TimePoint &time, std::string *error_msg=NULL) const override |
Test if a transform is possible. More... | |
bool | canTransform (const std::string &target_frame, const TimePoint &target_time, const std::string &source_frame, const TimePoint &source_time, const std::string &fixed_frame, std::string *error_msg=NULL) const override |
Test if a transform is possible. More... | |
std::vector< std::string > | getAllFrameNames () const override |
Get all frames that exist in the system. More... | |
std::string | allFramesAsYAML (TimePoint current_time) const |
A way to see what frames have been cached in yaml format Useful for debugging tools. More... | |
std::string | allFramesAsYAML () const |
std::string | allFramesAsString () const |
A way to see what frames have been cached Useful for debugging. More... | |
TransformableRequestHandle | addTransformableRequest (const TransformableCallback &cb, const std::string &target_frame, const std::string &source_frame, TimePoint time) |
Internal use only. More... | |
void | cancelTransformableRequest (TransformableRequestHandle handle) |
Internal use only. More... | |
void | setUsingDedicatedThread (bool value) |
bool | isUsingDedicatedThread () const |
bool | _frameExists (const std::string &frame_id_str) const |
Check if a frame exists in the tree. More... | |
bool | _getParent (const std::string &frame_id, TimePoint time, std::string &parent) const |
Fill the parent of a frame. More... | |
void | _getFrameStrings (std::vector< std::string > &ids) const |
A way to get a std::vector of available frame ids. More... | |
CompactFrameID | _lookupFrameNumber (const std::string &frameid_str) const |
CompactFrameID | _lookupOrInsertFrameNumber (const std::string &frameid_str) |
tf2::TF2Error | _getLatestCommonTime (CompactFrameID target_frame, CompactFrameID source_frame, TimePoint &time, std::string *error_string) const |
CompactFrameID | _validateFrameId (const char *function_name_arg, const std::string &frame_id) const |
tf2::Duration | getCacheLength () |
Get the duration over which this transformer will cache. More... | |
std::string | _allFramesAsDot (TimePoint current_time) const |
Backwards compatabilityA way to see what frames have been cached Useful for debugging. More... | |
std::string | _allFramesAsDot () const |
void | _chainAsVector (const std::string &target_frame, TimePoint target_time, const std::string &source_frame, TimePoint source_time, const std::string &fixed_frame, std::vector< std::string > &output) const |
Backwards compatabilityA way to see what frames are in a chain Useful for debugging. More... | |
Public Member Functions inherited from tf2::BufferCoreInterface | |
virtual | ~BufferCoreInterface ()=default |
Static Public Attributes | |
static const uint32_t | MAX_GRAPH_DEPTH = 1000UL |
< Maximum graph search depth (deeper graphs will be assumed to have loops) More... | |
A Class which provides coordinate transforms between any two frames in a system.
This class provides a simple interface to allow recording and lookup of relationships between arbitrary frames of the system.
libTF assumes that there is a tree of coordinate frame transforms which define the relationship between all coordinate frames. For example your typical robot would have a transform from global to real world. And then from base to hand, and from base to head. But Base to Hand really is composed of base to shoulder to elbow to wrist to hand. libTF is designed to take care of all the intermediate steps for you.
Internal Representation libTF will store frames with the parameters necessary for generating the transform into that frame from it's parent and a reference to the parent frame. Frames are designated using an std::string 0 is a frame without a parent (the top of a tree) The positions of frames over time must be pushed in.
All function calls which pass frame ids can potentially throw the exception tf::LookupException
using tf2::BufferCore::TransformableCallback = std::function< void (TransformableRequestHandle request_handle, const std::string & target_frame, const std::string & source_frame, TimePoint time, TransformableResult result)> |
|
explicit |
Constructor
interpolating | Whether to interpolate, if this is false the closest value will be returned |
cache_time | How long to keep a history of transforms in nanoseconds |
|
virtual |
|
overridevirtual |
Clear all data.
Implements tf2::BufferCoreInterface.
bool tf2::BufferCore::setTransform | ( | const geometry_msgs::msg::TransformStamped & | transform, |
const std::string & | authority, | ||
bool | is_static = false |
||
) |
Add transform information to the tf data structure.
transform | The transform to store |
authority | The source of the information for this transform |
is_static | Record this transform as a static transform. It will be good across all time. (This cannot be changed after the first call.) |
|
overridevirtual |
Get the transform between two frames by frame ID.
target_frame | The frame to which data should be transformed |
source_frame | The frame where the data originated |
time | The time at which the value of the transform is desired. (0 will get the latest) |
Possible exceptions tf2::LookupException, tf2::ConnectivityException, tf2::ExtrapolationException, tf2::InvalidArgumentException
Implements tf2::BufferCoreInterface.
|
overridevirtual |
Get the transform between two frames by frame ID assuming fixed frame.
target_frame | The frame to which data should be transformed |
target_time | The time to which the data should be transformed. (0 will get the latest) |
source_frame | The frame where the data originated |
source_time | The time at which the source_frame should be evaluated. (0 will get the latest) |
fixed_frame | The frame in which to assume the transform is constant in time. |
Possible exceptions tf2::LookupException, tf2::ConnectivityException, tf2::ExtrapolationException, tf2::InvalidArgumentException
Implements tf2::BufferCoreInterface.
|
overridevirtual |
Test if a transform is possible.
target_frame | The frame into which to transform |
source_frame | The frame from which to transform |
time | The time at which to transform |
error_msg | A pointer to a string which will be filled with why the transform failed, if not NULL |
Implements tf2::BufferCoreInterface.
|
overridevirtual |
Test if a transform is possible.
target_frame | The frame into which to transform |
target_time | The time into which to transform |
source_frame | The frame from which to transform |
source_time | The time from which to transform |
fixed_frame | The frame in which to treat the transform as constant in time |
error_msg | A pointer to a string which will be filled with why the transform failed, if not NULL |
Implements tf2::BufferCoreInterface.
|
overridevirtual |
Get all frames that exist in the system.
Implements tf2::BufferCoreInterface.
std::string tf2::BufferCore::allFramesAsYAML | ( | TimePoint | current_time | ) | const |
A way to see what frames have been cached in yaml format Useful for debugging tools.
std::string tf2::BufferCore::allFramesAsYAML | ( | ) | const |
Backwards compatibility for #84
std::string tf2::BufferCore::allFramesAsString | ( | ) | const |
A way to see what frames have been cached Useful for debugging.
TransformableRequestHandle tf2::BufferCore::addTransformableRequest | ( | const TransformableCallback & | cb, |
const std::string & | target_frame, | ||
const std::string & | source_frame, | ||
TimePoint | time | ||
) |
Internal use only.
void tf2::BufferCore::cancelTransformableRequest | ( | TransformableRequestHandle | handle | ) |
Internal use only.
|
inline |
|
inline |
bool tf2::BufferCore::_frameExists | ( | const std::string & | frame_id_str | ) | const |
Check if a frame exists in the tree.
frame_id_str | The frame id in question |
bool tf2::BufferCore::_getParent | ( | const std::string & | frame_id, |
TimePoint | time, | ||
std::string & | parent | ||
) | const |
Fill the parent of a frame.
frame_id | The frame id of the frame in question |
parent | The reference to the string to fill the parent Returns true unless "NO_PARENT" |
void tf2::BufferCore::_getFrameStrings | ( | std::vector< std::string > & | ids | ) | const |
A way to get a std::vector of available frame ids.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the duration over which this transformer will cache.
std::string tf2::BufferCore::_allFramesAsDot | ( | TimePoint | current_time | ) | const |
Backwards compatabilityA way to see what frames have been cached Useful for debugging.
std::string tf2::BufferCore::_allFramesAsDot | ( | ) | const |
void tf2::BufferCore::_chainAsVector | ( | const std::string & | target_frame, |
TimePoint | target_time, | ||
const std::string & | source_frame, | ||
TimePoint | source_time, | ||
const std::string & | fixed_frame, | ||
std::vector< std::string > & | output | ||
) | const |
Backwards compatabilityA way to see what frames are in a chain Useful for debugging.
|
static |
< Maximum graph search depth (deeper graphs will be assumed to have loops)