24#include <interfaces/PanTiltInterface.h>
26#include <core/exceptions/software.h>
60PanTiltInterface::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};
99PanTiltInterface::~PanTiltInterface()
109PanTiltInterface::flags()
const
119PanTiltInterface::maxlenof_flags()
const
129PanTiltInterface::set_flags(
const uint32_t new_flags)
131 set_field(data->flags, new_flags);
139PanTiltInterface::pan()
const
149PanTiltInterface::maxlenof_pan()
const
159PanTiltInterface::set_pan(
const float new_pan)
161 set_field(data->pan, new_pan);
169PanTiltInterface::tilt()
const
179PanTiltInterface::maxlenof_tilt()
const
189PanTiltInterface::set_tilt(
const float new_tilt)
191 set_field(data->tilt, new_tilt);
200PanTiltInterface::msgid()
const
210PanTiltInterface::maxlenof_msgid()
const
221PanTiltInterface::set_msgid(
const uint32_t new_msgid)
223 set_field(data->msgid, new_msgid);
232PanTiltInterface::is_final()
const
242PanTiltInterface::maxlenof_final()
const
253PanTiltInterface::set_final(
const bool new_final)
255 set_field(data->final, new_final);
265PanTiltInterface::error_code()
const
267 return data->error_code;
275PanTiltInterface::maxlenof_error_code()
const
287PanTiltInterface::set_error_code(
const uint32_t new_error_code)
289 set_field(data->error_code, new_error_code);
297PanTiltInterface::is_enabled()
const
299 return data->enabled;
307PanTiltInterface::maxlenof_enabled()
const
317PanTiltInterface::set_enabled(
const bool new_enabled)
319 set_field(data->enabled, new_enabled);
327PanTiltInterface::is_calibrated()
const
329 return data->calibrated;
337PanTiltInterface::maxlenof_calibrated()
const
347PanTiltInterface::set_calibrated(
const bool new_calibrated)
349 set_field(data->calibrated, new_calibrated);
357PanTiltInterface::min_pan()
const
359 return data->min_pan;
367PanTiltInterface::maxlenof_min_pan()
const
377PanTiltInterface::set_min_pan(
const float new_min_pan)
379 set_field(data->min_pan, new_min_pan);
387PanTiltInterface::max_pan()
const
389 return data->max_pan;
397PanTiltInterface::maxlenof_max_pan()
const
407PanTiltInterface::set_max_pan(
const float new_max_pan)
409 set_field(data->max_pan, new_max_pan);
417PanTiltInterface::min_tilt()
const
419 return data->min_tilt;
427PanTiltInterface::maxlenof_min_tilt()
const
437PanTiltInterface::set_min_tilt(
const float new_min_tilt)
439 set_field(data->min_tilt, new_min_tilt);
447PanTiltInterface::max_tilt()
const
449 return data->max_tilt;
457PanTiltInterface::maxlenof_max_tilt()
const
467PanTiltInterface::set_max_tilt(
const float new_max_tilt)
469 set_field(data->max_tilt, new_max_tilt);
477PanTiltInterface::max_pan_velocity()
const
479 return data->max_pan_velocity;
487PanTiltInterface::maxlenof_max_pan_velocity()
const
497PanTiltInterface::set_max_pan_velocity(
const float new_max_pan_velocity)
499 set_field(data->max_pan_velocity, new_max_pan_velocity);
507PanTiltInterface::max_tilt_velocity()
const
509 return data->max_tilt_velocity;
517PanTiltInterface::maxlenof_max_tilt_velocity()
const
527PanTiltInterface::set_max_tilt_velocity(
const float new_max_tilt_velocity)
529 set_field(data->max_tilt_velocity, new_max_tilt_velocity);
537PanTiltInterface::pan_velocity()
const
539 return data->pan_velocity;
547PanTiltInterface::maxlenof_pan_velocity()
const
557PanTiltInterface::set_pan_velocity(
const float new_pan_velocity)
559 set_field(data->pan_velocity, new_pan_velocity);
567PanTiltInterface::tilt_velocity()
const
569 return data->tilt_velocity;
577PanTiltInterface::maxlenof_tilt_velocity()
const
587PanTiltInterface::set_tilt_velocity(
const float new_tilt_velocity)
589 set_field(data->tilt_velocity, new_tilt_velocity);
598PanTiltInterface::pan_margin()
const
600 return data->pan_margin;
608PanTiltInterface::maxlenof_pan_margin()
const
619PanTiltInterface::set_pan_margin(
const float new_pan_margin)
621 set_field(data->pan_margin, new_pan_margin);
630PanTiltInterface::tilt_margin()
const
632 return data->tilt_margin;
640PanTiltInterface::maxlenof_tilt_margin()
const
651PanTiltInterface::set_tilt_margin(
const float new_tilt_margin)
653 set_field(data->tilt_margin, new_tilt_margin);
658PanTiltInterface::create_message(
const char *type)
const
660 if ( strncmp(
"StopMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
662 }
else if ( strncmp(
"FlushMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
664 }
else if ( strncmp(
"CalibrateMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
666 }
else if ( strncmp(
"ParkMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
668 }
else if ( strncmp(
"GotoMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
670 }
else if ( strncmp(
"TimedGotoMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
672 }
else if ( strncmp(
"SetEnabledMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
674 }
else if ( strncmp(
"SetVelocityMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
676 }
else if ( strncmp(
"SetMarginMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
680 "message type for this interface type.", type);
694 type(), other->
type());
696 memcpy(data, oi->data,
sizeof(PanTiltInterface_data_t));
700PanTiltInterface::enum_tostring(
const char *enumtype,
int val)
const
714PanTiltInterface::StopMessage::StopMessage() :
Message(
"StopMessage")
719 data = (StopMessage_data_t *)
data_ptr;
737 data = (StopMessage_data_t *)
data_ptr;
765 data = (FlushMessage_data_t *)
data_ptr;
783 data = (FlushMessage_data_t *)
data_ptr;
808 data_size =
sizeof(CalibrateMessage_data_t);
811 data = (CalibrateMessage_data_t *)
data_ptr;
829 data = (CalibrateMessage_data_t *)
data_ptr;
857 data = (ParkMessage_data_t *)
data_ptr;
875 data = (ParkMessage_data_t *)
data_ptr;
906 data = (GotoMessage_data_t *)
data_ptr;
909 data->tilt = ini_tilt;
919 data = (GotoMessage_data_t *)
data_ptr;
939 data = (GotoMessage_data_t *)
data_ptr;
1028 data_size =
sizeof(TimedGotoMessage_data_t);
1031 data = (TimedGotoMessage_data_t *)
data_ptr;
1033 data->time_sec = ini_time_sec;
1034 data->pan = ini_pan;
1035 data->tilt = ini_tilt;
1043 data_size =
sizeof(TimedGotoMessage_data_t);
1046 data = (TimedGotoMessage_data_t *)
data_ptr;
1067 data = (TimedGotoMessage_data_t *)
data_ptr;
1080 return data->time_sec;
1101 set_field(data->time_sec, new_time_sec);
1186 data_size =
sizeof(SetEnabledMessage_data_t);
1189 data = (SetEnabledMessage_data_t *)
data_ptr;
1191 data->enabled = ini_enabled;
1197 data_size =
sizeof(SetEnabledMessage_data_t);
1200 data = (SetEnabledMessage_data_t *)
data_ptr;
1219 data = (SetEnabledMessage_data_t *)
data_ptr;
1231 return data->enabled;
1277 data_size =
sizeof(SetVelocityMessage_data_t);
1280 data = (SetVelocityMessage_data_t *)
data_ptr;
1282 data->pan_velocity = ini_pan_velocity;
1283 data->tilt_velocity = ini_tilt_velocity;
1290 data_size =
sizeof(SetVelocityMessage_data_t);
1293 data = (SetVelocityMessage_data_t *)
data_ptr;
1313 data = (SetVelocityMessage_data_t *)
data_ptr;
1325 return data->pan_velocity;
1345 set_field(data->pan_velocity, new_pan_velocity);
1355 return data->tilt_velocity;
1375 set_field(data->tilt_velocity, new_tilt_velocity);
1401 data_size =
sizeof(SetMarginMessage_data_t);
1404 data = (SetMarginMessage_data_t *)
data_ptr;
1406 data->pan_margin = ini_pan_margin;
1407 data->tilt_margin = ini_tilt_margin;
1414 data_size =
sizeof(SetMarginMessage_data_t);
1417 data = (SetMarginMessage_data_t *)
data_ptr;
1437 data = (SetMarginMessage_data_t *)
data_ptr;
1450 return data->pan_margin;
1471 set_field(data->pan_margin, new_pan_margin);
1482 return data->tilt_margin;
1503 set_field(data->tilt_margin, new_tilt_margin);
Base class for all Fawkes BlackBoard interfaces.
const char * type() const
Get type of interface.
void * data_ptr
Pointer to local memory storage.
void set_field(FieldT &field, DataT &data)
Set a field, set data_changed to true and update data_changed accordingly.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
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.
void * data_ptr
Pointer to memory that contains local data.
message_data_ts_t * data_ts
data timestamp aliasing pointer
unsigned int data_size
Size of memory needed to hold all data.
CalibrateMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
~CalibrateMessage()
Destructor.
CalibrateMessage()
Constructor.
FlushMessage Fawkes BlackBoard Interface Message.
~FlushMessage()
Destructor.
FlushMessage()
Constructor.
virtual Message * clone() const
Clone this message.
GotoMessage Fawkes BlackBoard Interface Message.
void set_tilt(const float new_tilt)
Set tilt value.
GotoMessage()
Constructor.
void set_pan(const float new_pan)
Set pan value.
~GotoMessage()
Destructor.
size_t maxlenof_tilt() const
Get maximum length of tilt value.
float pan() const
Get pan 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.
ParkMessage()
Constructor.
~ParkMessage()
Destructor.
SetEnabledMessage Fawkes BlackBoard Interface Message.
bool is_enabled() const
Get enabled value.
virtual Message * clone() const
Clone this message.
void set_enabled(const bool new_enabled)
Set enabled value.
~SetEnabledMessage()
Destructor.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
SetEnabledMessage()
Constructor.
SetMarginMessage Fawkes BlackBoard Interface Message.
void set_pan_margin(const float new_pan_margin)
Set pan_margin value.
~SetMarginMessage()
Destructor.
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.
SetMarginMessage()
Constructor.
float pan_margin() const
Get pan_margin value.
SetVelocityMessage Fawkes BlackBoard Interface Message.
~SetVelocityMessage()
Destructor.
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.
SetVelocityMessage()
Constructor.
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.
~StopMessage()
Destructor.
StopMessage()
Constructor.
virtual Message * clone() const
Clone this message.
TimedGotoMessage Fawkes BlackBoard Interface Message.
TimedGotoMessage()
Constructor.
float time_sec() const
Get time_sec value.
size_t maxlenof_time_sec() const
Get maximum length of time_sec value.
float tilt() const
Get tilt 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.
float pan() const
Get pan value.
void set_pan(const float new_pan)
Set pan value.
~TimedGotoMessage()
Destructor.
PanTiltInterface Fawkes BlackBoard Interface.
static const uint32_t ERROR_NONE
ERROR_NONE constant.
static const uint32_t ERROR_UNSPECIFIC
ERROR_UNSPECIFIC constant.
static const uint32_t FLAG_SUPPORTS_PAN
FLAG_SUPPORTS_PAN constant.
static const uint32_t FLAG_SUPPORTS_TILT
FLAG_SUPPORTS_TILT constant.
static const uint32_t ERROR_TILT_OUTOFRANGE
ERROR_TILT_OUTOFRANGE constant.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
static const uint32_t ERROR_COMMUNICATION
ERROR_COMMUNICATION constant.
static const uint32_t ERROR_PAN_OUTOFRANGE
ERROR_PAN_OUTOFRANGE constant.
Fawkes library namespace.
Timestamp data, must be present and first entries for each interface data structs!...