23 #include "sensor_thread.h"
25 #include "acquisition_thread.h"
27 #include <interfaces/Laser1080Interface.h>
28 #include <interfaces/Laser360Interface.h>
29 #include <interfaces/Laser720Interface.h>
46 std::string & cfg_prefix,
48 :
Thread(
"LaserSensorThread",
Thread::OPMODE_WAITFORWAKEUP),
51 set_name(
"LaserSensorThread(%s)", cfg_name.c_str());
54 cfg_prefix_ = cfg_prefix;
64 bool main_sensor =
false;
69 main_sensor =
config->
get_bool((cfg_prefix_ +
"main_sensor").c_str());
77 std::string if_id = main_sensor ?
"Laser" : (
"Laser " + cfg_name_);
79 if (num_values_ == 360) {
82 laser360_if_->
set_frame(cfg_frame_.c_str());
83 laser360_if_->
write();
84 }
else if (num_values_ == 720) {
87 laser720_if_->
set_frame(cfg_frame_.c_str());
88 laser720_if_->
write();
89 }
else if (num_values_ == 1080) {
92 laser1080_if_->
set_frame(cfg_frame_.c_str());
93 laser1080_if_->
write();
95 throw Exception(
"Laser acquisition thread must produce either 360, 720, or 1080 "
96 "distance values, but it produces %u",
113 if (num_values_ == 360) {
116 laser360_if_->
write();
117 }
else if (num_values_ == 720) {
120 laser720_if_->
write();
121 }
else if (num_values_ == 1080) {
124 laser1080_if_->
write();
virtual void pre_init(fawkes::Configuration *config, fawkes::Logger *logger)=0
Pre initialization.
const fawkes::Time * get_timestamp()
Get timestamp of data.
const float * get_distance_data()
Get distance data.
void unlock()
Unlock data,.
unsigned int get_distance_data_size()
Get distance data size.
bool lock_if_new_data()
Lock data if fresh.
virtual void finalize()
Finalize the thread.
LaserSensorThread(std::string &cfg_name, std::string &cfg_prefix, LaserAcquisitionThread *aqt)
Constructor.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for writing.
virtual void close(Interface *interface)=0
Close interface.
Thread aspect to use blocked timing.
Configuration * config
This is the Configuration member used to access the configuration.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
Base class for exceptions in Fawkes.
void set_auto_timestamping(bool enabled)
Enable or disable automated timestamping.
void write()
Write from local copy into BlackBoard memory.
void set_timestamp(const Time *t=NULL)
Set timestamp.
Laser1080Interface Fawkes BlackBoard Interface.
void set_frame(const char *new_frame)
Set frame value.
void set_distances(unsigned int index, const float new_distances)
Set distances value at given index.
Laser360Interface Fawkes BlackBoard Interface.
void set_frame(const char *new_frame)
Set frame value.
void set_distances(unsigned int index, const float new_distances)
Set distances value at given index.
Laser720Interface Fawkes BlackBoard Interface.
void set_distances(unsigned int index, const float new_distances)
Set distances value at given index.
void set_frame(const char *new_frame)
Set frame value.
Logger * logger
This is the Logger member used to access the logger.
Thread class encapsulation of pthreads.
void set_name(const char *format,...)
Set name of thread.
Fawkes library namespace.