Fawkes API  Fawkes Development Version
fawkes::TransformAspect Class Reference

Thread aspect to access the transform system. More...

#include <>>

Inheritance diagram for fawkes::TransformAspect:

Public Types

enum  Mode {
  ONLY_LISTENER, ONLY_PUBLISHER, DEFER_PUBLISHER, BOTH,
  BOTH_DEFER_PUBLISHER
}
 Enumeration describing the desired mode of operation. More...
 

Public Member Functions

 TransformAspect (Mode mode=ONLY_LISTENER, const char *frame_id=0)
 Constructor. More...
 
virtual ~TransformAspect ()
 Virtual empty destructor. More...
 
void init_TransformAspect (BlackBoard *blackboard, tf::Transformer *transformer, const char *thread_name)
 Init transform aspect. More...
 
void finalize_TransformAspect ()
 Finalize transform aspect. More...
 
- Public Member Functions inherited from fawkes::Aspect
const std::list< const char * > & get_aspects () const
 Get list of aspect names attached to a aspected thread. More...
 

Protected Member Functions

void tf_enable_publisher (const char *frame_id=0)
 Late enabling of publisher. More...
 
void tf_add_publisher (const char *frame_id_format,...)
 Late add of publisher. More...
 
- Protected Member Functions inherited from fawkes::Aspect
void add_aspect (const char *name)
 Add an aspect to a thread. More...
 

Protected Attributes

tf::Transformertf_listener
 This is the transform listener which saves transforms published by other threads in the system. More...
 
tf::TransformPublishertf_publisher
 This is the transform publisher which can be used to publish transforms via the blackboard. More...
 
std::map< std::string, tf::TransformPublisher * > tf_publishers
 Map of transform publishers created through the aspect. More...
 

Detailed Description

Thread aspect to access the transform system.

Give this aspect to your thread to gain access to the transform library. Depending on the parameters to the ctor only the listener or additionaly the publisher is created. It is guaranteed that if used properly from within plugins that the blackboard member has been initialized properly.

Author
Tim Niemueller

Definition at line 42 of file tf.h.

Member Enumeration Documentation

◆ Mode

Enumeration describing the desired mode of operation.

Enumerator
ONLY_LISTENER 

only create a transform listener

ONLY_PUBLISHER 

only create a transform publisher

DEFER_PUBLISHER 

Create neither listener or publisher, but allow late enabling of a publisher using tf_enable_publisher() or tf_add_publisher() in init().

Note that this requires to pass a valid (unique) tf_bb_iface_id to the constructor.

BOTH 

create both, transform listener and publisher

BOTH_DEFER_PUBLISHER 

create transform listener but defer creation of publisher, cf.

DEFER_PUBLISHER mode documentation above for details.

Definition at line 46 of file tf.h.

Constructor & Destructor Documentation

◆ TransformAspect()

fawkes::TransformAspect::TransformAspect ( Mode  mode = ONLY_LISTENER,
const char *  frame_id = 0 
)

Constructor.

Parameters
modemode of operation
frame_idID of frame to create publisher for, can be zero if creating of publisher is omitted or deferred.

Definition at line 78 of file tf.cpp.

References fawkes::Aspect::add_aspect(), BOTH, BOTH_DEFER_PUBLISHER, DEFER_PUBLISHER, and ONLY_PUBLISHER.

◆ ~TransformAspect()

fawkes::TransformAspect::~TransformAspect ( )
virtual

Virtual empty destructor.

Definition at line 95 of file tf.cpp.

Member Function Documentation

◆ finalize_TransformAspect()

void fawkes::TransformAspect::finalize_TransformAspect ( )

Finalize transform aspect.

This deletes the transform listener and publisher.

Definition at line 227 of file tf.cpp.

References tf_listener, tf_publisher, and tf_publishers.

Referenced by fawkes::TransformAspectIniFin::finalize().

◆ init_TransformAspect()

void fawkes::TransformAspect::init_TransformAspect ( BlackBoard blackboard,
tf::Transformer transformer,
const char *  thread_name 
)

