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
31namespace 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 /** Internal data storage, do NOT modify! */
50 typedef struct {
51 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
52 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
53 uint32_t flags; /**< Flags. */
54 float pan; /**< Current pan. */
55 float tilt; /**< Current tilt. */
56 uint32_t msgid; /**< The ID of the message that is currently being
57 processed, or 0 if no message is being processed. */
58 bool final; /**< True, if the last goto command has been finished,
59 false if it is still running */
60 uint32_t error_code; /**< Failure code set if
61 final is true. 0 if no error occured, an error code from ERROR_*
62 constants otherwise (or a bit-wise combination). */
63 bool enabled; /**< Is the pan/tilt unit enabled? */
64 bool calibrated; /**< Is the pan/tilt unit calibrated? */
65 float min_pan; /**< Minimum pan possible. */
66 float max_pan; /**< Maximum pan possible. */
67 float min_tilt; /**< Minimum tilt possible. */
68 float max_tilt; /**< Maximum tilt possible. */
69 float max_pan_velocity; /**< Maximum supported pan velocity. */
70 float max_tilt_velocity; /**< Maximum supported tilt velocity. */
71 float pan_velocity; /**< Maximum pan velocity currently reached. */
72 float tilt_velocity; /**< Maximum tilt velocity currently reached. */
73 float pan_margin; /**< Margin in radians around a
74 target pan value to consider the motion as final. */
75 float tilt_margin; /**< Margin in radians around a
76 target tilt value to consider the motion as final. */
77 } PanTiltInterface_data_t;
78
79 PanTiltInterface_data_t *data;
80
81 public:
82 /* messages */
83 class StopMessage : public Message
84 {
85 private:
86 /** Internal data storage, do NOT modify! */
87 typedef struct {
88 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
89 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
90 } StopMessage_data_t;
91
92 StopMessage_data_t *data;
93
94 public:
97
98 explicit StopMessage(const StopMessage *m);
99 /* Methods */
100 virtual Message * clone() const;
101 };
102
103 class FlushMessage : public Message
104 {
105 private:
106 /** Internal data storage, do NOT modify! */
107 typedef struct {
108 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
109 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
110 } FlushMessage_data_t;
111
112 FlushMessage_data_t *data;
113
114 public:
115 FlushMessage();
117
118 explicit FlushMessage(const FlushMessage *m);
119 /* Methods */
120 virtual Message * clone() const;
121 };
122
124 {
125 private:
126 /** Internal data storage, do NOT modify! */
127 typedef struct {
128 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
129 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
130 } CalibrateMessage_data_t;
131
132 CalibrateMessage_data_t *data;
133
134 public:
137
138 explicit CalibrateMessage(const CalibrateMessage *m);
139 /* Methods */
140 virtual Message * clone() const;
141 };
142
143 class ParkMessage : public Message
144 {
145 private:
146 /** Internal data storage, do NOT modify! */
147 typedef struct {
148 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
149 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
150 } ParkMessage_data_t;
151
152 ParkMessage_data_t *data;
153
154 public:
155 ParkMessage();
156 ~ParkMessage();
157
158 explicit ParkMessage(const ParkMessage *m);
159 /* Methods */
160 virtual Message * clone() const;
161 };
162
163 class GotoMessage : public Message
164 {
165 private:
166 /** Internal data storage, do NOT modify! */
167 typedef struct {
168 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
169 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
170 float pan; /**< Current pan. */
171 float tilt; /**< Current tilt. */
172 } GotoMessage_data_t;
173
174 GotoMessage_data_t *data;
175
176 public:
177 GotoMessage(const float ini_pan, const float ini_tilt);
178 GotoMessage();
179 ~GotoMessage();
180
181 explicit GotoMessage(const GotoMessage *m);
182 /* Methods */
183 float pan() const;
184 void set_pan(const float new_pan);
185 size_t maxlenof_pan() const;
186 float tilt() const;
187 void set_tilt(const float new_tilt);
188 size_t maxlenof_tilt() const;
189 virtual Message * clone() const;
190 };
191
193 {
194 private:
195 /** Internal data storage, do NOT modify! */
196 typedef struct {
197 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
198 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
199 float time_sec; /**< Time in seconds when to reach
200 the final position. */
201 float pan; /**< Current pan. */
202 float tilt; /**< Current tilt. */
203 } TimedGotoMessage_data_t;
204
205 TimedGotoMessage_data_t *data;
206
207 public:
208 TimedGotoMessage(const float ini_time_sec, const float ini_pan, const float ini_tilt);
211
212 explicit TimedGotoMessage(const TimedGotoMessage *m);
213 /* Methods */
214 float time_sec() const;
215 void set_time_sec(const float new_time_sec);
216 size_t maxlenof_time_sec() const;
217 float pan() const;
218 void set_pan(const float new_pan);
219 size_t maxlenof_pan() const;
220 float tilt() const;
221 void set_tilt(const float new_tilt);
222 size_t maxlenof_tilt() const;
223 virtual Message * clone() const;
224 };
225
227 {
228 private:
229 /** Internal data storage, do NOT modify! */
230 typedef struct {
231 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
232 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
233 bool enabled; /**< Is the pan/tilt unit enabled? */
234 } SetEnabledMessage_data_t;
235
236 SetEnabledMessage_data_t *data;
237
238 public:
239 SetEnabledMessage(const bool ini_enabled);
242
243 explicit SetEnabledMessage(const SetEnabledMessage *m);
244 /* Methods */
245 bool is_enabled() const;
246 void set_enabled(const bool new_enabled);
247 size_t maxlenof_enabled() const;
248 virtual Message * clone() const;
249 };
250
252 {
253 private:
254 /** Internal data storage, do NOT modify! */
255 typedef struct {
256 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
257 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
258 float pan_velocity; /**< Maximum pan velocity currently reached. */
259 float tilt_velocity; /**< Maximum tilt velocity currently reached. */
260 } SetVelocityMessage_data_t;
261
262 SetVelocityMessage_data_t *data;
263
264 public:
265 SetVelocityMessage(const float ini_pan_velocity, const float ini_tilt_velocity);
268
269 explicit SetVelocityMessage(const SetVelocityMessage *m);
270 /* Methods */
271 float pan_velocity() const;
272 void set_pan_velocity(const float new_pan_velocity);
273 size_t maxlenof_pan_velocity() const;
274 float tilt_velocity() const;
275 void set_tilt_velocity(const float new_tilt_velocity);
276 size_t maxlenof_tilt_velocity() const;
277 virtual Message * clone() const;
278 };
279
281 {
282 private:
283 /** Internal data storage, do NOT modify! */
284 typedef struct {
285 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
286 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
287 float pan_margin; /**< Margin in radians around a
288 target pan value to consider the motion as final. */
289 float tilt_margin; /**< Margin in radians around a
290 target tilt value to consider the motion as final. */
291 } SetMarginMessage_data_t;
292
293 SetMarginMessage_data_t *data;
294
295 public:
296 SetMarginMessage(const float ini_pan_margin, const float ini_tilt_margin);
299
300 explicit SetMarginMessage(const SetMarginMessage *m);
301 /* Methods */
302 float pan_margin() const;
303 void set_pan_margin(const float new_pan_margin);
304 size_t maxlenof_pan_margin() const;
305 float tilt_margin() const;
306 void set_tilt_margin(const float new_tilt_margin);
307 size_t maxlenof_tilt_margin() const;
308 virtual Message * clone() const;
309 };
310
311 virtual bool message_valid(const Message *message) const;
312 private:
315
316 public:
317 /* Methods */
318 uint32_t flags() const;
319 void set_flags(const uint32_t new_flags);
320 size_t maxlenof_flags() const;
321 float pan() const;
322 void set_pan(const float new_pan);
323 size_t maxlenof_pan() const;
324 float tilt() const;
325 void set_tilt(const float new_tilt);
326 size_t maxlenof_tilt() const;
327 uint32_t msgid() const;
328 void set_msgid(const uint32_t new_msgid);
329 size_t maxlenof_msgid() const;
330 bool is_final() const;
331 void set_final(const bool new_final);
332 size_t maxlenof_final() const;
333 uint32_t error_code() const;
334 void set_error_code(const uint32_t new_error_code);
335 size_t maxlenof_error_code() const;
336 bool is_enabled() const;
337 void set_enabled(const bool new_enabled);
338 size_t maxlenof_enabled() const;
339 bool is_calibrated() const;
340 void set_calibrated(const bool new_calibrated);
341 size_t maxlenof_calibrated() const;
342 float min_pan() const;
343 void set_min_pan(const float new_min_pan);
344 size_t maxlenof_min_pan() const;
345 float max_pan() const;
346 void set_max_pan(const float new_max_pan);
347 size_t maxlenof_max_pan() const;
348 float min_tilt() const;
349 void set_min_tilt(const float new_min_tilt);
350 size_t maxlenof_min_tilt() const;
351 float max_tilt() const;
352 void set_max_tilt(const float new_max_tilt);
353 size_t maxlenof_max_tilt() const;
354 float max_pan_velocity() const;
355 void set_max_pan_velocity(const float new_max_pan_velocity);
356 size_t maxlenof_max_pan_velocity() const;
357 float max_tilt_velocity() const;
358 void set_max_tilt_velocity(const float new_max_tilt_velocity);
359 size_t maxlenof_max_tilt_velocity() const;
360 float pan_velocity() const;
361 void set_pan_velocity(const float new_pan_velocity);
362 size_t maxlenof_pan_velocity() const;
363 float tilt_velocity() const;
364 void set_tilt_velocity(const float new_tilt_velocity);
365 size_t maxlenof_tilt_velocity() const;
366 float pan_margin() const;
367 void set_pan_margin(const float new_pan_margin);
368 size_t maxlenof_pan_margin() const;
369 float tilt_margin() const;
370 void set_tilt_margin(const float new_tilt_margin);
371 size_t maxlenof_tilt_margin() const;
372 virtual Message * create_message(const char *type) const;
373
374 virtual void copy_values(const Interface *other);
375 virtual const char * enum_tostring(const char *enumtype, int val) const;
376
377};
378
379} // end namespace fawkes
380
381#endif
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
const char * type() const
Get type of interface.
Definition: interface.cpp:652
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
CalibrateMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
FlushMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
GotoMessage Fawkes BlackBoard Interface Message.
void set_tilt(const float new_tilt)
Set tilt value.
void set_pan(const float new_pan)
Set pan value.
size_t maxlenof_tilt() const
Get maximum length of tilt value.
virtual Message * clone() const
Clone this message.
float tilt() const
Get tilt value.
size_t maxlenof_pan() const
Get maximum length of pan value.
ParkMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
SetEnabledMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
void set_enabled(const bool new_enabled)
Set enabled value.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
SetMarginMessage Fawkes BlackBoard Interface Message.
void set_pan_margin(const float new_pan_margin)
Set pan_margin value.
virtual Message * clone() const
Clone this message.
void set_tilt_margin(const float new_tilt_margin)
Set tilt_margin value.
size_t maxlenof_pan_margin() const
Get maximum length of pan_margin value.
size_t maxlenof_tilt_margin() const
Get maximum length of tilt_margin value.
float tilt_margin() const
Get tilt_margin value.
float pan_margin() const
Get pan_margin value.
SetVelocityMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_pan_velocity() const
Get maximum length of pan_velocity value.
void set_pan_velocity(const float new_pan_velocity)
Set pan_velocity value.
virtual Message * clone() const
Clone this message.
float tilt_velocity() const
Get tilt_velocity value.
void set_tilt_velocity(const float new_tilt_velocity)
Set tilt_velocity value.
size_t maxlenof_tilt_velocity() const
Get maximum length of tilt_velocity value.
float pan_velocity() const
Get pan_velocity value.
StopMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
TimedGotoMessage Fawkes BlackBoard Interface Message.
float time_sec() const
Get time_sec value.
size_t maxlenof_time_sec() const
Get maximum length of time_sec value.
virtual Message * clone() const
Clone this message.
void set_tilt(const float new_tilt)
Set tilt value.
void set_time_sec(const float new_time_sec)
Set time_sec value.
size_t maxlenof_tilt() const
Get maximum length of tilt value.
size_t maxlenof_pan() const
Get maximum length of pan value.
void set_pan(const float new_pan)
Set pan value.
PanTiltInterface Fawkes BlackBoard Interface.
virtual void copy_values(const Interface *other)
Copy values from other interface.
size_t maxlenof_error_code() const
Get maximum length of error_code value.
bool is_final() const
Get final value.
void set_enabled(const bool new_enabled)
Set enabled value.
size_t maxlenof_tilt_margin() const
Get maximum length of tilt_margin value.
float max_tilt_velocity() const
Get max_tilt_velocity value.
void set_tilt_velocity(const float new_tilt_velocity)
Set tilt_velocity value.
static const uint32_t ERROR_NONE
ERROR_NONE constant.
uint32_t flags() const
Get flags value.
void set_min_pan(const float new_min_pan)
Set min_pan value.
void set_final(const bool new_final)
Set final value.
void set_min_tilt(const float new_min_tilt)
Set min_tilt value.
void set_max_tilt_velocity(const float new_max_tilt_velocity)
Set max_tilt_velocity value.
void set_error_code(const uint32_t new_error_code)
Set error_code value.
uint32_t msgid() const
Get msgid value.
size_t maxlenof_min_pan() const
Get maximum length of min_pan value.
size_t maxlenof_max_tilt() const
Get maximum length of max_tilt value.
size_t maxlenof_max_tilt_velocity() const
Get maximum length of max_tilt_velocity value.
void set_flags(const uint32_t new_flags)
Set flags value.
float tilt_margin() const
Get tilt_margin value.
bool is_enabled() const
Get enabled value.
float pan_velocity() const
Get pan_velocity value.
void set_max_tilt(const float new_max_tilt)
Set max_tilt value.
size_t maxlenof_final() const
Get maximum length of final value.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
size_t maxlenof_pan_velocity() const
Get maximum length of pan_velocity value.
static const uint32_t ERROR_UNSPECIFIC
ERROR_UNSPECIFIC constant.
float pan() const
Get pan value.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
float max_tilt() const
Get max_tilt value.
size_t maxlenof_tilt() const
Get maximum length of tilt value.
void set_max_pan(const float new_max_pan)
Set max_pan value.
bool is_calibrated() const
Get calibrated value.
void set_pan_velocity(const float new_pan_velocity)
Set pan_velocity value.
size_t maxlenof_pan() const
Get maximum length of pan value.
size_t maxlenof_max_pan() const
Get maximum length of max_pan value.
float max_pan() const
Get max_pan value.
static const uint32_t FLAG_SUPPORTS_PAN
FLAG_SUPPORTS_PAN constant.
size_t maxlenof_max_pan_velocity() const
Get maximum length of max_pan_velocity value.
size_t maxlenof_pan_margin() const
Get maximum length of pan_margin value.
size_t maxlenof_flags() const
Get maximum length of flags value.
uint32_t error_code() const
Get error_code value.
static const uint32_t FLAG_SUPPORTS_TILT
FLAG_SUPPORTS_TILT constant.
float min_tilt() const
Get min_tilt value.
float pan_margin() const
Get pan_margin value.
void set_pan_margin(const float new_pan_margin)
Set pan_margin value.
void set_tilt(const float new_tilt)
Set tilt value.
void set_max_pan_velocity(const float new_max_pan_velocity)
Set max_pan_velocity value.
float tilt() const
Get tilt value.
float min_pan() const
Get min_pan value.
static const uint32_t ERROR_TILT_OUTOFRANGE
ERROR_TILT_OUTOFRANGE constant.
size_t maxlenof_min_tilt() const
Get maximum length of min_tilt value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
void set_calibrated(const bool new_calibrated)
Set calibrated value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
float max_pan_velocity() const
Get max_pan_velocity value.
float tilt_velocity() const
Get tilt_velocity value.
void set_tilt_margin(const float new_tilt_margin)
Set tilt_margin value.
size_t maxlenof_tilt_velocity() const
Get maximum length of tilt_velocity value.
static const uint32_t ERROR_COMMUNICATION
ERROR_COMMUNICATION constant.
size_t maxlenof_calibrated() const
Get maximum length of calibrated value.
virtual Message * create_message(const char *type) const
Create message based on type name.
static const uint32_t ERROR_PAN_OUTOFRANGE
ERROR_PAN_OUTOFRANGE constant.
void set_pan(const float new_pan)
Set pan value.
size_t maxlenof_msgid() const
Get maximum length of msgid value.
Fawkes library namespace.