Fawkes API  Fawkes Development Version
LaserAcquisitionThread Class Reference

Laser acqusition thread. More...

#include "acquisition_thread.h"

Inheritance diagram for LaserAcquisitionThread:

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

Constructor & Destructor Documentation

LaserAcquisitionThread::LaserAcquisitionThread ( const char *  thread_name)

Constructor.

Parameters:
thread_namename of the thread, be descriptive

Definition at line 76 of file acquisition_thread.cpp.

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


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_distancesnumber of distances to allocate the array for

Definition at line 168 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.

Parameters:
num_echoesnumber of echoes to allocate the array for

Definition at line 186 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 124 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.

Returns:
size of data float array

Definition at line 146 of file acquisition_thread.cpp.

References _distances_size.

Referenced by LaserSensorThread::init().

const float * LaserAcquisitionThread::get_echo_data ( )

Get echo data.

Returns:
Float array with echo values

Definition at line 135 of file acquisition_thread.cpp.

References _new_data, and _echoes.

unsigned int LaserAcquisitionThread::get_echo_data_size ( )

Get echo data size.

Returns:
size of data float array

Definition at line 156 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 100 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.

Parameters:
configconfiguration
loggerlogger instance

Implemented in HokuyoUrgGbxAcquisitionThread, HokuyoUrgAcquisitionThread, and LaseEdlAcquisitionThread.

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

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

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


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