24 #include <interfaces/PanTiltInterface.h> 26 #include <core/exceptions/software.h> 60 PanTiltInterface::PanTiltInterface() : Interface()
62 data_size =
sizeof(PanTiltInterface_data_t);
63 data_ptr = malloc(data_size);
64 data = (PanTiltInterface_data_t *)data_ptr;
65 data_ts = (interface_data_ts_t *)data_ptr;
66 memset(data_ptr, 0, data_size);
67 add_fieldinfo(IFT_UINT32,
"flags", 1, &data->flags);
68 add_fieldinfo(IFT_FLOAT,
"pan", 1, &data->pan);
69 add_fieldinfo(IFT_FLOAT,
"tilt", 1, &data->tilt);
70 add_fieldinfo(IFT_UINT32,
"msgid", 1, &data->msgid);
71 add_fieldinfo(IFT_BOOL,
"final", 1, &data->final);
72 add_fieldinfo(IFT_UINT32,
"error_code", 1, &data->error_code);
73 add_fieldinfo(IFT_BOOL,
"enabled", 1, &data->enabled);
74 add_fieldinfo(IFT_BOOL,
"calibrated", 1, &data->calibrated);
75 add_fieldinfo(IFT_FLOAT,
"min_pan", 1, &data->min_pan);
76 add_fieldinfo(IFT_FLOAT,
"max_pan", 1, &data->max_pan);
77 add_fieldinfo(IFT_FLOAT,
"min_tilt", 1, &data->min_tilt);
78 add_fieldinfo(IFT_FLOAT,
"max_tilt", 1, &data->max_tilt);
79 add_fieldinfo(IFT_FLOAT,
"max_pan_velocity", 1, &data->max_pan_velocity);
80 add_fieldinfo(IFT_FLOAT,
"max_tilt_velocity", 1, &data->max_tilt_velocity);
81 add_fieldinfo(IFT_FLOAT,
"pan_velocity", 1, &data->pan_velocity);
82 add_fieldinfo(IFT_FLOAT,
"tilt_velocity", 1, &data->tilt_velocity);
83 add_fieldinfo(IFT_FLOAT,
"pan_margin", 1, &data->pan_margin);
84 add_fieldinfo(IFT_FLOAT,
"tilt_margin", 1, &data->tilt_margin);
85 add_messageinfo(
"StopMessage");
86 add_messageinfo(
"FlushMessage");
87 add_messageinfo(
"CalibrateMessage");
88 add_messageinfo(
"ParkMessage");
89 add_messageinfo(
"GotoMessage");
90 add_messageinfo(
"TimedGotoMessage");
91 add_messageinfo(
"SetEnabledMessage");
92 add_messageinfo(
"SetVelocityMessage");
93 add_messageinfo(
"SetMarginMessage");
94 unsigned char tmp_hash[] = {0x3, 0xd7, 0x3b, 0xa8, 0x9f, 0x6d, 00, 0xb9, 0xf5, 0xf2, 0x2f, 0x92, 0x25, 0x1b, 0x87, 0x8e};
99 PanTiltInterface::~PanTiltInterface()
109 PanTiltInterface::flags()
const 119 PanTiltInterface::maxlenof_flags()
const 129 PanTiltInterface::set_flags(
const uint32_t new_flags)
131 data->flags = new_flags;
140 PanTiltInterface::pan()
const 150 PanTiltInterface::maxlenof_pan()
const 160 PanTiltInterface::set_pan(
const float new_pan)
171 PanTiltInterface::tilt()
const 181 PanTiltInterface::maxlenof_tilt()
const 191 PanTiltInterface::set_tilt(
const float new_tilt)
193 data->tilt = new_tilt;
203 PanTiltInterface::msgid()
const 213 PanTiltInterface::maxlenof_msgid()
const 224 PanTiltInterface::set_msgid(
const uint32_t new_msgid)
226 data->msgid = new_msgid;
236 PanTiltInterface::is_final()
const 246 PanTiltInterface::maxlenof_final()
const 257 PanTiltInterface::set_final(
const bool new_final)
259 data->final = new_final;
270 PanTiltInterface::error_code()
const 272 return data->error_code;
280 PanTiltInterface::maxlenof_error_code()
const 292 PanTiltInterface::set_error_code(
const uint32_t new_error_code)
294 data->error_code = new_error_code;
303 PanTiltInterface::is_enabled()
const 305 return data->enabled;
313 PanTiltInterface::maxlenof_enabled()
const 323 PanTiltInterface::set_enabled(
const bool new_enabled)
325 data->enabled = new_enabled;
334 PanTiltInterface::is_calibrated()
const 336 return data->calibrated;
344 PanTiltInterface::maxlenof_calibrated()
const 354 PanTiltInterface::set_calibrated(
const bool new_calibrated)
356 data->calibrated = new_calibrated;
365 PanTiltInterface::min_pan()
const 367 return data->min_pan;
375 PanTiltInterface::maxlenof_min_pan()
const 385 PanTiltInterface::set_min_pan(
const float new_min_pan)
387 data->min_pan = new_min_pan;
396 PanTiltInterface::max_pan()
const 398 return data->max_pan;
406 PanTiltInterface::maxlenof_max_pan()
const 416 PanTiltInterface::set_max_pan(
const float new_max_pan)
418 data->max_pan = new_max_pan;
427 PanTiltInterface::min_tilt()
const 429 return data->min_tilt;
437 PanTiltInterface::maxlenof_min_tilt()
const 447 PanTiltInterface::set_min_tilt(
const float new_min_tilt)
449 data->min_tilt = new_min_tilt;
458 PanTiltInterface::max_tilt()
const 460 return data->max_tilt;
468 PanTiltInterface::maxlenof_max_tilt()
const 478 PanTiltInterface::set_max_tilt(
const float new_max_tilt)
480 data->max_tilt = new_max_tilt;
489 PanTiltInterface::max_pan_velocity()
const 491 return data->max_pan_velocity;
499 PanTiltInterface::maxlenof_max_pan_velocity()
const 509 PanTiltInterface::set_max_pan_velocity(
const float new_max_pan_velocity)
511 data->max_pan_velocity = new_max_pan_velocity;
520 PanTiltInterface::max_tilt_velocity()
const 522 return data->max_tilt_velocity;
530 PanTiltInterface::maxlenof_max_tilt_velocity()
const 540 PanTiltInterface::set_max_tilt_velocity(
const float new_max_tilt_velocity)
542 data->max_tilt_velocity = new_max_tilt_velocity;
551 PanTiltInterface::pan_velocity()
const 553 return data->pan_velocity;
561 PanTiltInterface::maxlenof_pan_velocity()
const 571 PanTiltInterface::set_pan_velocity(
const float new_pan_velocity)
573 data->pan_velocity = new_pan_velocity;
582 PanTiltInterface::tilt_velocity()
const 584 return data->tilt_velocity;
592 PanTiltInterface::maxlenof_tilt_velocity()
const 602 PanTiltInterface::set_tilt_velocity(
const float new_tilt_velocity)
604 data->tilt_velocity = new_tilt_velocity;
614 PanTiltInterface::pan_margin()
const 616 return data->pan_margin;
624 PanTiltInterface::maxlenof_pan_margin()
const 635 PanTiltInterface::set_pan_margin(
const float new_pan_margin)
637 data->pan_margin = new_pan_margin;
647 PanTiltInterface::tilt_margin()
const 649 return data->tilt_margin;
657 PanTiltInterface::maxlenof_tilt_margin()
const 668 PanTiltInterface::set_tilt_margin(
const float new_tilt_margin)
670 data->tilt_margin = new_tilt_margin;
676 PanTiltInterface::create_message(
const char *type)
const 678 if ( strncmp(
"StopMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
680 }
else if ( strncmp(
"FlushMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
682 }
else if ( strncmp(
"CalibrateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
684 }
else if ( strncmp(
"ParkMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
686 }
else if ( strncmp(
"GotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
688 }
else if ( strncmp(
"TimedGotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
690 }
else if ( strncmp(
"SetEnabledMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
692 }
else if ( strncmp(
"SetVelocityMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
694 }
else if ( strncmp(
"SetMarginMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
698 "message type for this interface type.", type);
712 type(), other->
type());
714 memcpy(data, oi->data,
sizeof(PanTiltInterface_data_t));
718 PanTiltInterface::enum_tostring(
const char *enumtype,
int val)
const 732 PanTiltInterface::StopMessage::StopMessage() :
Message(
"StopMessage")
737 data = (StopMessage_data_t *)
data_ptr;
755 data = (StopMessage_data_t *)
data_ptr;
783 data = (FlushMessage_data_t *)
data_ptr;
801 data = (FlushMessage_data_t *)
data_ptr;
826 data_size =
sizeof(CalibrateMessage_data_t);
829 data = (CalibrateMessage_data_t *)
data_ptr;
847 data = (CalibrateMessage_data_t *)
data_ptr;
875 data = (ParkMessage_data_t *)
data_ptr;
893 data = (ParkMessage_data_t *)
data_ptr;
924 data = (GotoMessage_data_t *)
data_ptr;
927 data->tilt = ini_tilt;
937 data = (GotoMessage_data_t *)
data_ptr;
957 data = (GotoMessage_data_t *)
data_ptr;
1019 data->tilt = new_tilt;
1046 data_size =
sizeof(TimedGotoMessage_data_t);
1049 data = (TimedGotoMessage_data_t *)
data_ptr;
1051 data->time_sec = ini_time_sec;
1052 data->pan = ini_pan;
1053 data->tilt = ini_tilt;
1061 data_size =
sizeof(TimedGotoMessage_data_t);
1064 data = (TimedGotoMessage_data_t *)
data_ptr;
1085 data = (TimedGotoMessage_data_t *)
data_ptr;
1098 return data->time_sec;
1119 data->time_sec = new_time_sec;
1149 data->pan = new_pan;
1179 data->tilt = new_tilt;
1204 data_size =
sizeof(SetEnabledMessage_data_t);
1207 data = (SetEnabledMessage_data_t *)
data_ptr;
1209 data->enabled = ini_enabled;
1215 data_size =
sizeof(SetEnabledMessage_data_t);
1218 data = (SetEnabledMessage_data_t *)
data_ptr;
1237 data = (SetEnabledMessage_data_t *)
data_ptr;
1249 return data->enabled;
1269 data->enabled = new_enabled;
1295 data_size =
sizeof(SetVelocityMessage_data_t);
1298 data = (SetVelocityMessage_data_t *)
data_ptr;
1300 data->pan_velocity = ini_pan_velocity;
1301 data->tilt_velocity = ini_tilt_velocity;
1308 data_size =
sizeof(SetVelocityMessage_data_t);
1311 data = (SetVelocityMessage_data_t *)
data_ptr;
1331 data = (SetVelocityMessage_data_t *)
data_ptr;
1343 return data->pan_velocity;
1363 data->pan_velocity = new_pan_velocity;
1373 return data->tilt_velocity;
1393 data->tilt_velocity = new_tilt_velocity;
1419 data_size =
sizeof(SetMarginMessage_data_t);
1422 data = (SetMarginMessage_data_t *)
data_ptr;
1424 data->pan_margin = ini_pan_margin;
1425 data->tilt_margin = ini_tilt_margin;
1432 data_size =
sizeof(SetMarginMessage_data_t);
1435 data = (SetMarginMessage_data_t *)
data_ptr;
1455 data = (SetMarginMessage_data_t *)
data_ptr;
1468 return data->pan_margin;
1489 data->pan_margin = new_pan_margin;
1500 return data->tilt_margin;
1521 data->tilt_margin = new_tilt_margin;
size_t maxlenof_pan() const
Get maximum length of pan value.
SetMarginMessage()
Constructor.
ParkMessage()
Constructor.
void * data_ptr
Pointer to memory that contains local data.
TimedGotoMessage Fawkes BlackBoard Interface Message.
void set_time_sec(const float new_time_sec)
Set time_sec value.
void set_tilt_velocity(const float new_tilt_velocity)
Set tilt_velocity value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
~GotoMessage()
Destructor.
~SetMarginMessage()
Destructor.
StopMessage()
Constructor.
size_t maxlenof_pan_velocity() const
Get maximum length of pan_velocity value.
static const uint32_t ERROR_PAN_OUTOFRANGE
ERROR_PAN_OUTOFRANGE constant.
static const uint32_t ERROR_COMMUNICATION
ERROR_COMMUNICATION constant.
~TimedGotoMessage()
Destructor.
static const uint32_t ERROR_UNSPECIFIC
ERROR_UNSPECIFIC constant.
virtual Message * clone() const
Clone this message.
virtual Message * clone() const
Clone this message.
void set_pan_margin(const float new_pan_margin)
Set pan_margin value.
Fawkes library namespace.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
float tilt_velocity() const
Get tilt_velocity value.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
SetEnabledMessage Fawkes BlackBoard Interface Message.
SetEnabledMessage()
Constructor.
size_t maxlenof_tilt_margin() const
Get maximum length of tilt_margin value.
CalibrateMessage()
Constructor.
float tilt() const
Get tilt value.
~FlushMessage()
Destructor.
~ParkMessage()
Destructor.
Base class for all Fawkes BlackBoard interfaces.
~CalibrateMessage()
Destructor.
float tilt_margin() const
Get tilt_margin value.
SetVelocityMessage Fawkes BlackBoard Interface Message.
float pan_velocity() const
Get pan_velocity value.
static const uint32_t ERROR_NONE
ERROR_NONE constant.
void set_pan(const float new_pan)
Set pan value.
~SetVelocityMessage()
Destructor.
message_data_ts_t * data_ts
data timestamp aliasing pointer
GotoMessage()
Constructor.
unsigned int data_size
Size of memory needed to hold all data.
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.
virtual Message * clone() const
Clone this message.
const char * type() const
Get type of interface.
ParkMessage Fawkes BlackBoard Interface Message.
float pan() const
Get pan value.
virtual Message * clone() const
Clone this message.
~SetEnabledMessage()
Destructor.
void set_tilt(const float new_tilt)
Set tilt value.
static const uint32_t FLAG_SUPPORTS_PAN
FLAG_SUPPORTS_PAN constant.
FlushMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_time_sec() const
Get maximum length of time_sec value.
FlushMessage()
Constructor.
virtual Message * clone() const
Clone this message.
void set_pan_velocity(const float new_pan_velocity)
Set pan_velocity value.
size_t maxlenof_pan_margin() const
Get maximum length of pan_margin value.
bool is_enabled() const
Get enabled value.
static const uint32_t ERROR_TILT_OUTOFRANGE
ERROR_TILT_OUTOFRANGE constant.
GotoMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
void set_pan(const float new_pan)
Set pan value.
SetVelocityMessage()
Constructor.
size_t maxlenof_pan() const
Get maximum length of pan value.
SetMarginMessage Fawkes BlackBoard Interface Message.
CalibrateMessage Fawkes BlackBoard Interface Message.
static const uint32_t FLAG_SUPPORTS_TILT
FLAG_SUPPORTS_TILT constant.
PanTiltInterface Fawkes BlackBoard Interface.
~StopMessage()
Destructor.
float tilt() const
Get tilt value.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
virtual Message * clone() const
Clone this message.
TimedGotoMessage()
Constructor.
size_t maxlenof_tilt() const
Get maximum length of tilt value.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
size_t maxlenof_tilt() const
Get maximum length of tilt value.
float pan_margin() const
Get pan_margin value.
void set_tilt(const float new_tilt)
Set tilt value.
virtual Message * clone() const
Clone this message.
float time_sec() const
Get time_sec value.
float pan() const
Get pan value.
StopMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
void set_enabled(const bool new_enabled)
Set enabled value.