MipBaselib::Scan Class Reference

Represents a laser scan. More...

#include <Scan.h>

List of all members.

Public Member Functions

 Scan ()
 Default constructor.
 Scan (ScanTypes type)
 Type constructor.
 Scan (Rays r, Time t)
 Complete constructor in m.
 Scan (Raymms r, Time t)
 Complete constructor in mm.
 Scan (const Scan &s)
 Copy constructor.
Scanoperator= (const Scan &s)
 Assigment operator =.
bool operator== (Scan &s)
 Compound operator ==.
bool operator!= (Scan &s)
 Compound operator !=.
bool getConeAmplitude (Decimal &coneAmplitude)
 Writes the cone amplitude in &coneAmplitude.
bool getScanAngle (Decimal &scanAngle)
 Writes the scan angle in &scanAngle.
bool askExclusiveAccess (Time timeout)
void leaveExclusiveAccess ()
 Release the scan resources.
bool allowed ()
 Says if this thread is allowed.
bool reserve (int n)
 Reserve a ray dimension.
bool valid (bool &validity)
 Get scan validity.
bool getScanType (ScanTypes &type)
 Get scan type.
bool getSize (int &size)
 Get scan size.
Angle getAngRes ()
 Get the angular resolution of the Scan.
bool getTimeStamp (Time &timestamp)
 Get time stamp.
bool getRay (Ray &ray, int index)
 Get a ray in m.
bool getRay (Raymm &raymm, int index)
 Get a ray in mm.
bool setRay (Ray &ray, int index)
 Sets a ray given in m.
bool setRay (Raymm &raymm, int index)
 Sets a ray given in mm.
bool setTimeStamp (Time t)
 Set time-stamp.
bool addRay (const Ray r)
 Push back a ray in m.
bool addRay (const Raymm r)
 Push back a ray in mm.
bool clear ()
 Reset the scan.
bool voidReadings (Decimal minReading, Decimal maxReading)
 Sets valid to false in each ray having reading outside a certain interval (extremes included).
string print ()
 Print function.
void printJson (fstream &s)
 Print Json function.
UCoordmm unmutexedGetReading (int index)
 Get a reading in UCoordmm (implemented for efficiency).
bool unmutexedGetValid (int index)
 Get a valid (implemented for efficiency).


Detailed Description

Represents a laser scan.

The scan class contains a rays. Each ray has a reading and a bearing, corresponding respectively to the linear and angular coordinate in a polar system of coordinate. Each ray has also a boolean specifying the validity of that ray. Bearing and reading of a ray whose validity is false are not defined. A scan is also equiped with a mutex and an extern function is permitted to ask and leave exclusive access to it to avoid that another thread could modify it. If exclusive access is requested, is good programming to leave as soon as possible. It is important to always leave the exclusive access anyway. For this peculiarity, all get functions of the do not return directly the requested item. They return a boolean that is true if it is possible to retreive the requested item (no other thread has exclusive access) and false otherwise (another thtread has exclusive access). The requested item is stored in an argument passed for reference. The set functions have the same feature.
Another important characteristic of the Scan class is that it can be of two types. First type is Scan in m, in which all linear measures are expressed in m and stored in Decimal variables, while all angular measures are stored in Angle and expressed in radians. The Second type is Scan in mm, in which all linear measures are expressed in mm and stored in int variables, while all angular measures are stored in Anglem and expressed in hundredths of degree.

Author:
Antonio Franchi
Note:
Mutually thread access safe.

Rays can be only added, not removed, you can:
1) reset the scan by means clear() and overwrite all with addRay or assigment "="
2) using direcly the assignment
the scan it is considered valid from the first ray pushed in, when cleared it is resetted to invalid

Todo:
Change the use of size() in chech for assignement or element reading with the method .at which throw an exception.

Constructor & Destructor Documentation

MipBaselib::Scan::Scan (  )  [inline]

Default constructor.

MipBaselib::Scan::Scan ( ScanTypes  type  )  [inline]

Type constructor.

MipBaselib::Scan::Scan ( Rays  r,
Time  t 
)

Complete constructor in m.

Parameters:
[in] r Vector of Ray to fill the native vector _ray.
[in] t Time to be set.

MipBaselib::Scan::Scan ( Raymms  r,
Time  t 
)

Complete constructor in mm.

Parameters:
[in] r Vector of Raymm to fill the native vector _raymm.
[in] t Time to be set.

MipBaselib::Scan::Scan ( const Scan s  ) 

Copy constructor.

Parameters:
[in] &s Scan to be copied.


Member Function Documentation

Scan& MipBaselib::Scan::operator= ( const Scan s  )  [inline]

Assigment operator =.

bool MipBaselib::Scan::operator== ( Scan s  )  [inline]

Compound operator ==.

Return false if one of the scan is locked, if the types of the scans are different, if the size of the scans are different, if at least one pair of corresponding rays (or raymms according to the type) are different. Return true otherwise.

bool MipBaselib::Scan::operator!= ( Scan s  )  [inline]

Compound operator !=.

It returns !operator==.

bool MipBaselib::Scan::getConeAmplitude ( Decimal coneAmplitude  ) 

Writes the cone amplitude in &coneAmplitude.

