24#include <interfaces/LaserClusterInterface.h>
26#include <core/exceptions/software.h>
44LaserClusterInterface::LaserClusterInterface() : Interface()
46 data_size =
sizeof(LaserClusterInterface_data_t);
47 data_ptr = malloc(data_size);
48 data = (LaserClusterInterface_data_t *)data_ptr;
49 data_ts = (interface_data_ts_t *)data_ptr;
50 memset(data_ptr, 0, data_size);
51 enum_map_SelectionMode[(int)SELMODE_MIN_ANGLE] =
"SELMODE_MIN_ANGLE";
52 enum_map_SelectionMode[(int)SELMODE_MIN_DIST] =
"SELMODE_MIN_DIST";
53 add_fieldinfo(IFT_FLOAT,
"max_x", 1, &data->max_x);
54 add_fieldinfo(IFT_ENUM,
"selection_mode", 1, &data->selection_mode,
"SelectionMode", &enum_map_SelectionMode);
55 add_messageinfo(
"SetMaxXMessage");
56 add_messageinfo(
"SetSelectionModeMessage");
57 unsigned char tmp_hash[] = {0xad, 0xf8, 0x6e, 0xe7, 0x17, 0x56, 0x8a, 0xfb, 0xf9, 0xad, 0x3e, 0xba, 0xd, 0x15, 0xce, 0xde};
62LaserClusterInterface::~LaserClusterInterface()
74 case SELMODE_MIN_ANGLE:
return "SELMODE_MIN_ANGLE";
75 case SELMODE_MIN_DIST:
return "SELMODE_MIN_DIST";
76 default:
return "UNKNOWN";
86LaserClusterInterface::max_x()
const
96LaserClusterInterface::maxlenof_max_x()
const
107LaserClusterInterface::set_max_x(
const float new_max_x)
109 set_field(data->max_x, new_max_x);
119LaserClusterInterface::selection_mode()
const
129LaserClusterInterface::maxlenof_selection_mode()
const
141LaserClusterInterface::set_selection_mode(
const SelectionMode new_selection_mode)
143 set_field(data->selection_mode, new_selection_mode);
148LaserClusterInterface::create_message(
const char *type)
const
150 if ( strncmp(
"SetMaxXMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
152 }
else if ( strncmp(
"SetSelectionModeMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
156 "message type for this interface type.", type);
165LaserClusterInterface::copy_values(
const Interface *other)
170 type(), other->
type());
172 memcpy(data, oi->data,
sizeof(LaserClusterInterface_data_t));
176LaserClusterInterface::enum_tostring(
const char *enumtype,
int val)
const
178 if (strcmp(enumtype,
"SelectionMode") == 0) {
195LaserClusterInterface::SetMaxXMessage::SetMaxXMessage(
const float ini_max_x) :
Message(
"SetMaxXMessage")
197 data_size =
sizeof(SetMaxXMessage_data_t);
200 data = (SetMaxXMessage_data_t *)
data_ptr;
202 data->max_x = ini_max_x;
210 data_size =
sizeof(SetMaxXMessage_data_t);
213 data = (SetMaxXMessage_data_t *)
data_ptr;
234 data = (SetMaxXMessage_data_t *)
data_ptr;
293 data_size =
sizeof(SetSelectionModeMessage_data_t);
296 data = (SetSelectionModeMessage_data_t *)
data_ptr;
298 data->selection_mode = ini_selection_mode;
301 add_fieldinfo(
IFT_ENUM,
"selection_mode", 1, &data->selection_mode,
"SelectionMode", &enum_map_SelectionMode);
306 data_size =
sizeof(SetSelectionModeMessage_data_t);
309 data = (SetSelectionModeMessage_data_t *)
data_ptr;
313 add_fieldinfo(
IFT_ENUM,
"selection_mode", 1, &data->selection_mode,
"SelectionMode", &enum_map_SelectionMode);
330 data = (SetSelectionModeMessage_data_t *)
data_ptr;
366 set_field(data->selection_mode, new_selection_mode);
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.
SetMaxXMessage Fawkes BlackBoard Interface Message.
float max_x() const
Get max_x value.
size_t maxlenof_max_x() const
Get maximum length of max_x value.
void set_max_x(const float new_max_x)
Set max_x value.
virtual Message * clone() const
Clone this message.
~SetMaxXMessage()
Destructor.
SetMaxXMessage()
Constructor.
SetSelectionModeMessage Fawkes BlackBoard Interface Message.
~SetSelectionModeMessage()
Destructor.
void set_selection_mode(const SelectionMode new_selection_mode)
Set selection_mode value.
virtual Message * clone() const
Clone this message.
SelectionMode selection_mode() const
Get selection_mode value.
size_t maxlenof_selection_mode() const
Get maximum length of selection_mode value.
SetSelectionModeMessage()
Constructor.
LaserClusterInterface Fawkes BlackBoard Interface.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
SelectionMode
Enumeration defining the possible cluster selection modes.
@ SELMODE_MIN_ANGLE
Choose the cluster with the minimum angle difference from 0 degrees.
@ SELMODE_MIN_DIST
Choose the cluster with the minimum distance in X direction of the reference frame (typically forward...
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.
Fawkes library namespace.
@ IFT_ENUM
field with interface specific enum type
Timestamp data, must be present and first entries for each interface data structs!...