Fawkes API  Fawkes Development Version
tf.h
1 
2 /***************************************************************************
3  * tf.h - Transform aspect for Fawkes
4  *
5  * Created: Tue Oct 25 21:33:21 2011
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version. A runtime exception applies to
13  * this software (see LICENSE.GPL_WRE file mentioned below for details).
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
21  */
22 
23 #ifndef __ASPECT_TF_H_
24 #define __ASPECT_TF_H_
25 
26 #ifndef HAVE_TF
27 # error TF not available. Forgot to add CFLAGS_TF?
28 #endif
29 
30 #include <aspect/aspect.h>
31 #include <tf/transformer.h>
32 #include <tf/transform_publisher.h>
33 
34 namespace fawkes {
35 
36  class BlackBoard;
37 
38 #if 0 /* just to make Emacs auto-indent happy */
39 }
40 #endif
41 
42 class TransformAspect : public virtual Aspect
43 {
44  public:
45  /** Enumeration describing the desired mode of operation. */
46  typedef enum {
47  ONLY_LISTENER, ///< only create a transform listener
48  ONLY_PUBLISHER, ///< only create a transform publisher
49  DEFER_PUBLISHER, /**< Create neither listener or publisher, but allow late
50  * enabling of a publisher using tf_enable_publisher() or tf_add_publisher() in init().
51  * Note that this requires to pass a valid (unique) tf_bb_iface_id
52  * to the constructor. */
53  BOTH, ///< create both, transform listener and publisher
54  BOTH_DEFER_PUBLISHER /**< create transform listener but defer creation of publisher,
55  * cf. DEFER_PUBLISHER mode documentation above for details. */
56  } Mode;
57 
58  TransformAspect(Mode mode = ONLY_LISTENER, const char *frame_id = 0);
59  virtual ~TransformAspect();
60 
61  void init_TransformAspect(BlackBoard *blackboard, tf::Transformer *transformer,
62  const char *thread_name);
64 
65  protected: // methods
66  void tf_enable_publisher(const char *frame_id = 0);
67  void tf_add_publisher(const char *frame_id_format, ...);
68 
69  protected: // members
72 
73  std::map<std::string, tf::TransformPublisher *> tf_publishers;
74 
75  private:
76  Mode __tf_aspect_mode;
77  char *__tf_aspect_frame_id;
78  BlackBoard *__tf_aspect_blackboard;
79 };
80 
81 } // end namespace fawkes
82 
83 #endif
create transform listener but defer creation of publisher, cf.
Definition: tf.h:54
only create a transform publisher
Definition: tf.h:48
tf::TransformPublisher * tf_publisher
This is the transform publisher which can be used to publish transforms via the blackboard.
Definition: tf.h:71
Fawkes aspect base class.
Definition: aspect.h:34
Fawkes library namespace.
TransformAspect(Mode mode=ONLY_LISTENER, const char *frame_id=0)
Constructor.
Definition: tf.cpp:78
Mode
Enumeration describing the desired mode of operation.
Definition: tf.h:46
Thread aspect to access the transform system.
Definition: tf.h:42
virtual ~TransformAspect()
Virtual empty destructor.
Definition: tf.cpp:95
only create a transform listener
Definition: tf.h:47
std::map< std::string, tf::TransformPublisher * > tf_publishers
Map of transform publishers created through the aspect.
Definition: tf.h:73
create both, transform listener and publisher
Definition: tf.h:53
Create neither listener or publisher, but allow late enabling of a publisher using tf_enable_publishe...
Definition: tf.h:49
Utility class to send transforms.
void tf_add_publisher(const char *frame_id_format,...)
Late add of publisher.
Definition: tf.cpp:198
void tf_enable_publisher(const char *frame_id=0)
Late enabling of publisher.
Definition: tf.cpp:156
void finalize_TransformAspect()
Finalize transform aspect.
Definition: tf.cpp:227
void init_TransformAspect(BlackBoard *blackboard, tf::Transformer *transformer, const char *thread_name)
Init transform aspect.
Definition: tf.cpp:108
The BlackBoard abstract class.
Definition: blackboard.h:48
tf::Transformer * tf_listener
This is the transform listener which saves transforms published by other threads in the system...
Definition: tf.h:70
Coordinate transforms between any two frames in a system.
Definition: transformer.h:68