Parameters:
[out] coneAmplitude The reference to the variable where to write the coneAmplitude.
Returns:
true if successfully written. false otherwise.

bool MipBaselib::Scan::getScanAngle ( Decimal scanAngle  ) 

Writes the scan angle in &scanAngle.

Parameters:
[out] scanAngle The reference to the variable where to write the s.
Returns:
true if successfully written. false otherwise.

bool MipBaselib::Scan::askExclusiveAccess ( Time  timeout  )  [inline]

Aks to use the scan resources.

Returns:
true if the resource can be used, false otherwise.
Parameters:
[out] timeout Maximum time to obtain exclusive access.
Note:
If it returns true it must be called a leaveExclusiveAccess() when read/write is completed.

void MipBaselib::Scan::leaveExclusiveAccess (  )  [inline]

Release the scan resources.

bool MipBaselib::Scan::allowed (  )  [inline]

Says if this thread is allowed.

Returns:
true if the thread is allowed, false otherwise.

bool MipBaselib::Scan::reserve ( int  n  )  [inline]

Reserve a ray dimension.

This method wrap the method reserve of _rays or _raymms according with the _scanType.

Parameters:
[in] n Dimension to be reserved.

bool MipBaselib::Scan::valid ( bool &  validity  )  [inline]

Get scan validity.

Returns:
true if succesfully get, false otherwise.
Parameters:
[out] &validity Returned validity.

bool MipBaselib::Scan::getScanType ( ScanTypes type  )  [inline]

Get scan type.

Returns:
true if succesfully get, false otherwise.
Parameters:
[out] &type Returned type.

bool MipBaselib::Scan::getSize ( int &  size  ) 

Get scan size.

Returns:
true if succesfully get, false otherwise.
Parameters:
[out] &size Returned size.

Angle MipBaselib::Scan::getAngRes (  )  [inline]

Get the angular resolution of the Scan.

Note:
just for compatibily, should not be used

bool MipBaselib::Scan::getTimeStamp ( Time timestamp  )  [inline]

Get time stamp.

Returns:
true if succesfully get, false otherwise.
Parameters:
[out] &timestamp Returned timestamp.

bool MipBaselib::Scan::getRay ( Ray ray,
int  index 
)

Get a ray in m.

Returns:
true if succesfully get, false otherwise.
Parameters:
[out] &ray Returned ray.
[in] index Index of the ray to be set.

bool MipBaselib::Scan::getRay ( Raymm raymm,
int  index 
)

Get a ray in mm.

Returns:
true if succesfully get, false otherwise.
Parameters:
[out] &raymm Returned ray.
[in] index Index of the ray to be set.

bool MipBaselib::Scan::setRay ( Ray ray,
int  index 
)

Sets a ray given in m.

Returns:
true if succesfully set, false otherwise.
Parameters:
[in] &ray Ray to copy.
[in] index Index of the ray to be set.

bool MipBaselib::Scan::setRay ( Raymm raymm,
int  index 
)

Sets a ray given in mm.

Returns:
true if succesfully set, false otherwise.
Parameters:
[in] &raymm Raymm to copy.
[in] index Index of the ray to be set.

bool MipBaselib::Scan::setTimeStamp ( Time  t  )  [inline]

Set time-stamp.

Returns:
true if succesfully set, false otherwise.
Parameters:
t Timestamp to set

bool MipBaselib::Scan::addRay ( const Ray  r  )  [inline]

Push back a ray in m.

Returns:
true if succesfully added, false otherwise.
Parameters:
[in] r Ray to add.
Todo:
Include the case of a SENS_SCANMM

bool MipBaselib::Scan::addRay ( const Raymm  r  )  [inline]

Push back a ray in mm.

Returns:
true if succesfully added, false otherwise.
Parameters:
[in] r Ray to add.
Todo:
Include the case of a SENS_SCAN

bool MipBaselib::Scan::clear ( void   )  [inline]

Reset the scan.

Returns:
true if succesfully cleared, false otherwise.

bool MipBaselib::Scan::voidReadings ( Decimal  minReading,
Decimal  maxReading 
)

Sets valid to false in each ray having reading outside a certain interval (extremes included).

Parameters:
[in] minReading Low value of the interval.
[in] maxReading Hi value of the interval.

string MipBaselib::Scan::print (  ) 

Print function.

Returns:
A printable string with the scan printed on it.

void MipBaselib::Scan::printJson ( fstream &  s  ) 

Print Json function.

Print the scan in Json Format on a filestream.

Todo:
Remake for the case of ScanType == SCAN_SENSMM

UCoordmm MipBaselib::Scan::unmutexedGetReading ( int  index  )  [inline]

Get a reading in UCoordmm (implemented for efficiency).

Returns:
true if succesfully get, false otherwise.
Parameters:
[in] index Index of the returned reading.
Note:
Only for SCAN_SENSMM. Never use if you don't know what you are doing.

bool MipBaselib::Scan::unmutexedGetValid ( int  index  )  [inline]

Get a valid (implemented for efficiency).

Returns:
true if succesfully get, false otherwise.
Parameters:
[in] index Index of the returned valid.
Note:
Only for SCAN_SENSMM. Never use if you don't know what you are doing.


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

Generated on Mon Feb 20 07:01:11 2017 for MIP by  doxygen 1.5.6