24#include <interfaces/RobotinoSensorInterface.h>
26#include <core/exceptions/software.h>
44RobotinoSensorInterface::RobotinoSensorInterface() : Interface()
46 data_size =
sizeof(RobotinoSensorInterface_data_t);
47 data_ptr = malloc(data_size);
48 data = (RobotinoSensorInterface_data_t *)data_ptr;
49 data_ts = (interface_data_ts_t *)data_ptr;
50 memset(data_ptr, 0, data_size);
51 add_fieldinfo(IFT_FLOAT,
"mot_velocity", 3, &data->mot_velocity);
52 add_fieldinfo(IFT_INT32,
"mot_position", 3, &data->mot_position);
53 add_fieldinfo(IFT_FLOAT,
"mot_current", 3, &data->mot_current);
54 add_fieldinfo(IFT_BOOL,
"bumper", 1, &data->bumper);
55 add_fieldinfo(IFT_FLOAT,
"distance", 9, &data->distance);
56 add_fieldinfo(IFT_BOOL,
"digital_in", 8, &data->digital_in);
57 add_fieldinfo(IFT_BOOL,
"digital_out", 8, &data->digital_out);
58 add_fieldinfo(IFT_FLOAT,
"analog_in", 8, &data->analog_in);
59 add_fieldinfo(IFT_BOOL,
"bumper_estop_enabled", 1, &data->bumper_estop_enabled);
60 add_messageinfo(
"SetBumperEStopEnabledMessage");
61 add_messageinfo(
"SetDigitalOutputMessage");
62 unsigned char tmp_hash[] = {0xa5, 0xb, 0xa1, 0x94, 0xea, 0x39, 0x14, 0x7, 0x98, 0x77, 0x10, 0xc, 0x25, 0x72, 0x57, 0xa0};
67RobotinoSensorInterface::~RobotinoSensorInterface()
77RobotinoSensorInterface::mot_velocity()
const
79 return data->mot_velocity;
89RobotinoSensorInterface::mot_velocity(
unsigned int index)
const
92 throw Exception(
"Index value %u out of bounds (0..2)", index);
94 return data->mot_velocity[index];
102RobotinoSensorInterface::maxlenof_mot_velocity()
const
112RobotinoSensorInterface::set_mot_velocity(
const float * new_mot_velocity)
114 set_field(data->mot_velocity, new_mot_velocity);
123RobotinoSensorInterface::set_mot_velocity(
unsigned int index,
const float new_mot_velocity)
125 set_field(data->mot_velocity, index, new_mot_velocity);
132RobotinoSensorInterface::mot_position()
const
134 return data->mot_position;
144RobotinoSensorInterface::mot_position(
unsigned int index)
const
147 throw Exception(
"Index value %u out of bounds (0..2)", index);
149 return data->mot_position[index];
157RobotinoSensorInterface::maxlenof_mot_position()
const
167RobotinoSensorInterface::set_mot_position(
const int32_t * new_mot_position)
169 set_field(data->mot_position, new_mot_position);
178RobotinoSensorInterface::set_mot_position(
unsigned int index,
const int32_t new_mot_position)
180 set_field(data->mot_position, index, new_mot_position);
187RobotinoSensorInterface::mot_current()
const
189 return data->mot_current;
199RobotinoSensorInterface::mot_current(
unsigned int index)
const
202 throw Exception(
"Index value %u out of bounds (0..2)", index);
204 return data->mot_current[index];
212RobotinoSensorInterface::maxlenof_mot_current()
const
222RobotinoSensorInterface::set_mot_current(
const float * new_mot_current)
224 set_field(data->mot_current, new_mot_current);
233RobotinoSensorInterface::set_mot_current(
unsigned int index,
const float new_mot_current)
235 set_field(data->mot_current, index, new_mot_current);
242RobotinoSensorInterface::is_bumper()
const
252RobotinoSensorInterface::maxlenof_bumper()
const
262RobotinoSensorInterface::set_bumper(
const bool new_bumper)
264 set_field(data->bumper, new_bumper);
272RobotinoSensorInterface::distance()
const
274 return data->distance;
284RobotinoSensorInterface::distance(
unsigned int index)
const
287 throw Exception(
"Index value %u out of bounds (0..8)", index);
289 return data->distance[index];
297RobotinoSensorInterface::maxlenof_distance()
const
307RobotinoSensorInterface::set_distance(
const float * new_distance)
309 set_field(data->distance, new_distance);
318RobotinoSensorInterface::set_distance(
unsigned int index,
const float new_distance)
320 set_field(data->distance, index, new_distance);
327RobotinoSensorInterface::is_digital_in()
const
329 return data->digital_in;
339RobotinoSensorInterface::is_digital_in(
unsigned int index)
const
342 throw Exception(
"Index value %u out of bounds (0..7)", index);
344 return data->digital_in[index];
352RobotinoSensorInterface::maxlenof_digital_in()
const
362RobotinoSensorInterface::set_digital_in(
const bool * new_digital_in)
364 set_field(data->digital_in, new_digital_in);
373RobotinoSensorInterface::set_digital_in(
unsigned int index,
const bool new_digital_in)
375 set_field(data->digital_in, index, new_digital_in);
382RobotinoSensorInterface::is_digital_out()
const
384 return data->digital_out;
394RobotinoSensorInterface::is_digital_out(
unsigned int index)
const
397 throw Exception(
"Index value %u out of bounds (0..7)", index);
399 return data->digital_out[index];
407RobotinoSensorInterface::maxlenof_digital_out()
const
417RobotinoSensorInterface::set_digital_out(
const bool * new_digital_out)
419 set_field(data->digital_out, new_digital_out);
428RobotinoSensorInterface::set_digital_out(
unsigned int index,
const bool new_digital_out)
430 set_field(data->digital_out, index, new_digital_out);
437RobotinoSensorInterface::analog_in()
const
439 return data->analog_in;
449RobotinoSensorInterface::analog_in(
unsigned int index)
const
452 throw Exception(
"Index value %u out of bounds (0..7)", index);
454 return data->analog_in[index];
462RobotinoSensorInterface::maxlenof_analog_in()
const
472RobotinoSensorInterface::set_analog_in(
const float * new_analog_in)
474 set_field(data->analog_in, new_analog_in);
483RobotinoSensorInterface::set_analog_in(
unsigned int index,
const float new_analog_in)
485 set_field(data->analog_in, index, new_analog_in);
494RobotinoSensorInterface::is_bumper_estop_enabled()
const
496 return data->bumper_estop_enabled;
504RobotinoSensorInterface::maxlenof_bumper_estop_enabled()
const
516RobotinoSensorInterface::set_bumper_estop_enabled(
const bool new_bumper_estop_enabled)
518 set_field(data->bumper_estop_enabled, new_bumper_estop_enabled);
523RobotinoSensorInterface::create_message(
const char *type)
const
525 if ( strncmp(
"SetBumperEStopEnabledMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
527 }
else if ( strncmp(
"SetDigitalOutputMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
531 "message type for this interface type.", type);
540RobotinoSensorInterface::copy_values(
const Interface *other)
545 type(), other->
type());
547 memcpy(data, oi->data,
sizeof(RobotinoSensorInterface_data_t));
551RobotinoSensorInterface::enum_tostring(
const char *enumtype,
int val)
const
567RobotinoSensorInterface::SetBumperEStopEnabledMessage::SetBumperEStopEnabledMessage(
const bool ini_enabled) :
Message(
"SetBumperEStopEnabledMessage")
569 data_size =
sizeof(SetBumperEStopEnabledMessage_data_t);
572 data = (SetBumperEStopEnabledMessage_data_t *)
data_ptr;
574 data->enabled = ini_enabled;
580 data_size =
sizeof(SetBumperEStopEnabledMessage_data_t);
583 data = (SetBumperEStopEnabledMessage_data_t *)
data_ptr;
602 data = (SetBumperEStopEnabledMessage_data_t *)
data_ptr;
617 return data->enabled;
666 data_size =
sizeof(SetDigitalOutputMessage_data_t);
669 data = (SetDigitalOutputMessage_data_t *)
data_ptr;
671 data->digital_out = ini_digital_out;
672 data->enabled = ini_enabled;
679 data_size =
sizeof(SetDigitalOutputMessage_data_t);
682 data = (SetDigitalOutputMessage_data_t *)
data_ptr;
702 data = (SetDigitalOutputMessage_data_t *)
data_ptr;
716 return data->digital_out;
738 set_field(data->digital_out, new_digital_out);
750 return data->enabled;
Base class for exceptions in Fawkes.
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.
SetBumperEStopEnabledMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
void set_enabled(const bool new_enabled)
Set enabled value.
~SetBumperEStopEnabledMessage()
Destructor.
virtual Message * clone() const
Clone this message.
SetBumperEStopEnabledMessage()
Constructor.
bool is_enabled() const
Get enabled value.
SetDigitalOutputMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
void set_enabled(const bool new_enabled)
Set enabled value.
void set_digital_out(const uint8_t new_digital_out)
Set digital_out value.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
size_t maxlenof_digital_out() const
Get maximum length of digital_out value.
uint8_t digital_out() const
Get digital_out value.
SetDigitalOutputMessage()
Constructor.
bool is_enabled() const
Get enabled value.
~SetDigitalOutputMessage()
Destructor.
RobotinoSensorInterface Fawkes BlackBoard Interface.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Fawkes library namespace.
@ IFT_UINT8
8 bit unsigned integer field
Timestamp data, must be present and first entries for each interface data structs!...