Init transform aspect.

This creates the listener and potentially publisher.

Parameters
blackboardblackboard used to create listener and/or publisher.
transformersystem-wide shared transformer to pass to threads
thread_namename of thread opening publishers

Definition at line 108 of file tf.cpp.

References BOTH, BOTH_DEFER_PUBLISHER, ONLY_LISTENER, ONLY_PUBLISHER, tf_listener, tf_publisher, and tf_publishers.

Referenced by fawkes::TransformAspectIniFin::init().

◆ tf_add_publisher()

void fawkes::TransformAspect::tf_add_publisher ( const char *  frame_id_format,
  ... 
)
protected

Late add of publisher.

If and only if the TransformAspect has been initialized in DEFER_PUBLISHER or BOTH_DEFER_PUBLISHER mode additional transform publishers can be added using this method. It will create a new transform publisher with the given interface ID.

This method is intended to be used if it is unclear at construction time whether the publisher will be needed or not.

Exceptions
Exceptionthrown if the TransformAspect is not initialized in DEFER_PUBLISHER or BOTH_DEFER_PUBLISHER mode.
Parameters
frame_id_formatformat string of interface ID to create. See man printf for accepted patterns. If string starts with / is taken as is, otherwise "/tf/" is prepended to interface ID implicitly.

Definition at line 198 of file tf.cpp.

References BOTH_DEFER_PUBLISHER, DEFER_PUBLISHER, and tf_publishers.

Referenced by RosTfThread::bb_interface_reader_removed(), and StaticTransformsThread::finalize().

◆ tf_enable_publisher()

void fawkes::TransformAspect::tf_enable_publisher ( const char *  frame_id = 0)
protected

Late enabling of publisher.

If and only if the TransformAspect has been initialized in DEFER_PUBLISHER or BOTH_DEFER_PUBLISHER mode the transform publisher can be enabled using this method. It will create a new transform publisher with the interface ID given as constructor parameter.

This method is intended to be used if it is unclear at construction time whether the publisher will be needed or not.

Parameters
frame_idFrame ID to use for publisher. This can only be passed if the frame_id passed to the constructor was null.
Exceptions
Exceptionthrown if the TransformAspect is not initialized in DEFER_PUBLISHER or BOTH_DEFER_PUBLISHER mode.

Definition at line 156 of file tf.cpp.

References BOTH_DEFER_PUBLISHER, DEFER_PUBLISHER, tf_publisher, and tf_publishers.

Referenced by MapLaserGenThread::init(), and RobotinoSimThread::init().

Member Data Documentation

◆ tf_listener

◆ tf_publisher

tf::TransformPublisher * fawkes::TransformAspect::tf_publisher
protected

This is the transform publisher which can be used to publish transforms via the blackboard.

It is only created if the constructor taking the blackboard interface ID parameter is used!

Definition at line 71 of file tf.h.

Referenced by RobotStatePublisherThread::bb_interface_data_changed(), finalize_TransformAspect(), init_TransformAspect(), TfExampleThread::loop(), MapLaserGenThread::loop(), LocalizationSimThread::loop(), RobotinoSimThread::loop(), Bumblebee2Thread::loop(), LaserLinesThread::loop(), RobotStatePublisherThread::loop(), and tf_enable_publisher().

◆ tf_publishers

std::map< std::string, tf::TransformPublisher * > fawkes::TransformAspect::tf_publishers
protected

Map of transform publishers created through the aspect.

The maps key is the blackboard interface ID passed to either the constructor or tf_add_publisher(). The ID is used as passed, i.e., not with the /tf/ prefix which might be added by the TransformPublisher. The singular tf_publisher is also added to the map.

Definition at line 73 of file tf.h.

Referenced by RosTfThread::bb_interface_reader_removed(), StaticTransformsThread::finalize(), finalize_TransformAspect(), init_TransformAspect(), tf_add_publisher(), and tf_enable_publisher().


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