24 #include <interfaces/NaoSensorInterface.h> 26 #include <core/exceptions/software.h> 46 NaoSensorInterface::NaoSensorInterface() : Interface()
48 data_size =
sizeof(NaoSensorInterface_data_t);
50 data = (NaoSensorInterface_data_t *)
data_ptr;
53 enum_map_UltrasonicDirection[(int)USD_NONE] =
"USD_NONE";
54 enum_map_UltrasonicDirection[(int)USD_LEFT_LEFT] =
"USD_LEFT_LEFT";
55 enum_map_UltrasonicDirection[(int)USD_LEFT_RIGHT] =
"USD_LEFT_RIGHT";
56 enum_map_UltrasonicDirection[(int)USD_RIGHT_RIGHT] =
"USD_RIGHT_RIGHT";
57 enum_map_UltrasonicDirection[(int)USD_RIGHT_LEFT] =
"USD_RIGHT_LEFT";
58 enum_map_UltrasonicDirection[(int)USD_BOTH_BOTH] =
"USD_BOTH_BOTH";
83 add_fieldinfo(
IFT_ENUM,
"ultrasonic_direction", 1, &data->ultrasonic_direction,
"UltrasonicDirection", &enum_map_UltrasonicDirection);
96 unsigned char tmp_hash[] = {0x41, 0x41, 0x54, 0x94, 0xca, 0xe8, 0x3d, 0x7a, 0xb8, 0xaa, 0xc2, 0x4e, 0x2c, 0xac, 0xcb, 0x15};
101 NaoSensorInterface::~NaoSensorInterface()
113 case USD_NONE:
return "USD_NONE";
114 case USD_LEFT_LEFT:
return "USD_LEFT_LEFT";
115 case USD_LEFT_RIGHT:
return "USD_LEFT_RIGHT";
116 case USD_RIGHT_RIGHT:
return "USD_RIGHT_RIGHT";
117 case USD_RIGHT_LEFT:
return "USD_RIGHT_LEFT";
118 case USD_BOTH_BOTH:
return "USD_BOTH_BOTH";
119 default:
return "UNKNOWN";
130 return data->accel_x;
150 data->accel_x = new_accel_x;
161 return data->accel_y;
181 data->accel_y = new_accel_y;
192 return data->accel_z;
212 data->accel_z = new_accel_z;
243 data->gyro_x = new_gyro_x;
274 data->gyro_y = new_gyro_y;
285 return data->gyro_ref;
305 data->gyro_ref = new_gyro_ref;
316 return data->angle_x;
336 data->angle_x = new_angle_x;
347 return data->angle_y;
367 data->angle_y = new_angle_y;
378 return data->l_fsr_fl;
398 data->l_fsr_fl = new_l_fsr_fl;
409 return data->l_fsr_fr;
429 data->l_fsr_fr = new_l_fsr_fr;
440 return data->l_fsr_rl;
460 data->l_fsr_rl = new_l_fsr_rl;
471 return data->l_fsr_rr;
491 data->l_fsr_rr = new_l_fsr_rr;
502 return data->r_fsr_fl;
522 data->r_fsr_fl = new_r_fsr_fl;
533 return data->r_fsr_fr;
553 data->r_fsr_fr = new_r_fsr_fr;
564 return data->r_fsr_rl;
584 data->r_fsr_rl = new_r_fsr_rl;
595 return data->r_fsr_rr;
615 data->r_fsr_rr = new_r_fsr_rr;
626 return data->l_total_weight;
646 data->l_total_weight = new_l_total_weight;
657 return data->r_total_weight;
677 data->r_total_weight = new_r_total_weight;
688 return data->l_cop_x;
708 data->l_cop_x = new_l_cop_x;
719 return data->l_cop_y;
739 data->l_cop_y = new_l_cop_y;
750 return data->r_cop_x;
770 data->r_cop_x = new_r_cop_x;
781 return data->r_cop_y;
801 data->r_cop_y = new_r_cop_y;
815 return data->ultrasonic_distance_left;
831 throw Exception(
"Index value %u out of bounds (0..4)", index);
833 return data->ultrasonic_distance_left[index];
856 memcpy(data->ultrasonic_distance_left, new_ultrasonic_distance_left,
sizeof(
float) * 4);
872 throw Exception(
"Index value %u out of bounds (0..4)", index);
874 data->ultrasonic_distance_left[index] = new_ultrasonic_distance_left;
887 return data->ultrasonic_distance_right;
903 throw Exception(
"Index value %u out of bounds (0..4)", index);
905 return data->ultrasonic_distance_right[index];
928 memcpy(data->ultrasonic_distance_right, new_ultrasonic_distance_right,
sizeof(
float) * 4);
944 throw Exception(
"Index value %u out of bounds (0..4)", index);
946 data->ultrasonic_distance_right[index] = new_ultrasonic_distance_right;
980 data->ultrasonic_direction = new_ultrasonic_direction;
991 return data->l_foot_bumper_l;
1011 data->l_foot_bumper_l = new_l_foot_bumper_l;
1022 return data->l_foot_bumper_r;
1042 data->l_foot_bumper_r = new_l_foot_bumper_r;
1053 return data->r_foot_bumper_l;
1073 data->r_foot_bumper_l = new_r_foot_bumper_l;
1084 return data->r_foot_bumper_r;
1104 data->r_foot_bumper_r = new_r_foot_bumper_r;
1115 return data->head_touch_front;
1135 data->head_touch_front = new_head_touch_front;
1146 return data->head_touch_middle;
1166 data->head_touch_middle = new_head_touch_middle;
1177 return data->head_touch_rear;
1197 data->head_touch_rear = new_head_touch_rear;
1208 return data->chest_button;
1228 data->chest_button = new_chest_button;
1239 return data->battery_charge;
1259 data->battery_charge = new_battery_charge;
1267 if ( strncmp(
"EmitUltrasonicWaveMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
1269 }
else if ( strncmp(
"StartUltrasonicMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
1271 }
else if ( strncmp(
"StopUltrasonicMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
1275 "message type for this interface type.", type);
1291 memcpy(data, oi->data,
sizeof(NaoSensorInterface_data_t));
1297 if (strcmp(enumtype,
"UltrasonicDirection") == 0) {
1316 data_size =
sizeof(EmitUltrasonicWaveMessage_data_t);
1319 data = (EmitUltrasonicWaveMessage_data_t *)
data_ptr;
1321 data->ultrasonic_direction = ini_ultrasonic_direction;
1322 enum_map_UltrasonicDirection[(int)
USD_NONE] =
"USD_NONE";
1323 enum_map_UltrasonicDirection[(int)
USD_LEFT_LEFT] =
"USD_LEFT_LEFT";
1324 enum_map_UltrasonicDirection[(int)
USD_LEFT_RIGHT] =
"USD_LEFT_RIGHT";
1325 enum_map_UltrasonicDirection[(int)
USD_RIGHT_RIGHT] =
"USD_RIGHT_RIGHT";
1326 enum_map_UltrasonicDirection[(int)
USD_RIGHT_LEFT] =
"USD_RIGHT_LEFT";
1327 enum_map_UltrasonicDirection[(int)
USD_BOTH_BOTH] =
"USD_BOTH_BOTH";
1328 add_fieldinfo(
IFT_ENUM,
"ultrasonic_direction", 1, &data->ultrasonic_direction,
"UltrasonicDirection", &enum_map_UltrasonicDirection);
1333 data_size =
sizeof(EmitUltrasonicWaveMessage_data_t);
1336 data = (EmitUltrasonicWaveMessage_data_t *)
data_ptr;
1338 enum_map_UltrasonicDirection[(int)
USD_NONE] =
"USD_NONE";
1339 enum_map_UltrasonicDirection[(int)
USD_LEFT_LEFT] =
"USD_LEFT_LEFT";
1340 enum_map_UltrasonicDirection[(int)
USD_LEFT_RIGHT] =
"USD_LEFT_RIGHT";
1341 enum_map_UltrasonicDirection[(int)
USD_RIGHT_RIGHT] =
"USD_RIGHT_RIGHT";
1342 enum_map_UltrasonicDirection[(int)
USD_RIGHT_LEFT] =
"USD_RIGHT_LEFT";
1343 enum_map_UltrasonicDirection[(int)
USD_BOTH_BOTH] =
"USD_BOTH_BOTH";
1344 add_fieldinfo(
IFT_ENUM,
"ultrasonic_direction", 1, &data->ultrasonic_direction,
"UltrasonicDirection", &enum_map_UltrasonicDirection);
1361 data = (EmitUltrasonicWaveMessage_data_t *)
data_ptr;
1397 data->ultrasonic_direction = new_ultrasonic_direction;
1422 data_size =
sizeof(StartUltrasonicMessage_data_t);
1425 data = (StartUltrasonicMessage_data_t *)
data_ptr;
1427 data->ultrasonic_direction = ini_ultrasonic_direction;
1428 enum_map_UltrasonicDirection[(int)
USD_NONE] =
"USD_NONE";
1429 enum_map_UltrasonicDirection[(int)
USD_LEFT_LEFT] =
"USD_LEFT_LEFT";
1430 enum_map_UltrasonicDirection[(int)
USD_LEFT_RIGHT] =
"USD_LEFT_RIGHT";
1431 enum_map_UltrasonicDirection[(int)
USD_RIGHT_RIGHT] =
"USD_RIGHT_RIGHT";
1432 enum_map_UltrasonicDirection[(int)
USD_RIGHT_LEFT] =
"USD_RIGHT_LEFT";
1433 enum_map_UltrasonicDirection[(int)
USD_BOTH_BOTH] =
"USD_BOTH_BOTH";
1434 add_fieldinfo(
IFT_ENUM,
"ultrasonic_direction", 1, &data->ultrasonic_direction,
"UltrasonicDirection", &enum_map_UltrasonicDirection);
1439 data_size =
sizeof(StartUltrasonicMessage_data_t);
1442 data = (StartUltrasonicMessage_data_t *)
data_ptr;
1444 enum_map_UltrasonicDirection[(int)
USD_NONE] =
"USD_NONE";
1445 enum_map_UltrasonicDirection[(int)
USD_LEFT_LEFT] =
"USD_LEFT_LEFT";
1446 enum_map_UltrasonicDirection[(int)
USD_LEFT_RIGHT] =
"USD_LEFT_RIGHT";
1447 enum_map_UltrasonicDirection[(int)
USD_RIGHT_RIGHT] =
"USD_RIGHT_RIGHT";
1448 enum_map_UltrasonicDirection[(int)
USD_RIGHT_LEFT] =
"USD_RIGHT_LEFT";
1449 enum_map_UltrasonicDirection[(int)
USD_BOTH_BOTH] =
"USD_BOTH_BOTH";
1450 add_fieldinfo(
IFT_ENUM,
"ultrasonic_direction", 1, &data->ultrasonic_direction,
"UltrasonicDirection", &enum_map_UltrasonicDirection);
1467 data = (StartUltrasonicMessage_data_t *)
data_ptr;
1503 data->ultrasonic_direction = new_ultrasonic_direction;
1526 data_size =
sizeof(StopUltrasonicMessage_data_t);
1529 data = (StopUltrasonicMessage_data_t *)
data_ptr;
1531 enum_map_UltrasonicDirection[(int)
USD_NONE] =
"USD_NONE";
1532 enum_map_UltrasonicDirection[(int)
USD_LEFT_LEFT] =
"USD_LEFT_LEFT";
1533 enum_map_UltrasonicDirection[(int)
USD_LEFT_RIGHT] =
"USD_LEFT_RIGHT";
1534 enum_map_UltrasonicDirection[(int)
USD_RIGHT_RIGHT] =
"USD_RIGHT_RIGHT";
1535 enum_map_UltrasonicDirection[(int)
USD_RIGHT_LEFT] =
"USD_RIGHT_LEFT";
1536 enum_map_UltrasonicDirection[(int)
USD_BOTH_BOTH] =
"USD_BOTH_BOTH";
1553 data = (StopUltrasonicMessage_data_t *)
data_ptr;
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
uint8_t r_foot_bumper_r() const
Get r_foot_bumper_r value.
void * data_ptr
Pointer to memory that contains local data.
void set_l_fsr_rl(const float new_l_fsr_rl)
Set l_fsr_rl value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
size_t maxlenof_ultrasonic_direction() const
Get maximum length of ultrasonic_direction value.
void set_r_foot_bumper_r(const uint8_t new_r_foot_bumper_r)
Set r_foot_bumper_r value.
size_t maxlenof_r_fsr_fl() const
Get maximum length of r_fsr_fl value.
void set_accel_x(const float new_accel_x)
Set accel_x value.
StopUltrasonicMessage()
Constructor.
StopUltrasonicMessage Fawkes BlackBoard Interface Message.
uint8_t l_foot_bumper_l() const
Get l_foot_bumper_l value.
void set_l_fsr_fl(const float new_l_fsr_fl)
Set l_fsr_fl value.
EmitUltrasonicWaveMessage()
Constructor.
size_t maxlenof_l_cop_x() const
Get maximum length of l_cop_x value.
size_t maxlenof_ultrasonic_distance_left() const
Get maximum length of ultrasonic_distance_left value.
UltrasonicDirection ultrasonic_direction() const
Get ultrasonic_direction value.
void set_hash(unsigned char *ihash)
Set hash.
size_t maxlenof_battery_charge() const
Get maximum length of battery_charge value.
size_t maxlenof_l_fsr_fl() const
Get maximum length of l_fsr_fl value.
void set_head_touch_front(const uint8_t new_head_touch_front)
Set head_touch_front value.
void set_chest_button(const uint8_t new_chest_button)
Set chest_button value.
float r_fsr_fr() const
Get r_fsr_fr value.
size_t maxlenof_head_touch_middle() const
Get maximum length of head_touch_middle value.
void set_accel_z(const float new_accel_z)
Set accel_z value.
size_t maxlenof_r_fsr_fr() const
Get maximum length of r_fsr_fr value.
Fawkes library namespace.
size_t maxlenof_r_total_weight() const
Get maximum length of r_total_weight value.
8 bit unsigned integer field
float l_fsr_rl() const
Get l_fsr_rl value.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
Right emitter and right receiver.
size_t maxlenof_ultrasonic_distance_right() const
Get maximum length of ultrasonic_distance_right value.
unsigned int data_size
Minimal data size to hold data storage.
void set_l_fsr_rr(const float new_l_fsr_rr)
Set l_fsr_rr value.
float l_fsr_fl() const
Get l_fsr_fl value.
Right emitter and left receiver.
size_t maxlenof_l_fsr_rl() const
Get maximum length of l_fsr_rl value.
float l_fsr_rr() const
Get l_fsr_rr value.
void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction)
Set ultrasonic_direction value.
void set_l_total_weight(const float new_l_total_weight)
Set l_total_weight value.
float accel_x() const
Get accel_x value.
StartUltrasonicMessage Fawkes BlackBoard Interface Message.
void set_r_total_weight(const float new_r_total_weight)
Set r_total_weight value.
UltrasonicDirection ultrasonic_direction() const
Get ultrasonic_direction value.
void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction)
Set ultrasonic_direction value.
uint8_t l_foot_bumper_r() const
Get l_foot_bumper_r value.
virtual Message * clone() const
Clone this message.
NaoSensorInterface Fawkes BlackBoard Interface.
void set_l_cop_y(const float new_l_cop_y)
Set l_cop_y value.
size_t maxlenof_angle_y() const
Get maximum length of angle_y value.
Base class for all Fawkes BlackBoard interfaces.
float * ultrasonic_distance_right() const
Get ultrasonic_distance_right value.
float angle_x() const
Get angle_x value.
void set_gyro_y(const float new_gyro_y)
Set gyro_y value.
void set_battery_charge(const float new_battery_charge)
Set battery_charge value.
size_t maxlenof_gyro_ref() const
Get maximum length of gyro_ref value.
float * ultrasonic_distance_left() const
Get ultrasonic_distance_left value.
size_t maxlenof_accel_y() const
Get maximum length of accel_y value.
message_data_ts_t * data_ts
data timestamp aliasing pointer
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 field info list.
size_t maxlenof_head_touch_front() const
Get maximum length of head_touch_front value.
unsigned int data_size
Size of memory needed to hold all data.
size_t maxlenof_gyro_y() const
Get maximum length of gyro_y value.
void set_r_fsr_fr(const float new_r_fsr_fr)
Set r_fsr_fr value.
size_t maxlenof_r_foot_bumper_l() const
Get maximum length of r_foot_bumper_l value.
void add_messageinfo(const char *name)
Add an entry to the message info list.
void set_ultrasonic_distance_right(unsigned int index, const float new_ultrasonic_distance_right)
Set ultrasonic_distance_right value at given index.
size_t maxlenof_r_fsr_rr() const
Get maximum length of r_fsr_rr value.
float r_fsr_fl() const
Get r_fsr_fl value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
bool data_changed
Indicator if data has changed.
void set_r_fsr_fl(const float new_r_fsr_fl)
Set r_fsr_fl value.
size_t maxlenof_gyro_x() const
Get maximum length of gyro_x value.
UltrasonicDirection
This determines the chosen sender/receiver.
void set_r_cop_y(const float new_r_cop_y)
Set r_cop_y value.
const char * type() const
Get type of interface.
void * data_ptr
Pointer to local memory storage.
float l_fsr_fr() const
Get l_fsr_fr value.
Base class for exceptions in Fawkes.
void set_gyro_x(const float new_gyro_x)
Set gyro_x value.
~StartUltrasonicMessage()
Destructor.
float gyro_ref() const
Get gyro_ref value.
float r_cop_y() const
Get r_cop_y value.
Both emitters and both receivers.
size_t maxlenof_head_touch_rear() const
Get maximum length of head_touch_rear value.
void set_angle_y(const float new_angle_y)
Set angle_y value.
StartUltrasonicMessage()
Constructor.
virtual Message * create_message(const char *type) const
Create message based on type name.
Left emitter and left receiver.
float accel_y() const
Get accel_y value.
~EmitUltrasonicWaveMessage()
Destructor.
void set_accel_y(const float new_accel_y)
Set accel_y value.
float accel_z() const
Get accel_z value.
void set_l_foot_bumper_r(const uint8_t new_l_foot_bumper_r)
Set l_foot_bumper_r value.
~StopUltrasonicMessage()
Destructor.
uint8_t chest_button() const
Get chest_button value.
size_t maxlenof_ultrasonic_direction() const
Get maximum length of ultrasonic_direction value.
void set_l_cop_x(const float new_l_cop_x)
Set l_cop_x value.
size_t maxlenof_l_total_weight() const
Get maximum length of l_total_weight value.
void set_r_foot_bumper_l(const uint8_t new_r_foot_bumper_l)
Set r_foot_bumper_l value.
float l_cop_y() const
Get l_cop_y value.
float angle_y() const
Get angle_y value.
void set_l_fsr_fr(const float new_l_fsr_fr)
Set l_fsr_fr value.
size_t maxlenof_chest_button() const
Get maximum length of chest_button value.
void set_head_touch_rear(const uint8_t new_head_touch_rear)
Set head_touch_rear value.
size_t maxlenof_r_foot_bumper_r() const
Get maximum length of r_foot_bumper_r value.
virtual Message * clone() const
Clone this message.
float gyro_y() const
Get gyro_y value.
float r_fsr_rl() const
Get r_fsr_rl value.
void set_l_foot_bumper_l(const uint8_t new_l_foot_bumper_l)
Set l_foot_bumper_l value.
size_t maxlenof_r_cop_x() const
Get maximum length of r_cop_x value.
float l_total_weight() const
Get l_total_weight value.
size_t maxlenof_ultrasonic_direction() const
Get maximum length of ultrasonic_direction value.
size_t maxlenof_accel_z() const
Get maximum length of accel_z value.
float r_cop_x() const
Get r_cop_x value.
size_t maxlenof_l_fsr_rr() const
Get maximum length of l_fsr_rr value.
float gyro_x() const
Get gyro_x value.
uint8_t head_touch_rear() const
Get head_touch_rear value.
uint8_t r_foot_bumper_l() const
Get r_foot_bumper_l value.
void set_r_fsr_rl(const float new_r_fsr_rl)
Set r_fsr_rl value.
UltrasonicDirection ultrasonic_direction() const
Get ultrasonic_direction value.
size_t maxlenof_l_cop_y() const
Get maximum length of l_cop_y value.
EmitUltrasonicWaveMessage Fawkes BlackBoard Interface Message.
void set_ultrasonic_distance_left(unsigned int index, const float new_ultrasonic_distance_left)
Set ultrasonic_distance_left value at given index.
void set_r_fsr_rr(const float new_r_fsr_rr)
Set r_fsr_rr value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_l_foot_bumper_l() const
Get maximum length of l_foot_bumper_l value.
interface_data_ts_t * data_ts
Pointer to data casted to timestamp struct.
size_t maxlenof_r_cop_y() const
Get maximum length of r_cop_y 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.
float battery_charge() const
Get battery_charge value.
No transmission received, yet.
uint8_t head_touch_front() const
Get head_touch_front value.
float l_cop_x() const
Get l_cop_x value.
size_t maxlenof_r_fsr_rl() const
Get maximum length of r_fsr_rl value.
void set_r_cop_x(const float new_r_cop_x)
Set r_cop_x value.
size_t maxlenof_accel_x() const
Get maximum length of accel_x value.
float r_fsr_rr() const
Get r_fsr_rr value.
void set_ultrasonic_direction(const UltrasonicDirection new_ultrasonic_direction)
Set ultrasonic_direction value.
field with interface specific enum type
size_t maxlenof_l_fsr_fr() const
Get maximum length of l_fsr_fr value.
float r_total_weight() const
Get r_total_weight value.
const char * tostring_UltrasonicDirection(UltrasonicDirection value) const
Convert UltrasonicDirection constant to string.
void set_head_touch_middle(const uint8_t new_head_touch_middle)
Set head_touch_middle value.
size_t maxlenof_angle_x() const
Get maximum length of angle_x value.
Left emitter and right receiver.
uint8_t head_touch_middle() const
Get head_touch_middle value.
size_t maxlenof_l_foot_bumper_r() const
Get maximum length of l_foot_bumper_r value.
void set_angle_x(const float new_angle_x)
Set angle_x value.
void set_gyro_ref(const float new_gyro_ref)
Set gyro_ref value.