Helper class for transforming data into Ogre's world frame (the fixed frame). More...
#include <frame_manager.h>
Classes | |
struct | CacheEntry |
struct | CacheKey |
Public Types | |
enum | SyncMode { SyncOff = 0, SyncExact, SyncApprox, SyncFrame } |
Signals | |
void | fixedFrameChanged () |
Emitted whenever the fixed frame changes. More... | |
Public Member Functions | |
std::string | discoverFailureReason (const std::string &frame_id, const ros::Time &stamp, const std::string &caller_id, tf2_ros::FilterFailureReason reason) |
bool | frameHasProblems (const std::string &frame, ros::Time time, std::string &error) |
Check to see if a frame exists in our tf buffer. More... | |
FrameManager (std::shared_ptr< tf2_ros::Buffer > tf_buffer=std::shared_ptr< tf2_ros::Buffer >(), std::shared_ptr< tf2_ros::TransformListener > tf_listener=std::shared_ptr< tf2_ros::TransformListener >()) | |
Constructor, will create a TransformListener (and Buffer) automatically if not provided. More... | |
const std::string & | getFixedFrame () |
Return the current fixed frame name. More... | |
bool | getPause () |
SyncMode | getSyncMode () |
const std::shared_ptr< tf2_ros::Buffer > | getTF2BufferPtr () |
ros::Time | getTime () |
Get current time, depending on the sync mode. More... | |
template<typename Header > | |
bool | getTransform (const Header &header, Ogre::Vector3 &position, Ogre::Quaternion &orientation) |
Return the pose for a header, relative to the fixed frame, in Ogre classes. More... | |
bool | getTransform (const std::string &frame, ros::Time time, Ogre::Vector3 &position, Ogre::Quaternion &orientation) |
Return the pose for a frame relative to the fixed frame, in Ogre classes, at a given time. More... | |
template<class M > | |
void | registerFilterForTransformStatusCheck (tf2_ros::MessageFilter< M > *filter, Display *display) |
void | setFixedFrame (const std::string &frame) |
Set the frame to consider "fixed", into which incoming data is transformed. More... | |
void | setPause (bool pause) |
Enable/disable pause mode. More... | |
void | setSyncMode (SyncMode mode) |
Set synchronization mode (off/exact/approximate) More... | |
void | syncTime (ros::Time time) |
Synchronize with given time. More... | |
template<typename Header > | |
bool | transform (const Header &header, const geometry_msgs::Pose &pose, Ogre::Vector3 &position, Ogre::Quaternion &orientation) |
Transform a pose from a frame into the fixed frame. More... | |
bool | transform (const std::string &frame, ros::Time time, const geometry_msgs::Pose &pose, Ogre::Vector3 &position, Ogre::Quaternion &orientation) |
Transform a pose from a frame into the fixed frame. More... | |
bool | transformHasProblems (const std::string &frame, ros::Time time, std::string &error) |
Check to see if a transform is known between a given frame and the fixed frame. More... | |
void | update () |
Clear the internal cache. More... | |
~FrameManager () override | |
Destructor. More... | |
Private Types | |
typedef std::map< CacheKey, CacheEntry > | M_Cache |
Private Member Functions | |
void | adjustTime (ros::Time &time) |
template<class M , class TfFilterFailureReasonType > | |
void | failureCallback (const ros::MessageEvent< M const > &msg_evt, TfFilterFailureReasonType reason, Display *display) |
void | messageArrived (const std::string &frame_id, const ros::Time &stamp, const std::string &caller_id, Display *display) |
template<class M > | |
void | messageCallback (const ros::MessageEvent< M const > &msg_evt, Display *display) |
template<class TfFilterFailureReasonType > | |
void | messageFailed (const std::string &frame_id, const ros::Time &stamp, const std::string &caller_id, TfFilterFailureReasonType reason, Display *display) |
void | messageFailedImpl (const std::string &caller_id, const std::string &status_text, Display *display) |
Private Attributes | |
M_Cache | cache_ |
boost::mutex | cache_mutex_ |
double | current_delta_ |
std::string | fixed_frame_ |
bool | pause_ |
double | sync_delta_ |
SyncMode | sync_mode_ |
ros::Time | sync_time_ |
std::shared_ptr< tf2_ros::Buffer > | tf_buffer_ |
std::shared_ptr< tf2_ros::TransformListener > | tf_listener_ |
Helper class for transforming data into Ogre's world frame (the fixed frame).
During one frame update (nominally 33ms), the tf tree stays consistent and queries are cached for speedup.
Definition at line 64 of file frame_manager.h.
|
private |
Definition at line 302 of file frame_manager.h.
Enumerator | |
---|---|
SyncOff | |
SyncExact | |
SyncApprox | |
SyncFrame |
Definition at line 68 of file frame_manager.h.
|
explicit |
Constructor, will create a TransformListener (and Buffer) automatically if not provided.
Definition at line 42 of file frame_manager.cpp.
|
override |
Destructor.
FrameManager should not need to be destroyed by hand, just destroy the boost::shared_ptr returned by instance(), and it will be deleted when the last reference is removed.
Definition at line 56 of file frame_manager.cpp.
|
private |
Definition at line 152 of file frame_manager.cpp.
std::string rviz::FrameManager::discoverFailureReason | ( | const std::string & | frame_id, |
const ros::Time & | stamp, | ||
const std::string & | caller_id, | ||
tf2_ros::FilterFailureReason | reason | ||
) |
Create a description of a transform problem.
frame_id | The name of the frame with issues. |
stamp | The time for which the problem was detected. |
caller_id | Dummy parameter, not used. |
reason | The reason given by the tf2_ros::MessageFilter in its failure callback. |
Once a problem has been detected with a given frame or transform, call this to get an error message describing the problem.
Definition at line 311 of file frame_manager.cpp.
|
inlineprivate |
Definition at line 245 of file frame_manager.h.
|
signal |
Emitted whenever the fixed frame changes.
bool rviz::FrameManager::frameHasProblems | ( | const std::string & | frame, |
ros::Time | time, | ||
std::string & | error | ||
) |
Check to see if a frame exists in our tf buffer.
[in] | frame | The name of the frame to check. |
[in] | time | Dummy parameter, not actually used. |
[out] | error | If the frame does not exist, an error message is stored here. |
Definition at line 257 of file frame_manager.cpp.
|
inline |
Return the current fixed frame name.
Definition at line 204 of file frame_manager.h.
|
inline |
Definition at line 97 of file frame_manager.h.
|
inline |
Definition at line 105 of file frame_manager.h.
|
inline |
Definition at line 209 of file frame_manager.h.
|
inline |
Get current time, depending on the sync mode.
Definition at line 114 of file frame_manager.h.
|
inline |
Return the pose for a header, relative to the fixed frame, in Ogre classes.
[in] | header | The source of the frame name and time. |
[out] | position | The position of the header frame relative to the fixed frame. |
[out] | orientation | The orientation of the header frame relative to the fixed frame. |
Definition at line 125 of file frame_manager.h.
bool rviz::FrameManager::getTransform | ( | const std::string & | frame, |
ros::Time | time, | ||
Ogre::Vector3 & | position, | ||
Ogre::Quaternion & | orientation | ||
) |
Return the pose for a frame relative to the fixed frame, in Ogre classes, at a given time.
[in] | frame | The frame to find the pose of. |
[in] | time | The time at which to get the pose. |
[out] | position | The position of the frame relative to the fixed frame. |
[out] | orientation | The orientation of the frame relative to the fixed frame. |
Definition at line 171 of file frame_manager.cpp.
|
private |
Definition at line 334 of file frame_manager.cpp.
|
inlineprivate |
Definition at line 236 of file frame_manager.h.
|
inlineprivate |
Definition at line 263 of file frame_manager.h.
|
private |
Definition at line 342 of file frame_manager.cpp.
|
inline |
Connect success and failure callbacks to a tf2_ros::MessageFilter.
filter | The tf2_ros::MessageFilter to connect to. |
display | The Display using the filter. |
FrameManager has internal functions for handling success and failure of tf2_ros::MessageFilters, which call Display::setStatus() based on success or failure of the filter, including appropriate error messages.
Definition at line 194 of file frame_manager.h.
void rviz::FrameManager::setFixedFrame | ( | const std::string & | frame | ) |
Set the frame to consider "fixed", into which incoming data is transformed.
The fixed frame serves as the reference for all getTransform() and transform() functions in FrameManager.
Definition at line 91 of file frame_manager.cpp.
void rviz::FrameManager::setPause | ( | bool | pause | ) |
Enable/disable pause mode.
Definition at line 110 of file frame_manager.cpp.
void rviz::FrameManager::setSyncMode | ( | SyncMode | mode | ) |
Set synchronization mode (off/exact/approximate)
Definition at line 115 of file frame_manager.cpp.
void rviz::FrameManager::syncTime | ( | ros::Time | time | ) |
Synchronize with given time.
Definition at line 123 of file frame_manager.cpp.
|
inline |
Transform a pose from a frame into the fixed frame.
[in] | header | The source of the input frame and time. |
[in] | pose | The input pose, relative to the header frame. |
[out] | position | Position part of pose relative to the fixed frame. |
[out] | orientation | Orientation part of pose relative to the fixed frame. |
Definition at line 148 of file frame_manager.h.
bool rviz::FrameManager::transform | ( | const std::string & | frame, |
ros::Time | time, | ||
const geometry_msgs::Pose & | pose, | ||
Ogre::Vector3 & | position, | ||
Ogre::Quaternion & | orientation | ||
) |
Transform a pose from a frame into the fixed frame.
[in] | frame | The input frame. |
[in] | time | The time at which to get the pose. |
[in] | pose | The input pose, relative to the input frame. |
[out] | position | Position part of pose relative to the fixed frame. |
[out] | orientation | Orientation part of pose relative to the fixed frame. |
Definition at line 209 of file frame_manager.cpp.
bool rviz::FrameManager::transformHasProblems | ( | const std::string & | frame, |
ros::Time | time, | ||
std::string & | error | ||
) |
Check to see if a transform is known between a given frame and the fixed frame.
[in] | frame | The name of the frame to check. |
[in] | time | The time at which the transform is desired. |
[out] | error | If the transform is not known, an error message is stored here. |
Definition at line 272 of file frame_manager.cpp.
void rviz::FrameManager::update | ( | ) |
Clear the internal cache.
Definition at line 60 of file frame_manager.cpp.
|
private |
Definition at line 305 of file frame_manager.h.
|
private |
Definition at line 304 of file frame_manager.h.
|
private |
Definition at line 319 of file frame_manager.h.
|
private |
Definition at line 309 of file frame_manager.h.
|
private |
Definition at line 311 of file frame_manager.h.
|
private |
Definition at line 320 of file frame_manager.h.
|
private |
Definition at line 313 of file frame_manager.h.
|
private |
Definition at line 316 of file frame_manager.h.
|
private |
Definition at line 307 of file frame_manager.h.
|
private |
Definition at line 308 of file frame_manager.h.