LaserAcquisitionThread Class Reference

Laser acqusition thread. More...

#include <acquisition_thread.h>

Inheritance diagram for LaserAcquisitionThread:
Inheritance graph
[legend]

List of all members.

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.

Detailed Description

Laser acqusition thread.

Interface for different laser types.

Author:
Tim Niemueller

Definition at line 37 of file acquisition_thread.h.


Constructor & Destructor Documentation

LaserAcquisitionThread::LaserAcquisitionThread ( const char *  thread_name  ) 

Constructor.

Parameters:
thread_name name of the thread, be descriptive

Definition at line 75 of file acquisition_thread.cpp.

References _data_mutex, _distances, _distances_size, _echoes, _echoes_size, and _new_data.


Member Function Documentation

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.

Parameters:
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 HokuyoUrgGbxAcquisitionThread::init(), and HokuyoUrgAcquisitionThread::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.

Parameters:
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.

Returns:
Float array with distance values

Definition at line 123 of file acquisition_thread.cpp.

References _distances, and _new_data.

Referenced by LaserSensorThread::loop().

unsigned int LaserAcquisitionThread::get_distance_data_size (  ) 

Get distance data size.

Returns:
size of data float array

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.

Returns:
Float array with echo values

Definition at line 134 of file acquisition_thread.cpp.

References _echoes, and _new_data.

unsigned int LaserAcquisitionThread::get_echo_data_size (  ) 

Get echo data size.

Returns:
size of data float array

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.

Returns:
true if the lock was acquired and there is new data, false otherwise

Definition at line 99 of file acquisition_thread.cpp.

References _data_mutex, _new_data, fawkes::Mutex::lock(), 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.

Parameters:
config configuration
logger logger instance

Implemented in LaseEdlAcquisitionThread, HokuyoUrgAcquisitionThread, and HokuyoUrgGbxAcquisitionThread.

Referenced by LaserSensorThread::init().

virtual void LaserAcquisitionThread::run (  )  [inline, protected, virtual]

Stub to see name in backtrace for easier debugging.

See also:
Thread::run()

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().


Member Data Documentation

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(), HokuyoUrgGbxAcquisitionThread::loop(), HokuyoUrgAcquisitionThread::loop(), and unlock().

unsigned int LaserAcquisitionThread::_distances_size [protected]
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 alloc_echoes(), LaseEdlAcquisitionThread::finalize(), get_echo_data(), LaseEdlAcquisitionThread::init(), and LaserAcquisitionThread().

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 alloc_echoes(), get_echo_data_size(), LaserAcquisitionThread(), and LaseEdlAcquisitionThread::pre_init().

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 get_distance_data(), get_echo_data(), LaserAcquisitionThread(), lock_if_new_data(), HokuyoUrgGbxAcquisitionThread::loop(), and HokuyoUrgAcquisitionThread::loop().


The documentation for this class was generated from the following files:

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1