24 #include <interfaces/PanTiltInterface.h> 26 #include <core/exceptions/software.h> 58 PanTiltInterface::PanTiltInterface() : Interface()
60 data_size =
sizeof(PanTiltInterface_data_t);
61 data_ptr = malloc(data_size);
62 data = (PanTiltInterface_data_t *)data_ptr;
63 data_ts = (interface_data_ts_t *)data_ptr;
64 memset(data_ptr, 0, data_size);
65 add_fieldinfo(IFT_UINT32,
"flags", 1, &data->flags,
"");
66 add_fieldinfo(IFT_FLOAT,
"pan", 1, &data->pan,
"");
67 add_fieldinfo(IFT_FLOAT,
"tilt", 1, &data->tilt,
"");
68 add_fieldinfo(IFT_UINT32,
"msgid", 1, &data->msgid,
"");
69 add_fieldinfo(IFT_BOOL,
"final", 1, &data->final,
"");
70 add_fieldinfo(IFT_UINT32,
"error_code", 1, &data->error_code,
"");
71 add_fieldinfo(IFT_BOOL,
"enabled", 1, &data->enabled,
"");
72 add_fieldinfo(IFT_BOOL,
"calibrated", 1, &data->calibrated,
"");
73 add_fieldinfo(IFT_FLOAT,
"min_pan", 1, &data->min_pan,
"");
74 add_fieldinfo(IFT_FLOAT,
"max_pan", 1, &data->max_pan,
"");
75 add_fieldinfo(IFT_FLOAT,
"min_tilt", 1, &data->min_tilt,
"");
76 add_fieldinfo(IFT_FLOAT,
"max_tilt", 1, &data->max_tilt,
"");
77 add_fieldinfo(IFT_FLOAT,
"max_pan_velocity", 1, &data->max_pan_velocity,
"");
78 add_fieldinfo(IFT_FLOAT,
"max_tilt_velocity", 1, &data->max_tilt_velocity,
"");
79 add_fieldinfo(IFT_FLOAT,
"pan_velocity", 1, &data->pan_velocity,
"");
80 add_fieldinfo(IFT_FLOAT,
"tilt_velocity", 1, &data->tilt_velocity,
"");
81 add_fieldinfo(IFT_FLOAT,
"pan_margin", 1, &data->pan_margin,
"");
82 add_fieldinfo(IFT_FLOAT,
"tilt_margin", 1, &data->tilt_margin,
"");
83 add_messageinfo(
"StopMessage");
84 add_messageinfo(
"FlushMessage");
85 add_messageinfo(
"CalibrateMessage");
86 add_messageinfo(
"ParkMessage");
87 add_messageinfo(
"GotoMessage");
88 add_messageinfo(
"TimedGotoMessage");
89 add_messageinfo(
"SetEnabledMessage");
90 add_messageinfo(
"SetVelocityMessage");
91 add_messageinfo(
"SetMarginMessage");
92 unsigned char tmp_hash[] = {0x3, 0xd7, 0x3b, 0xa8, 0x9f, 0x6d, 00, 0xb9, 0xf5, 0xf2, 0x2f, 0x92, 0x25, 0x1b, 0x87, 0x8e};
97 PanTiltInterface::~PanTiltInterface()
107 PanTiltInterface::flags()
const 117 PanTiltInterface::maxlenof_flags()
const 127 PanTiltInterface::set_flags(
const uint32_t new_flags)
129 data->flags = new_flags;
138 PanTiltInterface::pan()
const 148 PanTiltInterface::maxlenof_pan()
const 158 PanTiltInterface::set_pan(
const float new_pan)
169 PanTiltInterface::tilt()
const 179 PanTiltInterface::maxlenof_tilt()
const 189 PanTiltInterface::set_tilt(
const float new_tilt)
191 data->tilt = new_tilt;
201 PanTiltInterface::msgid()
const 211 PanTiltInterface::maxlenof_msgid()
const 222 PanTiltInterface::set_msgid(
const uint32_t new_msgid)
224 data->msgid = new_msgid;
234 PanTiltInterface::is_final()
const 244 PanTiltInterface::maxlenof_final()
const 255 PanTiltInterface::set_final(
const bool new_final)
257 data->final = new_final;
268 PanTiltInterface::error_code()
const 270 return data->error_code;
278 PanTiltInterface::maxlenof_error_code()
const 290 PanTiltInterface::set_error_code(
const uint32_t new_error_code)
292 data->error_code = new_error_code;
301 PanTiltInterface::is_enabled()
const 303 return data->enabled;
311 PanTiltInterface::maxlenof_enabled()
const 321 PanTiltInterface::set_enabled(
const bool new_enabled)
323 data->enabled = new_enabled;
332 PanTiltInterface::is_calibrated()
const 334 return data->calibrated;
342 PanTiltInterface::maxlenof_calibrated()
const 352 PanTiltInterface::set_calibrated(
const bool new_calibrated)
354 data->calibrated = new_calibrated;
363 PanTiltInterface::min_pan()
const 365 return data->min_pan;
373 PanTiltInterface::maxlenof_min_pan()
const 383 PanTiltInterface::set_min_pan(
const float new_min_pan)
385 data->min_pan = new_min_pan;
394 PanTiltInterface::max_pan()
const 396 return data->max_pan;
404 PanTiltInterface::maxlenof_max_pan()
const 414 PanTiltInterface::set_max_pan(
const float new_max_pan)
416 data->max_pan = new_max_pan;
425 PanTiltInterface::min_tilt()
const 427 return data->min_tilt;
435 PanTiltInterface::maxlenof_min_tilt()
const 445 PanTiltInterface::set_min_tilt(
const float new_min_tilt)
447 data->min_tilt = new_min_tilt;
456 PanTiltInterface::max_tilt()
const 458 return data->max_tilt;
466 PanTiltInterface::maxlenof_max_tilt()
const 476 PanTiltInterface::set_max_tilt(
const float new_max_tilt)
478 data->max_tilt = new_max_tilt;
487 PanTiltInterface::max_pan_velocity()
const 489 return data->max_pan_velocity;
497 PanTiltInterface::maxlenof_max_pan_velocity()
const 507 PanTiltInterface::set_max_pan_velocity(
const float new_max_pan_velocity)
509 data->max_pan_velocity = new_max_pan_velocity;
518 PanTiltInterface::max_tilt_velocity()
const 520 return data->max_tilt_velocity;
528 PanTiltInterface::maxlenof_max_tilt_velocity()
const 538 PanTiltInterface::set_max_tilt_velocity(
const float new_max_tilt_velocity)
540 data->max_tilt_velocity = new_max_tilt_velocity;
549 PanTiltInterface::pan_velocity()
const 551 return data->pan_velocity;
559 PanTiltInterface::maxlenof_pan_velocity()
const 569 PanTiltInterface::set_pan_velocity(
const float new_pan_velocity)
571 data->pan_velocity = new_pan_velocity;
580 PanTiltInterface::tilt_velocity()
const 582 return data->tilt_velocity;
590 PanTiltInterface::maxlenof_tilt_velocity()
const 600 PanTiltInterface::set_tilt_velocity(
const float new_tilt_velocity)
602 data->tilt_velocity = new_tilt_velocity;
612 PanTiltInterface::pan_margin()
const 614 return data->pan_margin;
622 PanTiltInterface::maxlenof_pan_margin()
const 633 PanTiltInterface::set_pan_margin(
const float new_pan_margin)
635 data->pan_margin = new_pan_margin;
645 PanTiltInterface::tilt_margin()
const 647 return data->tilt_margin;
655 PanTiltInterface::maxlenof_tilt_margin()
const 666 PanTiltInterface::set_tilt_margin(
const float new_tilt_margin)
668 data->tilt_margin = new_tilt_margin;
674 PanTiltInterface::create_message(
const char *type)
const 676 if ( strncmp(
"StopMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
678 }
else if ( strncmp(
"FlushMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
680 }
else if ( strncmp(
"CalibrateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
682 }
else if ( strncmp(
"ParkMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
684 }
else if ( strncmp(
"GotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
686 }
else if ( strncmp(
"TimedGotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
688 }
else if ( strncmp(
"SetEnabledMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
690 }
else if ( strncmp(
"SetVelocityMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
692 }
else if ( strncmp(
"SetMarginMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
696 "message type for this interface type.", type);
710 type(), other->
type());
712 memcpy(data, oi->data,
sizeof(PanTiltInterface_data_t));
716 PanTiltInterface::enum_tostring(
const char *enumtype,
int val)
const 730 PanTiltInterface::StopMessage::StopMessage() :
Message(
"StopMessage")
735 data = (StopMessage_data_t *)
data_ptr;
753 data = (StopMessage_data_t *)
data_ptr;
781 data = (FlushMessage_data_t *)
data_ptr;
799 data = (FlushMessage_data_t *)
data_ptr;
824 data_size =
sizeof(CalibrateMessage_data_t);
827 data = (CalibrateMessage_data_t *)
data_ptr;
845 data = (CalibrateMessage_data_t *)
data_ptr;
873 data = (ParkMessage_data_t *)
data_ptr;
891 data = (ParkMessage_data_t *)
data_ptr;
922 data = (GotoMessage_data_t *)
data_ptr;
925 data->tilt = ini_tilt;
935 data = (GotoMessage_data_t *)
data_ptr;
955 data = (GotoMessage_data_t *)
data_ptr;
1017 data->tilt = new_tilt;
1044 data_size =
sizeof(TimedGotoMessage_data_t);
1047 data = (TimedGotoMessage_data_t *)
data_ptr;
1049 data->time_sec = ini_time_sec;
1050 data->pan = ini_pan;
1051 data->tilt = ini_tilt;
1059 data_size =
sizeof(TimedGotoMessage_data_t);
1062 data = (TimedGotoMessage_data_t *)
data_ptr;
1083 data = (TimedGotoMessage_data_t *)
data_ptr;
1096 return data->time_sec;
1117 data->time_sec = new_time_sec;
1147 data->pan = new_pan;
1177 data->tilt = new_tilt;
1202 data_size =
sizeof(SetEnabledMessage_data_t);
1205 data = (SetEnabledMessage_data_t *)
data_ptr;
1207 data->enabled = ini_enabled;
1213 data_size =
sizeof(SetEnabledMessage_data_t);
1216 data = (SetEnabledMessage_data_t *)
data_ptr;
1235 data = (SetEnabledMessage_data_t *)
data_ptr;
1247 return data->enabled;
1267 data->enabled = new_enabled;
1293 data_size =
sizeof(SetVelocityMessage_data_t);
1296 data = (SetVelocityMessage_data_t *)
data_ptr;
1298 data->pan_velocity = ini_pan_velocity;
1299 data->tilt_velocity = ini_tilt_velocity;
1306 data_size =
sizeof(SetVelocityMessage_data_t);
1309 data = (SetVelocityMessage_data_t *)
data_ptr;
1329 data = (SetVelocityMessage_data_t *)
data_ptr;
1341 return data->pan_velocity;
1361 data->pan_velocity = new_pan_velocity;
1371 return data->tilt_velocity;
1391 data->tilt_velocity = new_tilt_velocity;
1417 data_size =
sizeof(SetMarginMessage_data_t);
1420 data = (SetMarginMessage_data_t *)
data_ptr;
1422 data->pan_margin = ini_pan_margin;
1423 data->tilt_margin = ini_tilt_margin;
1430 data_size =
sizeof(SetMarginMessage_data_t);
1433 data = (SetMarginMessage_data_t *)
data_ptr;
1453 data = (SetMarginMessage_data_t *)
data_ptr;
1466 return data->pan_margin;
1487 data->pan_margin = new_pan_margin;
1498 return data->tilt_margin;
1519 data->tilt_margin = new_tilt_margin;
float tilt() const
Get tilt value.
SetMarginMessage()
Constructor.
ParkMessage()
Constructor.
float tilt_margin() const
Get tilt_margin value.
void * data_ptr
Pointer to memory that contains local data.
float pan() const
Get pan value.
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.
static const uint32_t ERROR_PAN_OUTOFRANGE
ERROR_PAN_OUTOFRANGE constant.
virtual Message * clone() const
Clone this message.
float tilt_velocity() const
Get tilt_velocity value.
static const uint32_t ERROR_COMMUNICATION
ERROR_COMMUNICATION constant.
~TimedGotoMessage()
Destructor.
static const uint32_t ERROR_UNSPECIFIC
ERROR_UNSPECIFIC constant.
void set_pan_margin(const float new_pan_margin)
Set pan_margin value.
Fawkes library namespace.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
SetEnabledMessage Fawkes BlackBoard Interface Message.
SetEnabledMessage()
Constructor.
CalibrateMessage()
Constructor.
size_t maxlenof_tilt() const
Get maximum length of tilt value.
float pan_margin() const
Get pan_margin value.
size_t maxlenof_tilt_margin() const
Get maximum length of tilt_margin value.
virtual Message * clone() const
Clone this message.
~FlushMessage()
Destructor.
~ParkMessage()
Destructor.
Base class for all Fawkes BlackBoard interfaces.
float pan_velocity() const
Get pan_velocity value.
~CalibrateMessage()
Destructor.
virtual Message * clone() const
Clone this message.
virtual Message * clone() const
Clone this message.
SetVelocityMessage Fawkes BlackBoard Interface Message.
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.
virtual Message * clone() const
Clone this message.
ParkMessage Fawkes BlackBoard Interface Message.
~SetEnabledMessage()
Destructor.
size_t maxlenof_pan_margin() const
Get maximum length of pan_margin value.
void set_tilt(const float new_tilt)
Set tilt value.
static const uint32_t FLAG_SUPPORTS_PAN
FLAG_SUPPORTS_PAN constant.
size_t maxlenof_tilt() const
Get maximum length of tilt value.
FlushMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
size_t maxlenof_pan() const
Get maximum length of pan value.
FlushMessage()
Constructor.
void set_pan_velocity(const float new_pan_velocity)
Set pan_velocity value.
size_t maxlenof_pan_velocity() const
Get maximum length of pan_velocity value.
static const uint32_t ERROR_TILT_OUTOFRANGE
ERROR_TILT_OUTOFRANGE constant.
GotoMessage Fawkes BlackBoard Interface Message.
float pan() const
Get pan value.
void set_pan(const float new_pan)
Set pan value.
SetVelocityMessage()
Constructor.
virtual Message * clone() const
Clone this message.
virtual Message * clone() const
Clone this message.
float tilt() const
Get tilt value.
SetMarginMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
CalibrateMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_time_sec() const
Get maximum length of time_sec value.
static const uint32_t FLAG_SUPPORTS_TILT
FLAG_SUPPORTS_TILT constant.
PanTiltInterface Fawkes BlackBoard Interface.
~StopMessage()
Destructor.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0)
Add an entry to the info list.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
float time_sec() const
Get time_sec value.
TimedGotoMessage()
Constructor.
size_t maxlenof_pan() const
Get maximum length of pan value.
const char * type() const
Get type of interface.
void set_tilt(const float new_tilt)
Set tilt value.
bool is_enabled() const
Get enabled value.
StopMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_tilt_velocity() const
Get maximum length of tilt_velocity value.
void set_enabled(const bool new_enabled)
Set enabled value.
virtual Message * clone() const
Clone this message.