24 #include <interfaces/RobotinoSensorInterface.h>
26 #include <core/exceptions/software.h>
42 RobotinoSensorInterface::RobotinoSensorInterface() : Interface()
44 data_size =
sizeof(RobotinoSensorInterface_data_t);
45 data_ptr = malloc(data_size);
46 data = (RobotinoSensorInterface_data_t *)data_ptr;
47 data_ts = (interface_data_ts_t *)data_ptr;
48 memset(data_ptr, 0, data_size);
49 add_fieldinfo(IFT_FLOAT,
"mot_velocity", 3, &data->mot_velocity);
50 add_fieldinfo(IFT_INT32,
"mot_position", 3, &data->mot_position);
51 add_fieldinfo(IFT_FLOAT,
"mot_current", 3, &data->mot_current);
52 add_fieldinfo(IFT_BOOL,
"bumper", 1, &data->bumper);
53 add_fieldinfo(IFT_FLOAT,
"distance", 9, &data->distance);
54 add_fieldinfo(IFT_BOOL,
"digital_in", 8, &data->digital_in);
55 add_fieldinfo(IFT_FLOAT,
"analog_in", 8, &data->analog_in);
56 add_fieldinfo(IFT_BOOL,
"gyro_available", 1, &data->gyro_available);
57 add_fieldinfo(IFT_FLOAT,
"gyro_angle", 1, &data->gyro_angle);
58 add_fieldinfo(IFT_FLOAT,
"gyro_rate", 1, &data->gyro_rate);
59 unsigned char tmp_hash[] = {0xfe, 0x8a, 0xcf, 0x8f, 0xe8, 0xb9, 0xf, 0x3b, 0x35, 0x3b, 0x1a, 0xea, 0xe7, 0x59, 0xab, 0xc8};
64 RobotinoSensorInterface::~RobotinoSensorInterface()
74 RobotinoSensorInterface::mot_velocity()
const
76 return data->mot_velocity;
86 RobotinoSensorInterface::mot_velocity(
unsigned int index)
const
89 throw Exception(
"Index value %u out of bounds (0..3)", index);
91 return data->mot_velocity[index];
99 RobotinoSensorInterface::maxlenof_mot_velocity()
const
109 RobotinoSensorInterface::set_mot_velocity(
const float * new_mot_velocity)
111 memcpy(data->mot_velocity, new_mot_velocity,
sizeof(
float) * 3);
121 RobotinoSensorInterface::set_mot_velocity(
unsigned int index,
const float new_mot_velocity)
124 throw Exception(
"Index value %u out of bounds (0..3)", index);
126 data->mot_velocity[index] = new_mot_velocity;
134 RobotinoSensorInterface::mot_position()
const
136 return data->mot_position;
146 RobotinoSensorInterface::mot_position(
unsigned int index)
const
149 throw Exception(
"Index value %u out of bounds (0..3)", index);
151 return data->mot_position[index];
159 RobotinoSensorInterface::maxlenof_mot_position()
const
169 RobotinoSensorInterface::set_mot_position(
const int32_t * new_mot_position)
171 memcpy(data->mot_position, new_mot_position,
sizeof(int32_t) * 3);
181 RobotinoSensorInterface::set_mot_position(
unsigned int index,
const int32_t new_mot_position)
184 throw Exception(
"Index value %u out of bounds (0..3)", index);
186 data->mot_position[index] = new_mot_position;
194 RobotinoSensorInterface::mot_current()
const
196 return data->mot_current;
206 RobotinoSensorInterface::mot_current(
unsigned int index)
const
209 throw Exception(
"Index value %u out of bounds (0..3)", index);
211 return data->mot_current[index];
219 RobotinoSensorInterface::maxlenof_mot_current()
const
229 RobotinoSensorInterface::set_mot_current(
const float * new_mot_current)
231 memcpy(data->mot_current, new_mot_current,
sizeof(
float) * 3);
241 RobotinoSensorInterface::set_mot_current(
unsigned int index,
const float new_mot_current)
244 throw Exception(
"Index value %u out of bounds (0..3)", index);
246 data->mot_current[index] = new_mot_current;
254 RobotinoSensorInterface::is_bumper()
const
264 RobotinoSensorInterface::maxlenof_bumper()
const
274 RobotinoSensorInterface::set_bumper(
const bool new_bumper)
276 data->bumper = new_bumper;
285 RobotinoSensorInterface::distance()
const
287 return data->distance;
297 RobotinoSensorInterface::distance(
unsigned int index)
const
300 throw Exception(
"Index value %u out of bounds (0..9)", index);
302 return data->distance[index];
310 RobotinoSensorInterface::maxlenof_distance()
const
320 RobotinoSensorInterface::set_distance(
const float * new_distance)
322 memcpy(data->distance, new_distance,
sizeof(
float) * 9);
332 RobotinoSensorInterface::set_distance(
unsigned int index,
const float new_distance)
335 throw Exception(
"Index value %u out of bounds (0..9)", index);
337 data->distance[index] = new_distance;
345 RobotinoSensorInterface::is_digital_in()
const
347 return data->digital_in;
357 RobotinoSensorInterface::is_digital_in(
unsigned int index)
const
360 throw Exception(
"Index value %u out of bounds (0..8)", index);
362 return data->digital_in[index];
370 RobotinoSensorInterface::maxlenof_digital_in()
const
380 RobotinoSensorInterface::set_digital_in(
const bool * new_digital_in)
382 memcpy(data->digital_in, new_digital_in,
sizeof(
bool) * 8);
392 RobotinoSensorInterface::set_digital_in(
unsigned int index,
const bool new_digital_in)
395 throw Exception(
"Index value %u out of bounds (0..8)", index);
397 data->digital_in[index] = new_digital_in;
405 RobotinoSensorInterface::analog_in()
const
407 return data->analog_in;
417 RobotinoSensorInterface::analog_in(
unsigned int index)
const
420 throw Exception(
"Index value %u out of bounds (0..8)", index);
422 return data->analog_in[index];
430 RobotinoSensorInterface::maxlenof_analog_in()
const
440 RobotinoSensorInterface::set_analog_in(
const float * new_analog_in)
442 memcpy(data->analog_in, new_analog_in,
sizeof(
float) * 8);
452 RobotinoSensorInterface::set_analog_in(
unsigned int index,
const float new_analog_in)
455 throw Exception(
"Index value %u out of bounds (0..8)", index);
457 data->analog_in[index] = new_analog_in;
465 RobotinoSensorInterface::is_gyro_available()
const
467 return data->gyro_available;
475 RobotinoSensorInterface::maxlenof_gyro_available()
const
485 RobotinoSensorInterface::set_gyro_available(
const bool new_gyro_available)
487 data->gyro_available = new_gyro_available;
496 RobotinoSensorInterface::gyro_angle()
const
498 return data->gyro_angle;
506 RobotinoSensorInterface::maxlenof_gyro_angle()
const
516 RobotinoSensorInterface::set_gyro_angle(
const float new_gyro_angle)
518 data->gyro_angle = new_gyro_angle;
527 RobotinoSensorInterface::gyro_rate()
const
529 return data->gyro_rate;
537 RobotinoSensorInterface::maxlenof_gyro_rate()
const
547 RobotinoSensorInterface::set_gyro_rate(
const float new_gyro_rate)
549 data->gyro_rate = new_gyro_rate;
555 RobotinoSensorInterface::create_message(
const char *type)
const
558 "message type for this interface type.", type);
566 RobotinoSensorInterface::copy_values(
const Interface *other)
571 type(), other->
type());
573 memcpy(data, oi->data,
sizeof(RobotinoSensorInterface_data_t));
577 RobotinoSensorInterface::enum_tostring(
const char *enumtype,
int val)
const
588 RobotinoSensorInterface::message_valid(
const Message *message)
const
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Fawkes library namespace.
Base class for all Fawkes BlackBoard interfaces.
RobotinoSensorInterface Fawkes BlackBoard Interface.
Base class for exceptions in Fawkes.
const char * type() const
Get type of interface.