Fawkes API
Fawkes Development Version
|
Laser acqusition thread. More...
#include "acquisition_thread.h"
Public Member Functions | |
LaserAcquisitionThread (const char *thread_name) | |
Constructor. | |
bool | lock_if_new_data () |
Lock data if fresh. | |
void | unlock () |
Unlock data,. | |
virtual void | pre_init (fawkes::Configuration *config, fawkes::Logger *logger)=0 |
Pre initialization. | |
const float * | get_distance_data () |
Get distance data. | |
const float * | get_echo_data () |
Get echo data. | |
unsigned int | get_distance_data_size () |
Get distance data size. | |
unsigned int | get_echo_data_size () |
Get echo data size. | |
Protected Member Functions | |
virtual void | run () |
Stub to see name in backtrace for easier debugging. | |
void | alloc_distances (unsigned int num_distances) |
Allocate distances array. | |
void | alloc_echoes (unsigned int num_echoes) |
Allocate echoes array. | |
Protected Attributes | |
fawkes::Mutex * | _data_mutex |
Lock while writing to distances or echoes array or marking new data. | |
bool | _new_data |
Set to true in your loop if new data is available. | |
float * | _distances |
Allocate a float array and copy your distance values measured in meters here. | |
float * | _echoes |
Allocate a float array and copy your echo values here. | |
unsigned int | _distances_size |
Assign this the size of the _distances array. | |
unsigned int | _echoes_size |
Assign this the size of the _echoes array. |
Laser acqusition thread.
Interface for different laser types.
LaserAcquisitionThread::LaserAcquisitionThread | ( | const char * | thread_name | ) |
Constructor.
thread_name | name of the thread, be descriptive |
Definition at line 75 of file acquisition_thread.cpp.
References _data_mutex, _new_data, _distances, _echoes, _distances_size, and _echoes_size.
void LaserAcquisitionThread::alloc_distances | ( | unsigned int | num_distances | ) | [protected] |
Allocate distances array.
Call this from a laser acqusition thread implementation to properly initialize the distances array.
num_distances | number of distances to allocate the array for |
Definition at line 167 of file acquisition_thread.cpp.
References _distances, and _distances_size.
Referenced by HokuyoUrgAcquisitionThread::init(), and HokuyoUrgGbxAcquisitionThread::init().
void LaserAcquisitionThread::alloc_echoes | ( | unsigned int | num_echoes | ) | [protected] |
Allocate echoes array.
Call this from a laser acqusition thread implementation to properly initialize the echoes array.
num_echoes | number of echoes to allocate the array for |
Definition at line 183 of file acquisition_thread.cpp.
References _echoes, and _echoes_size.
const float * LaserAcquisitionThread::get_distance_data | ( | ) |
Get distance data.
Definition at line 123 of file acquisition_thread.cpp.
References _new_data, and _distances.
Referenced by LaserSensorThread::loop().
unsigned int LaserAcquisitionThread::get_distance_data_size | ( | ) |
Get distance data size.
Definition at line 145 of file acquisition_thread.cpp.
References _distances_size.
Referenced by LaserSensorThread::init(), and LaserSensorThread::loop().
const float * LaserAcquisitionThread::get_echo_data | ( | ) |
Get echo data.
Definition at line 134 of file acquisition_thread.cpp.
unsigned int LaserAcquisitionThread::get_echo_data_size | ( | ) |
Get echo data size.
Definition at line 155 of file acquisition_thread.cpp.
References _echoes_size.
bool LaserAcquisitionThread::lock_if_new_data | ( | ) |
Lock data if fresh.
If new data has been received since get_distance_data() or get_echo_data() was called last the data is locked, no new data can arrive until you call unlock(), otherwise the lock is immediately released after checking.
Definition at line 99 of file acquisition_thread.cpp.
References _data_mutex, fawkes::Mutex::lock(), _new_data, and fawkes::Mutex::unlock().
Referenced by LaserSensorThread::loop().
void LaserAcquisitionThread::pre_init | ( | fawkes::Configuration * | config, |
fawkes::Logger * | logger | ||
) | [pure virtual] |
Pre initialization.
This method is called by the sensor thread for pre-initialization. After this method has been executed the methods get_distances_data_size() and get_echo_data_size() must return valid data.
config | configuration |
logger | logger instance |
Implemented in HokuyoUrgAcquisitionThread, LaseEdlAcquisitionThread, and HokuyoUrgGbxAcquisitionThread.
Referenced by LaserSensorThread::init().
virtual void LaserAcquisitionThread::run | ( | ) | [inline, protected, virtual] |
Stub to see name in backtrace for easier debugging.
Reimplemented from fawkes::Thread.
Definition at line 60 of file acquisition_thread.h.
void LaserAcquisitionThread::unlock | ( | ) |
Unlock data,.
Definition at line 113 of file acquisition_thread.cpp.
References _data_mutex, and fawkes::Mutex::unlock().
Referenced by LaserSensorThread::loop().
fawkes::Mutex * LaserAcquisitionThread::_data_mutex [protected] |
Lock while writing to distances or echoes array or marking new data.
Definition at line 67 of file acquisition_thread.h.
Referenced by LaserAcquisitionThread(), lock_if_new_data(), unlock(), HokuyoUrgAcquisitionThread::loop(), and HokuyoUrgGbxAcquisitionThread::loop().
float * LaserAcquisitionThread::_distances [protected] |
Allocate a float array and copy your distance values measured in meters here.
Definition at line 70 of file acquisition_thread.h.
Referenced by LaserAcquisitionThread(), get_distance_data(), alloc_distances(), LaseEdlAcquisitionThread::init(), LaseEdlAcquisitionThread::finalize(), HokuyoUrgAcquisitionThread::finalize(), HokuyoUrgAcquisitionThread::loop(), HokuyoUrgGbxAcquisitionThread::finalize(), and HokuyoUrgGbxAcquisitionThread::loop().
unsigned int LaserAcquisitionThread::_distances_size [protected] |
Assign this the size of the _distances array.
Definition at line 73 of file acquisition_thread.h.
Referenced by LaserAcquisitionThread(), get_distance_data_size(), alloc_distances(), LaseEdlAcquisitionThread::pre_init(), HokuyoUrgAcquisitionThread::pre_init(), and HokuyoUrgGbxAcquisitionThread::pre_init().
float * LaserAcquisitionThread::_echoes [protected] |
Allocate a float array and copy your echo values here.
Definition at line 71 of file acquisition_thread.h.
Referenced by LaserAcquisitionThread(), get_echo_data(), alloc_echoes(), LaseEdlAcquisitionThread::init(), and LaseEdlAcquisitionThread::finalize().
unsigned int LaserAcquisitionThread::_echoes_size [protected] |
Assign this the size of the _echoes array.
Definition at line 74 of file acquisition_thread.h.
Referenced by LaserAcquisitionThread(), get_echo_data_size(), alloc_echoes(), and LaseEdlAcquisitionThread::pre_init().
bool LaserAcquisitionThread::_new_data [protected] |
Set to true in your loop if new data is available.
Set to false automatically in get_distance_data() and get_echoes_data().
Definition at line 69 of file acquisition_thread.h.
Referenced by LaserAcquisitionThread(), lock_if_new_data(), get_distance_data(), get_echo_data(), HokuyoUrgAcquisitionThread::loop(), and HokuyoUrgGbxAcquisitionThread::loop().