23 #include "sensor_thread.h"
24 #include "acquisition_thread.h"
26 #include <interfaces/Laser360Interface.h>
27 #include <interfaces/Laser720Interface.h>
45 std::string &cfg_prefix,
47 :
Thread(
"LaserSensorThread",
Thread::OPMODE_WAITFORWAKEUP),
50 set_name(
"LaserSensorThread(%s)", cfg_name.c_str());
52 __cfg_name = cfg_name;
53 __cfg_prefix = cfg_prefix;
63 bool main_sensor =
false;
68 main_sensor =
config->
get_bool((__cfg_prefix +
"main_sensor").c_str());
75 std::string if_id = main_sensor ?
"Laser" : (
"Laser " + __cfg_name);
77 if (__num_values == 360) {
79 __laser360_if->
set_frame(__cfg_frame.c_str());
80 __laser360_if->
write();
81 }
else if (__num_values == 720){
83 __laser720_if->
set_frame(__cfg_frame.c_str());
84 __laser720_if->
write();
86 throw Exception(
"Laser acquisition thread must produce either 360 or 720 "
104 if (__num_values == 360) {
106 __laser360_if->
write();
107 }
else if (__num_values == 720) {
109 __laser720_if->
write();
Laser360Interface Fawkes BlackBoard Interface.
unsigned int get_distance_data_size()
Get distance data size.
void set_frame(const char *new_frame)
Set frame value.
void set_frame(const char *new_frame)
Set frame value.
Fawkes library namespace.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual void pre_init(fawkes::Configuration *config, fawkes::Logger *logger)=0
Pre initialization.
virtual void init()
Initialize the thread.
Thread class encapsulation of pthreads.
void write()
Write from local copy into BlackBoard memory.
void set_distances(unsigned int index, const float new_distances)
Set distances value at given index.
Logger * logger
This is the Logger member used to access the logger.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier)=0
Open interface for writing.
LaserSensorThread(std::string &cfg_name, std::string &cfg_prefix, LaserAcquisitionThread *aqt)
Constructor.
Thread aspect to use blocked timing.
virtual void loop()
Code to execute in the thread.
void set_name(const char *format,...)
Set name of thread.
Base class for exceptions in Fawkes.
virtual void finalize()
Finalize the thread.
const float * get_distance_data()
Get distance data.
void unlock()
Unlock data,.
void set_distances(unsigned int index, const float new_distances)
Set distances value at given index.
bool lock_if_new_data()
Lock data if fresh.
Configuration * config
This is the Configuration member used to access the configuration.
Laser720Interface Fawkes BlackBoard Interface.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
virtual void close(Interface *interface)=0
Close interface.