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.
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
tf2::BufferCore Class Reference

A Class which provides coordinate transforms between any two frames in a system. More...

#include <buffer_core.h>

Inheritance diagram for tf2::BufferCore:
Inheritance graph
[legend]
Collaboration diagram for tf2::BufferCore:
Collaboration graph
[legend]

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
 Lookup the twist of the tracking_frame with respect to the observation frame in the reference_frame using the reference point. 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::stringgetAllFrameNames () 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...
 
TransformableCallbackHandle addTransformableCallback (const TransformableCallback &cb)
 Internal use only. More...
 
void removeTransformableCallback (TransformableCallbackHandle handle)
 Internal use only. More...
 
TransformableRequestHandle addTransformableRequest (TransformableCallbackHandle handle, 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...
 

Detailed Description

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

Member Typedef Documentation

◆ TransformableCallback

using tf2::BufferCore::TransformableCallback = std::function<void(TransformableRequestHandle request_handle, const std::string& target_frame, const std::string& source_frame, TimePoint time, TransformableResult result)>

Constructor & Destructor Documentation

◆ BufferCore()

tf2::BufferCore::BufferCore ( tf2::Duration  cache_time_ = BUFFER_CORE_DEFAULT_CACHE_TIME)

Constructor

Parameters
interpolatingWhether to interpolate, if this is false the closest value will be returned
cache_timeHow long to keep a history of transforms in nanoseconds

◆ ~BufferCore()

virtual tf2::BufferCore::~BufferCore ( void  )
virtual

Member Function Documentation

◆ clear()

void tf2::BufferCore::clear ( )
overridevirtual

Clear all data.

Implements tf2::BufferCoreInterface.

◆ setTransform()

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.

Parameters
transformThe transform to store
authorityThe source of the information for this transform
is_staticRecord this transform as a static transform. It will be good across all time. (This cannot be changed after the first call.)
Returns
True unless an error occured

◆ lookupTransform() [1/2]

geometry_msgs::msg::TransformStamped tf2::BufferCore::lookupTransform ( const std::string target_frame,
const std::string source_frame,
const TimePoint time 
) const
overridevirtual

Get the transform between two frames by frame ID.

Parameters
target_frameThe frame to which data should be transformed
source_frameThe frame where the data originated
timeThe time at which the value of the transform is desired. (0 will get the latest)
Returns
The transform between the frames

Possible exceptions tf2::LookupException, tf2::ConnectivityException, tf2::ExtrapolationException, tf2::InvalidArgumentException

Implements tf2::BufferCoreInterface.

◆ lookupTransform() [2/2]

geometry_msgs::msg::TransformStamped tf2::BufferCore::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
overridevirtual

Get the transform between two frames by frame ID assuming fixed frame.

Parameters
target_frameThe frame to which data should be transformed
target_timeThe time to which the data should be transformed. (0 will get the latest)
source_frameThe frame where the data originated
source_timeThe time at which the source_frame should be evaluated. (0 will get the latest)
fixed_frameThe frame in which to assume the transform is constant in time.
Returns
The transform between the frames

Possible exceptions tf2::LookupException, tf2::ConnectivityException, tf2::ExtrapolationException, tf2::InvalidArgumentException

Implements tf2::BufferCoreInterface.

◆ canTransform() [1/2]

bool tf2::BufferCore::canTransform ( const std::string target_frame,
const std::string source_frame,
const TimePoint time,
std::string error_msg = NULL 
) const
overridevirtual

Lookup the twist of the tracking_frame with respect to the observation frame in the reference_frame using the reference point.

Parameters
tracking_frameThe frame to track
observation_frameThe frame from which to measure the twist
reference_frameThe reference frame in which to express the twist
reference_pointThe reference point with which to express the twist
reference_point_frameThe frame_id in which the reference point is expressed
timeThe time at which to get the velocity
durationThe period over which to average
Returns
twist The twist output

This will compute the average velocity on the interval (time - duration/2, time+duration/2). If that is too close to the most recent reading, in which case it will shift the interval up to duration/2 to prevent extrapolation.

Possible exceptions tf2::LookupException, tf2::ConnectivityException, tf2::ExtrapolationException, tf2::InvalidArgumentException

New in geometry 1.1

lookup the twist of the tracking frame with respect to the observational frame

This is a simplified version of lookupTwist with it assumed that the reference point is the origin of the tracking frame, and the reference frame is the observation frame.

Possible exceptions tf2::LookupException, tf2::ConnectivityException, tf2::ExtrapolationException, tf2::InvalidArgumentException

New in geometry 1.1

Test if a transform is possible

Parameters
target_frameThe frame into which to transform
source_frameThe frame from which to transform
timeThe time at which to transform
error_msgA pointer to a string which will be filled with why the transform failed, if not NULL
Returns
True if the transform is possible, false otherwise

Implements tf2::BufferCoreInterface.

◆ canTransform() [2/2]

bool tf2::BufferCore::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
overridevirtual

Test if a transform is possible.

Parameters
target_frameThe frame into which to transform
target_timeThe time into which to transform
source_frameThe frame from which to transform
source_timeThe time from which to transform
fixed_frameThe frame in which to treat the transform as constant in time
error_msgA pointer to a string which will be filled with why the transform failed, if not NULL
Returns
True if the transform is possible, false otherwise

Implements tf2::BufferCoreInterface.

◆ getAllFrameNames()

std::vector<std::string> tf2::BufferCore::getAllFrameNames ( ) const
overridevirtual

Get all frames that exist in the system.

Implements tf2::BufferCoreInterface.

◆ allFramesAsYAML() [1/2]

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.

◆ allFramesAsYAML() [2/2]

std::string tf2::BufferCore::allFramesAsYAML ( ) const

Backwards compatibility for #84

◆ allFramesAsString()

std::string tf2::BufferCore::allFramesAsString ( ) const

A way to see what frames have been cached Useful for debugging.

◆ addTransformableCallback()

TransformableCallbackHandle tf2::BufferCore::addTransformableCallback ( const TransformableCallback cb)

Internal use only.

◆ removeTransformableCallback()

void tf2::BufferCore::removeTransformableCallback ( TransformableCallbackHandle  handle)

Internal use only.

◆ addTransformableRequest()

TransformableRequestHandle tf2::BufferCore::addTransformableRequest ( TransformableCallbackHandle  handle,
const std::string target_frame,
const std::string source_frame,
TimePoint  time 
)

Internal use only.

◆ cancelTransformableRequest()

void tf2::BufferCore::cancelTransformableRequest ( TransformableRequestHandle  handle)

Internal use only.

◆ setUsingDedicatedThread()

void tf2::BufferCore::setUsingDedicatedThread ( bool  value)
inline

◆ isUsingDedicatedThread()

bool tf2::BufferCore::isUsingDedicatedThread ( ) const
inline

◆ _frameExists()

bool tf2::BufferCore::_frameExists ( const std::string frame_id_str) const

Check if a frame exists in the tree.

Parameters
frame_id_strThe frame id in question

◆ _getParent()

bool tf2::BufferCore::_getParent ( const std::string frame_id,
TimePoint  time,
std::string parent 
) const

Fill the parent of a frame.

Parameters
frame_idThe frame id of the frame in question
parentThe reference to the string to fill the parent Returns true unless "NO_PARENT"

◆ _getFrameStrings()

void tf2::BufferCore::_getFrameStrings ( std::vector< std::string > &  ids) const

A way to get a std::vector of available frame ids.

◆ _lookupFrameNumber()

CompactFrameID tf2::BufferCore::_lookupFrameNumber ( const std::string frameid_str) const
inline

◆ _lookupOrInsertFrameNumber()

CompactFrameID tf2::BufferCore::_lookupOrInsertFrameNumber ( const std::string frameid_str)
inline

◆ _getLatestCommonTime()

tf2::TF2Error tf2::BufferCore::_getLatestCommonTime ( CompactFrameID  target_frame,
CompactFrameID  source_frame,
TimePoint time,
std::string error_string 
) const
inline

◆ _validateFrameId()

CompactFrameID tf2::BufferCore::_validateFrameId ( const char *  function_name_arg,
const std::string frame_id 
) const
inline

◆ getCacheLength()

tf2::Duration tf2::BufferCore::getCacheLength ( )
inline

Get the duration over which this transformer will cache.

◆ _allFramesAsDot() [1/2]

std::string tf2::BufferCore::_allFramesAsDot ( TimePoint  current_time) const

Backwards compatabilityA way to see what frames have been cached Useful for debugging.

◆ _allFramesAsDot() [2/2]

std::string tf2::BufferCore::_allFramesAsDot ( ) const

◆ _chainAsVector()

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.

Member Data Documentation

◆ MAX_GRAPH_DEPTH

const uint32_t tf2::BufferCore::MAX_GRAPH_DEPTH = 1000UL
static

Maximum graph search depth (deeper graphs will be assumed to have loops)


The documentation for this class was generated from the following file: