Fawkes API  Fawkes Development Version
PanTiltInterface.h
1 
2 /***************************************************************************
3  * PanTiltInterface.h - Fawkes BlackBoard Interface - PanTiltInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2009 Tim Niemueller
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __INTERFACES_PANTILTINTERFACE_H_
25 #define __INTERFACES_PANTILTINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(PanTiltInterface)
37  /// @endcond
38  public:
39  /* constants */
40  static const uint32_t FLAG_SUPPORTS_PAN;
41  static const uint32_t FLAG_SUPPORTS_TILT;
42  static const uint32_t ERROR_NONE;
43  static const uint32_t ERROR_UNSPECIFIC;
44  static const uint32_t ERROR_COMMUNICATION;
45  static const uint32_t ERROR_PAN_OUTOFRANGE;
46  static const uint32_t ERROR_TILT_OUTOFRANGE;
47 
48  private:
49 #pragma pack(push,4)
50  /** Internal data storage, do NOT modify! */
51  typedef struct {
52  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
53  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
54  uint32_t flags; /**< Flags. */
55  float pan; /**< Current pan. */
56  float tilt; /**< Current tilt. */
57  uint32_t msgid; /**< The ID of the message that is currently being
58  processed, or 0 if no message is being processed. */
59  bool final; /**< True, if the last goto command has been finished,
60  false if it is still running */
61  uint32_t error_code; /**< Failure code set if
62  final is true. 0 if no error occured, an error code from ERROR_*
63  constants otherwise (or a bit-wise combination). */
64  bool enabled; /**< Is the pan/tilt unit enabled? */
65  bool calibrated; /**< Is the pan/tilt unit calibrated? */
66  float min_pan; /**< Minimum pan possible. */
67  float max_pan; /**< Maximum pan possible. */
68  float min_tilt; /**< Minimum tilt possible. */
69  float max_tilt; /**< Maximum tilt possible. */
70  float max_pan_velocity; /**< Maximum supported pan velocity. */
71  float max_tilt_velocity; /**< Maximum supported tilt velocity. */
72  float pan_velocity; /**< Maximum pan velocity currently reached. */
73  float tilt_velocity; /**< Maximum tilt velocity currently reached. */
74  float pan_margin; /**< Margin in radians around a
75  target pan value to consider the motion as final. */
76  float tilt_margin; /**< Margin in radians around a
77  target tilt value to consider the motion as final. */
78  } PanTiltInterface_data_t;
79 #pragma pack(pop)
80 
81  PanTiltInterface_data_t *data;
82 
83  public:
84  /* messages */
85  class StopMessage : public Message
86  {
87  private:
88 #pragma pack(push,4)
89  /** Internal data storage, do NOT modify! */
90  typedef struct {
91  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
92  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
93  } StopMessage_data_t;
94 #pragma pack(pop)
95 
96  StopMessage_data_t *data;
97 
98  public:
99  StopMessage();
100  ~StopMessage();
101 
102  StopMessage(const StopMessage *m);
103  /* Methods */
104  virtual Message * clone() const;
105  };
106 
107  class FlushMessage : public Message
108  {
109  private:
110 #pragma pack(push,4)
111  /** Internal data storage, do NOT modify! */
112  typedef struct {
113  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
114  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
115  } FlushMessage_data_t;
116 #pragma pack(pop)
117 
118  FlushMessage_data_t *data;
119 
120  public:
121  FlushMessage();
122  ~FlushMessage();
123 
124  FlushMessage(const FlushMessage *m);
125  /* Methods */
126  virtual Message * clone() const;
127  };
128 
129  class CalibrateMessage : public Message
130  {
131  private:
132 #pragma pack(push,4)
133  /** Internal data storage, do NOT modify! */
134  typedef struct {
135  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
136  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
137  } CalibrateMessage_data_t;
138 #pragma pack(pop)
139 
140  CalibrateMessage_data_t *data;
141 
142  public:
144  ~CalibrateMessage();
145 
147  /* Methods */
148  virtual Message * clone() const;
149  };
150 
151  class ParkMessage : public Message
152  {
153  private:
154 #pragma pack(push,4)
155  /** Internal data storage, do NOT modify! */
156  typedef struct {
157  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
158  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
159  } ParkMessage_data_t;
160 #pragma pack(pop)
161 
162  ParkMessage_data_t *data;
163 
164  public:
165  ParkMessage();
166  ~ParkMessage();
167 
168  ParkMessage(const ParkMessage *m);
169  /* Methods */
170  virtual Message * clone() const;
171  };
172 
173  class GotoMessage : public Message
174  {
175  private:
176 #pragma pack(push,4)
177  /** Internal data storage, do NOT modify! */
178  typedef struct {
179  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
180  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
181  float pan; /**< Current pan. */
182  float tilt; /**< Current tilt. */
183  } GotoMessage_data_t;
184 #pragma pack(pop)
185 
186  GotoMessage_data_t *data;
187 
188  public:
189  GotoMessage(const float ini_pan, const float ini_tilt);
190  GotoMessage();
191  ~GotoMessage();
192 
193  GotoMessage(const GotoMessage *m);
194  /* Methods */
195  float pan() const;
196  void set_pan(const float new_pan);
197  size_t maxlenof_pan() const;
198  float tilt() const;
199  void set_tilt(const float new_tilt);
200  size_t maxlenof_tilt() const;
201  virtual Message * clone() const;
202  };
203 
204  class TimedGotoMessage : public Message
205  {
206  private:
207 #pragma pack(push,4)
208  /** Internal data storage, do NOT modify! */
209  typedef struct {
210  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
211  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
212  float time_sec; /**< Time in seconds when to reach
213  the final position. */
214  float pan; /**< Current pan. */
215  float tilt; /**< Current tilt. */
216  } TimedGotoMessage_data_t;
217 #pragma pack(pop)
218 
219  TimedGotoMessage_data_t *data;
220 
221  public:
222  TimedGotoMessage(const float ini_time_sec, const float ini_pan, const float ini_tilt);
224  ~TimedGotoMessage();
225 
227  /* Methods */
228  float time_sec() const;
229  void set_time_sec(const float new_time_sec);
230  size_t maxlenof_time_sec() const;
231  float pan() const;
232  void set_pan(const float new_pan);
233  size_t maxlenof_pan() const;
234  float tilt() const;
235  void set_tilt(const float new_tilt);
236  size_t maxlenof_tilt() const;
237  virtual Message * clone() const;
238  };
239 
240  class SetEnabledMessage : public Message
241  {
242  private:
243 #pragma pack(push,4)
244  /** Internal data storage, do NOT modify! */
245  typedef struct {
246  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
247  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
248  bool enabled; /**< Is the pan/tilt unit enabled? */
249  } SetEnabledMessage_data_t;
250 #pragma pack(pop)
251 
252  SetEnabledMessage_data_t *data;
253 
254  public:
255  SetEnabledMessage(const bool ini_enabled);
258 
260  /* Methods */
261  bool is_enabled() const;
262  void set_enabled(const bool new_enabled);
263  size_t maxlenof_enabled() const;
264  virtual Message * clone() const;
265  };
266 
268  {
269  private:
270 #pragma pack(push,4)
271  /** Internal data storage, do NOT modify! */
272  typedef struct {
273  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
274  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
275  float pan_velocity; /**< Maximum pan velocity currently reached. */
276  float tilt_velocity; /**< Maximum tilt velocity currently reached. */
277  } SetVelocityMessage_data_t;
278 #pragma pack(pop)
279 
280  SetVelocityMessage_data_t *data;
281 
282  public:
283  SetVelocityMessage(const float ini_pan_velocity, const float ini_tilt_velocity);
286 
288  /* Methods */
289  float pan_velocity() const;
290  void set_pan_velocity(const float new_pan_velocity);
291  size_t maxlenof_pan_velocity() const;
292  float tilt_velocity() const;
293  void set_tilt_velocity(const float new_tilt_velocity);
294  size_t maxlenof_tilt_velocity() const;
295  virtual Message * clone() const;
296  };
297 
298  class SetMarginMessage : public Message
299  {
300  private:
301 #pragma pack(push,4)
302  /** Internal data storage, do NOT modify! */
303  typedef struct {
304  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
305  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
306  float pan_margin; /**< Margin in radians around a
307  target pan value to consider the motion as final. */
308  float tilt_margin; /**< Margin in radians around a
309  target tilt value to consider the motion as final. */
310  } SetMarginMessage_data_t;
311 #pragma pack(pop)
312 
313  SetMarginMessage_data_t *data;
314 
315  public:
316  SetMarginMessage(const float ini_pan_margin, const float ini_tilt_margin);
318  ~SetMarginMessage();
319 
321  /* Methods */
322  float pan_margin() const;
323  void set_pan_margin(const float new_pan_margin);
324  size_t maxlenof_pan_margin() const;
325  float tilt_margin() const;
326  void set_tilt_margin(const float new_tilt_margin);
327  size_t maxlenof_tilt_margin() const;
328  virtual Message * clone() const;
329  };
330 
331  virtual bool message_valid(const Message *message) const;
332  private:
334  ~PanTiltInterface();
335 
336  public:
337  /* Methods */
338  uint32_t flags() const;
339  void set_flags(const uint32_t new_flags);
340  size_t maxlenof_flags() const;
341  float pan() const;
342  void set_pan(const float new_pan);
343  size_t maxlenof_pan() const;
344  float tilt() const;
345  void set_tilt(const float new_tilt);
346  size_t maxlenof_tilt() const;
347  uint32_t msgid() const;
348  void set_msgid(const uint32_t new_msgid);
349  size_t maxlenof_msgid() const;
350  bool is_final() const;
351  void set_final(const bool new_final);
352  size_t maxlenof_final() const;
353  uint32_t error_code() const;
354  void set_error_code(const uint32_t new_error_code);
355  size_t maxlenof_error_code() const;
356  bool is_enabled() const;
357  void set_enabled(const bool new_enabled);
358  size_t maxlenof_enabled() const;
359  bool is_calibrated() const;
360  void set_calibrated(const bool new_calibrated);
361  size_t maxlenof_calibrated() const;
362  float min_pan() const;
363  void set_min_pan(const float new_min_pan);
364  size_t maxlenof_min_pan() const;
365  float max_pan() const;
366  void set_max_pan(const float new_max_pan);
367  size_t maxlenof_max_pan() const;
368  float min_tilt() const;
369  void set_min_tilt(const float new_min_tilt);
370  size_t maxlenof_min_tilt() const;
371  float max_tilt() const;
372  void set_max_tilt(const float new_max_tilt);
373  size_t maxlenof_max_tilt() const;
374  float max_pan_velocity() const;
375  void set_max_pan_velocity(const float new_max_pan_velocity);
376  size_t maxlenof_max_pan_velocity() const;
377  float max_tilt_velocity() const;
378  void set_max_tilt_velocity(const float new_max_tilt_velocity);
379  size_t maxlenof_max_tilt_velocity() const;
380  float pan_velocity() const;
381  void set_pan_velocity(const float new_pan_velocity);
382  size_t maxlenof_pan_velocity() const;
383  float tilt_velocity() const;
384  void set_tilt_velocity(const float new_tilt_velocity);
385  size_t maxlenof_tilt_velocity() const;
386  float pan_margin() const;
387  void set_pan_margin(const float new_pan_margin);
388  size_t maxlenof_pan_margin() const;
389  float tilt_margin() const;
390  void set_tilt_margin(const float new_tilt_margin);
391  size_t maxlenof_tilt_margin() const;
392  virtual Message * create_message(const char *type) const;
393 
394  virtual void copy_values(const Interface *other);
395  virtual const char * enum_tostring(const char *enumtype, int val) const;
396 
397 };
398 
399 } // end namespace fawkes
400 
401 #endif
size_t maxlenof_tilt_margin() const
Get maximum length of tilt_margin value.
TimedGotoMessage Fawkes BlackBoard Interface Message.
bool is_final() const
Get final value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:43
size_t maxlenof_final() const
Get maximum length of final value.
float pan_velocity() const
Get pan_velocity value.
static const uint32_t ERROR_PAN_OUTOFRANGE
ERROR_PAN_OUTOFRANGE constant.
virtual Message * clone() const
Clone this message.
uint32_t msgid() const
Get msgid value.
static const uint32_t ERROR_COMMUNICATION
ERROR_COMMUNICATION constant.
const char * type() const
Get message type.
Definition: message.cpp:378
static const uint32_t ERROR_UNSPECIFIC
ERROR_UNSPECIFIC constant.
uint32_t error_code() const
Get error_code value.
float max_tilt() const
Get max_tilt value.
void set_pan_velocity(const float new_pan_velocity)
Set pan_velocity value.
Fawkes library namespace.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
size_t maxlenof_calibrated() const
Get maximum length of calibrated value.
float min_tilt() const
Get min_tilt value.
float tilt_velocity() const
Get tilt_velocity value.
void set_max_pan_velocity(const float new_max_pan_velocity)
Set max_pan_velocity value.
SetEnabledMessage Fawkes BlackBoard Interface Message.
void set_flags(const uint32_t new_flags)
Set flags value.
size_t maxlenof_tilt_velocity() const
Get maximum length of tilt_velocity value.
float pan() const
Get pan value.
size_t maxlenof_msgid() const
Get maximum length of msgid value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
void set_pan_margin(const float new_pan_margin)
Set pan_margin value.
SetVelocityMessage Fawkes BlackBoard Interface Message.
static const uint32_t ERROR_NONE
ERROR_NONE constant.
size_t maxlenof_max_tilt() const
Get maximum length of max_tilt value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
void set_min_pan(const float new_min_pan)
Set min_pan value.
size_t maxlenof_min_tilt() const
Get maximum length of min_tilt value.
ParkMessage Fawkes BlackBoard Interface Message.
static const uint32_t FLAG_SUPPORTS_PAN
FLAG_SUPPORTS_PAN constant.
size_t maxlenof_flags() const
Get maximum length of flags value.
virtual Message * create_message(const char *type) const
Create message based on type name.
void set_tilt_margin(const float new_tilt_margin)
Set tilt_margin value.
size_t maxlenof_max_tilt_velocity() const
Get maximum length of max_tilt_velocity value.
FlushMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_pan() const
Get maximum length of pan value.
void set_min_tilt(const float new_min_tilt)
Set min_tilt value.
float max_pan() const
Get max_pan value.
void set_tilt(const float new_tilt)
Set tilt value.
size_t maxlenof_pan_velocity() const
Get maximum length of pan_velocity value.
size_t maxlenof_tilt() const
Get maximum length of tilt value.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
static const uint32_t ERROR_TILT_OUTOFRANGE
ERROR_TILT_OUTOFRANGE constant.
void set_final(const bool new_final)
Set final value.
void set_calibrated(const bool new_calibrated)
Set calibrated value.
GotoMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_max_pan_velocity() const
Get maximum length of max_pan_velocity value.
bool is_calibrated() const
Get calibrated value.
void set_max_tilt(const float new_max_tilt)
Set max_tilt value.
size_t maxlenof_max_pan() const
Get maximum length of max_pan value.
float max_pan_velocity() const
Get max_pan_velocity value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
float pan_margin() const
Get pan_margin value.
float max_tilt_velocity() const
Get max_tilt_velocity value.
void set_max_tilt_velocity(const float new_max_tilt_velocity)
Set max_tilt_velocity value.
bool is_enabled() const
Get enabled value.
float min_pan() const
Get min_pan value.
SetMarginMessage Fawkes BlackBoard Interface Message.
void set_pan(const float new_pan)
Set pan value.
CalibrateMessage Fawkes BlackBoard Interface Message.
static const uint32_t FLAG_SUPPORTS_TILT
FLAG_SUPPORTS_TILT constant.
PanTiltInterface Fawkes BlackBoard Interface.
void set_max_pan(const float new_max_pan)
Set max_pan value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
float tilt_margin() const
Get tilt_margin value.
uint32_t flags() const
Get flags value.
float tilt() const
Get tilt value.
void set_enabled(const bool new_enabled)
Set enabled value.
void set_tilt_velocity(const float new_tilt_velocity)
Set tilt_velocity value.
size_t maxlenof_pan_margin() const
Get maximum length of pan_margin value.
size_t maxlenof_min_pan() const
Get maximum length of min_pan value.
void set_error_code(const uint32_t new_error_code)
Set error_code value.
size_t maxlenof_error_code() const
Get maximum length of error_code value.
StopMessage Fawkes BlackBoard Interface Message.