AURobotServers  4
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ULaserData Class Reference

#include <ulaserdataset.h>

Inheritance diagram for ULaserData:
Inheritance graph

Public Member Functions

bool addMeasurement (ULaserMeasurement *source)
 
bool addMeasurements (int count, double startAngle, double stride)
 
void clear ()
 
void copy (ULaserData *source)
 
U2Dpos get2d (int index, int set=0)
 
double getAngle ()
 
double getAngleDeg (int index)
 
double getAngleRad (int index)
 
double getAngleResolutionDeg ()
 
double getAngleResolutionRad ()
 
double getAngleStart ()
 
double getAngleStartRad ()
 
virtual const char * getDataType ()
 
int getDeviceNum ()
 
double getDistance ()
 
UPose getFakePose ()
 
UPoseTVQ getFakePoseTime ()
 
int getFlag ()
 
int * getFlags (int index)
 
double getMaxAngleDeg ()
 
double getMaxValidRange ()
 
ULaserMeasurementgetMeasurement (int idx)
 
double getMeasurementAngleDeg (int index)
 
int getMeasurementsCnt ()
 
int getMeasurementSetCnt (int set)
 
int getMeasurementSetsCnt ()
 
double getMinAngleDeg ()
 
UPosition getPosition (UPosition laserPos, double cosLaserTilt)
 
UPosition getPosition (UMatrix4 *movLtoR)
 
int getRangeCnt (int set=0)
 
double getRangeMeter (int index, bool *rangeValid=NULL, int set=0)
 
double getRangeMetre (int index, bool *rangeValid=NULL, int set=0)
 
int getRangeRaw (int index, int set)
 
UTime getScanTime ()
 
double getSdL ()
 
unsigned long getSerial ()
 
double getTilt ()
 
int getUnit ()
 
double getVarL ()
 
bool inZoneA ()
 
bool inZoneB ()
 
bool isDazzled ()
 
bool isFake ()
 
bool isMeasurementStructure ()
 
bool isMirror ()
 
bool isValid ()
 
void print (char *prestring)
 
void print (char *preString)
 
void reInitMeasurements ()
 
bool saveToLogFile (FILE *logfile)
 
void setAngleResAndStart (double start, double res)
 
void setDeviceNum (int value)
 
void setFakeDataRad (double minAng, double maxAng, double resolution, double minRange, double maxRange, UPose sourcePose, UPosRot sensorPose, int fakeMode)
 
void setFakePose (UPose pose)
 
bool setFromTag (USmlTag *tag)
 
void setMaxValidRange (double value)
 
void setMeasurement (int idx, int set, int range)
 
void setMirror (bool value)
 
void setRangeCnt (int value)
 
void setScanTime (UTime value)
 
void setSerial (const unsigned long value)
 
void setSimData (double minAng, double maxAng, double resolution, double minRange, double maxRange, UPose sourcePose, UPosRot sensorPose, int fake)
 
void setUnit (int toUnit)
 
void setValid (bool value)
 
void setValue (double ang, unsigned char lsb, unsigned char msb, double measurementUnits)
 
void setValue (double ang, double distance, bool inA, bool inB, bool inZ)
 
void setValue (int idx, unsigned char lsb, unsigned char msb)
 
 ULaserData ()
 
 ULaserData ()
 
 ~ULaserData ()
 
- Public Member Functions inherited from UDataBase
bool isA (const char *typeString)
 
virtual bool isAlsoA (const char *typeString)
 
virtual void snprint (const char *preString, char *buff, const int buffCnt)
 
 UDataBase ()
 
virtual ~UDataBase ()
 
- Public Member Functions inherited from ULock
bool lock ()
 
void lockInit ()
 
void post ()
 
bool tryLock ()
 
bool tryWait ()
 
 ULock ()
 
void unlock ()
 
bool wait ()
 
 ~ULock ()
 

Protected Member Functions

int * getRange (int index)
 

Protected Attributes

double angleResolution
 
double angleStart
 
int device
 
bool fake
 
UPoseV fakePose
 
int flags [MAX_RANGE_VALUES]
 
ULaserMeasurement ** laserMeasurement
 pointer array More...
 
int laserMeasurementCnt
 size of pointer array - rangeCnt is number of used values More...
 
int laserMeasurementMaxCnt
 size of pointer array - rangeCnt is number of used values More...
 
int laserMeasurementSetCnt [5]
 number of (non-zero) measurements in each range bin More...
 
double maxValidRange
 
int range [MAX_RANGE_VALUES]
 
int rangeCnt
 
UTime scanTime
 
unsigned long serial
 
int unit
 
bool useLaserMeasurementStructure
 
bool valid
 

Private Attributes

double angle
 
int flag
 
double range
 
double tilt
 
double varL
 

Detailed Description

Class to hold one measurement of a laser scan

Laser values in integer array, with flag support

Author
Christian Andersen

Constructor & Destructor Documentation

ULaserData::ULaserData ( )

Constructor

References flag.

Referenced by ULaserMeasurement::clear(), and UFakeMap::getPink().

ULaserData::ULaserData ( )

Constructor

ULaserData::~ULaserData ( )

Destructor

References bool2str(), print(), and ULaserMeasurement::rangeCnt.

Referenced by ULaserMeasurement::clear().

Member Function Documentation

bool ULaserData::addMeasurement ( ULaserMeasurement source)

Add a measurement to the list of known measurements The source is copied - not just linked.

Returns
0 (false) if failed

References ULaserMeasurement::angle, ULaserMeasurement::flags, ULaserMeasurement::intens, ULaserMeasurement::MAX_VALUES_PER_ANGLE, ULaserMeasurement::range, ULaserMeasurement::rangeCnt, and ULaserMeasurement::ULaserMeasurement().

Referenced by ULaserMeasurement::clear().

bool ULaserData::addMeasurements ( int  count,
double  startAngle,
double  stride 
)

Allocate this number of measurements, and set angle values

Returns
0 (false) if failed is number of measureements to add is first angle (in degrees relative to forward (positive is clockwise) is angle distance between measurements (in degrees)

References ULaserMeasurement::angle, and ULaserMeasurement::ULaserMeasurement().

Referenced by ULaserMeasurement::clear(), USickData::getDataTo(), ULms100::getDataTo(), ULms500::getDataTo(), UHokuyo::getDataTo(), UV360Scan::getScan(), and UReplayDevice::replayStep().

void ULaserData::clear ( void  )

set all values to default in old structure format (not measurement) but allocated memory for measurements are not cleared, just count, not maxCount

References ULaserMeasurement::rangeCnt.

Referenced by ULaserMeasurement::clear(), USick::getNewestData(), ULaserPi::setFromTag(), UPlannerValue::setFromTag(), ULaserDataSet::ULaserDataSet(), and UPlannerValue::UPlannerValue().

void ULaserData::copy ( ULaserData source)
U2Dpos ULaserData::get2d ( int  index,
int  set = 0 
)

Get range measurement as x,y coordinate in laser scanner coordinates.

Parameters
intindex to measurement (up to getRangeCnt() - 1)
setis dataset number if more than one range per angle (0..4) x,y in metre, or 0,0 if not a valid measurement.

References a, U2Dpos::clear(), ULaserMeasurement::range, ULaserMeasurement::rangeCnt, U2Dpos::x, and U2Dpos::y.

Referenced by ULaserMeasurement::clear(), and UNamedBox::doDetect().

double ULaserData::getAngle ( )
inline
double ULaserData::getAngleDeg ( int  index)
inline

Get angle for this measurement. NB! no range check for index. Returns angle in degrees, 0 is front, left is positive.

Referenced by Funcavoid::findHuller(), Funcavoid::findSpring(), handlePeopleDetection(), and UFunctionLaser::sendScan().

double ULaserData::getAngleRad ( int  index)
inline
double ULaserData::getAngleResolutionDeg ( )
inline

Get resolution angle (in degrees). If scanner is mounted upside down then the start angle is positive, and the resolution negative.

Referenced by ULaserMeasurement::clear(), copy(), USickData::getDataTo(), and UFunctionLaser::sendScan().

double ULaserData::getAngleResolutionRad ( )
inline

Get resolution angle (in radians) Resolution is the angular interval between measurements. If scanner is mounted upside down then the start angle is positive, and the resolution negative.

Referenced by UV360Scan::update().

double ULaserData::getAngleStart ( )
inline

Get start angle (in degrees, center is 0, right is negative). If scanner is mounted upside down then the start angle is positive, and the resolution negative.

Referenced by ULaserMeasurement::clear(), copy(), USickData::getDataTo(), and ULaserScan::setScan().

double ULaserData::getAngleStartRad ( )
inline

Get start angle (in radians, center is 0, left is positive). If scanner is mounted upside down then the start angle is positive, and the resolution negative.

Referenced by UV360Scan::update().

virtual const char* ULaserData::getDataType ( )
inlinevirtual

Get (end) type of this structure

Reimplemented from UDataBase.

int ULaserData::getDeviceNum ( )
inline
double ULaserData::getDistance ( )
inline

Get measured distance

References range.

Referenced by UClientFuncLaserGui::doImage(), getPosition(), and UClientFuncLaserGui::paintHistScan().

UPose ULaserData::getFakePose ( )
inline

Get faked pose - only valid if the data actually is faked, and the fake method uses a pose to generate the data

Referenced by ULaserMeasurement::clear(), copy(), UFuncEfLine::getCurrentOdoPose(), UFunctionPassable::handlePass(), UFunctionLaser::sendScan(), and UResV360::update().

UPoseTVQ ULaserData::getFakePoseTime ( )
inline

Get faked pose - only valid if the data actually is faked, and the fake method uses a pose to generate the data

References UPoseTVQ::q, UPoseTVQ::set(), and UPoseTime::t.

Referenced by UFunctionLaser::handleScanGetCommand().

int ULaserData::getFlag ( )
inline

Is measurement dazzeled (measurement is not valid)

References flag.

Referenced by UClientFuncLaserGui::paintHistScan(), and UClientFuncLaserGui::paintScanStatData().

int* ULaserData::getFlags ( int  index)
inline

Get pointer to measurement flag values with this index. NB! no range test for index (or value)

Referenced by ULaserMeasurement::clear(), copy(), USickData::getDataTo(), ULms100::getDataTo(), UV360Scan::getScan(), UReplayDevice::replayStep(), and UFunctionLaser::sendScan().

double ULaserData::getMaxAngleDeg ( )

Get maximum (leftmost) angle

References maxd(), and ULaserMeasurement::rangeCnt.

Referenced by ULaserMeasurement::clear().

double ULaserData::getMaxValidRange ( )
inline
ULaserMeasurement * ULaserData::getMeasurement ( int  idx)

het laser measurement structure with this index

Parameters
idxid element to get - in received order
Returns
pointer to element

Referenced by ULaserMeasurement::clear(), and copy().

double ULaserData::getMeasurementAngleDeg ( int  index)

Get angle of this measurement

Parameters
indexis measurement number.
Returns
value in degrees

References ULaserMeasurement::angle.

Referenced by ULaserMeasurement::clear().

int ULaserData::getMeasurementsCnt ( )
inline

Get number og measurements allocated (number of angles in scan)

int ULaserData::getMeasurementSetCnt ( int  set)
inline

Get statistics of valid measurements in each dataset

Parameters
setis the set number 0..4
Returns
measurement count 0..laserMeasurementCnt

Referenced by ULaserMeasurement::clear(), and copy().

int ULaserData::getMeasurementSetsCnt ( )
inline
double ULaserData::getMinAngleDeg ( )

Get minimum (rightmost) angle

References mind(), and ULaserMeasurement::rangeCnt.

Referenced by ULaserMeasurement::clear().

UPosition ULaserData::getPosition ( UPosition  laserPos,
double  cosLaserTilt 
)

Get position as 3D relative to robot, when laser is positioned at laserPos - assuming same orientation

References getAngle(), getDistance(), UPosition::x, and UPosition::y.

Referenced by UClientFuncLaserGui::doRepaint(), getTilt(), UClientFuncLaserGui::paintHistScan(), and UClientFuncLaserGui::paintScanStatData().

UPosition ULaserData::getPosition ( UMatrix4 movLtoR)

Get position in robot coordinates using full pose set

References getAngle(), getDistance(), UPosition::x, UPosition::y, and UPosition::z.

int* ULaserData::getRange ( int  index)
inlineprotected

Get pointer to range measurement with this index. NB! no range check on index.

Referenced by ULaserMeasurement::clear(), copy(), and handlePeopleDetection().

int ULaserData::getRangeCnt ( int  set = 0)
inline
double ULaserData::getRangeMeter ( int  index,
bool *  rangeValid = NULL,
int  set = 0 
)
double ULaserData::getRangeMetre ( int  index,
bool *  rangeValid = NULL,
int  set = 0 
)
inline

Get range measurement in meter with this index. Returns range in meter (same call as below, but different spelling).

Referenced by UV360Scan::update().

int ULaserData::getRangeRaw ( int  index,
int  set 
)

Get range in integer with the default scaling

Parameters
indexindex to value (angle)
setis measurement set - up to 5, default is 0 (all others than lms5xx
Returns
range as integer - in used scaling, e.g. mm

References ULaserMeasurement::range, and ULaserMeasurement::rangeCnt.

Referenced by ULaserMeasurement::clear(), and UFunctionLaser::sendScan().

UTime ULaserData::getScanTime ( )
inline
double ULaserData::getSdL ( )
inline

Get measurement deviation to the left

References varL.

Referenced by UClientFuncLaserGui::paintScanStatData().

unsigned long ULaserData::getSerial ( )
inline
double ULaserData::getTilt ( )
inline

Get combined variance to the left Get combined deviation to the left Get measurement variance to the left Get measurement variance to the right

References getPosition(), print(), setFromTag(), and tilt.

Referenced by UClientFuncLaserGui::paintScanStatData().

int ULaserData::getUnit ( )
inline

Get unit measurement unit 0 = cm, 1 = mm, 2 = 10cm

Referenced by ULaserMeasurement::clear(), copy(), handlePeopleDetection(), and UFunctionLaser::sendScan().

double ULaserData::getVarL ( )
inline

Get measurement variance Get measurement variance to the left

References varL.

bool ULaserData::inZoneA ( )
inline
bool ULaserData::inZoneB ( )
inline
bool ULaserData::isDazzled ( )
inline

Is measurement dazzeled (measurement is not valid)

References flag.

Referenced by UClientFuncLaserGui::doRepaint(), UClientFuncLaserGui::paintHistScan(), and print().

bool ULaserData::isFake ( )
inline

Is the data based on one of the fixed fake scenarios

Referenced by ULaserMeasurement::clear(), copy(), UFuncEfLine::getCurrentOdoPose(), and UFunctionLaser::handleScanGetCommand().

bool ULaserData::isMeasurementStructure ( )
inline

is it new or old structure

Returns
true if new structure

Referenced by ULaserMeasurement::clear(), and copy().

bool ULaserData::isMirror ( )
inline

Is the dataset mirrored. This is set to be true if the resolution value is set negative (corresponding to the missor flag is set true)

Referenced by UFunctionLaser::sendScan().

bool ULaserData::isValid ( )
inline
void ULaserData::print ( char *  prestring)

Print metadata for this set:

void ULaserData::print ( char *  preString)

Get measurement edge value Get measurement curvature value Print values of this measurement

References angle, inZoneA(), inZoneB(), isDazzled(), and range.

Referenced by ULaserMeasurement::clear(), ULaserDataSet::getLaserTilt(), getTilt(), ULaserDataSet::print(), and ~ULaserData().

void ULaserData::reInitMeasurements ( )

Reinit angle settings in allstored measurements to be used when changing mirror or width

References ULaserMeasurement::angle, and ULaserMeasurement::ULaserMeasurement().

Referenced by ULaserMeasurement::clear(), and UHokuyo::getDataTo().

bool ULaserData::saveToLogFile ( FILE *  logfile)

Write data to logfile. 'logfile' must be open in write mode. Returns true if successfull.

References ULaserMeasurement::rangeCnt.

Referenced by ULaserMeasurement::clear(), and ULaserDevice::logThisScan().

void ULaserData::setAngleResAndStart ( double  start,
double  res 
)
inline

Set angle start and resolution

Parameters
startangle is for first measurement.
resis increment for each measurement. Both values are in degrees. zero angle is forwardt. e.g. start=-90.0 res=1.0 fits for 181 measurements with 1 deg resolution for a SICK laser

Referenced by USick::getNewestData(), UClientFuncSimScan::handleLaserScan(), and UReplayDevice::replayStep().

void ULaserData::setDeviceNum ( int  value)
inline
void ULaserData::setFakeDataRad ( double  minAng,
double  maxAng,
double  resolution,
double  minRange,
double  maxRange,
UPose  sourcePose,
UPosRot  sensorPose,
int  fakeMode 
)

Fill random simulated data into structure all angles in radians. fakeMode is: 0 = not fake data. 1 = random data. 2,3,4 = fake corridor data.

References a, fakeMap, ULaserMeasurement::flags, UFakeMap::getFake2range(), UPosRot::getPhi(), UPosRot::getZ(), MAX_RANGE_VALUES, maxd(), maxi(), mini(), ULaserMeasurement::range, ULaserMeasurement::rangeCnt, and roundi().

Referenced by ULaserMeasurement::clear().

void ULaserData::setFakePose ( UPose  pose)
inline

Set faked pose - used to set a pose relevant to the scandata.

Referenced by UFunctionPassable::handlePass(), and UFunctionLaser::handleScanGetCommand().

bool ULaserData::setFromTag ( USmlTag tag)
void ULaserData::setMaxValidRange ( double  value)
inline

Advance a fake robot position (fake=2 or 3) a delta time of 'dt' in seconds. The state and startPose should be saved between calls. Returns the new pose after the advance (and this should be used as the new start pose at the next call. Set the maximum (valid) sensor range for sensor data

Referenced by ULms100::decodeData(), ULms500::decodeData(), ULaserDevice::getFakeScan(), ULaserSim::getNewestData(), USick::getNewestData(), UV360Scan::getScan(), ULaserSim::receiveData(), UHokuyo::receiveData(), and UReplayDevice::replayStep().

void ULaserData::setMeasurement ( int  idx,
int  set,
int  range 
)

set new range measurement

Parameters
idxis the index to measurement angle
setis distance measurement set (0..4)
rangeis range in mm

References ULaserMeasurement::MAX_VALUES_PER_ANGLE, ULaserMeasurement::range, and ULaserMeasurement::rangeCnt.

Referenced by ULaserMeasurement::clear(), USickData::getDataTo(), ULms100::getDataTo(), ULms500::getDataTo(), UHokuyo::getDataTo(), UV360Scan::getScan(), and UReplayDevice::replayStep().

void ULaserData::setMirror ( bool  value)
void ULaserData::setRangeCnt ( int  value)
inline
void ULaserData::setScanTime ( UTime  value)
inline
void ULaserData::setSerial ( const unsigned long  value)
inline
void ULaserData::setSimData ( double  minAng,
double  maxAng,
double  resolution,
double  minRange,
double  maxRange,
UPose  sourcePose,
UPosRot  sensorPose,
int  fake 
)

Fill random simulated data into structure NB! min- maxAng and resolution in degrees - range [-180,180]

Referenced by ULaserMeasurement::clear(), and ULaserDevice::getFakeScan().

void ULaserData::setUnit ( int  toUnit)
inline

Get range measurement in metre with this index. Returns range in metre. Set unit measurement unit 0 = cm, 1 = mm, 2 = 10cm

Referenced by ULms100::decodeData(), ULms500::decodeData(), UHokuyo::decodeData(), USickData::getDataTo(), UV360Scan::getScan(), UClientFuncSimScan::handleLaserScan(), and UReplayDevice::replayStep().

void ULaserData::setValid ( bool  value)
inline
void ULaserData::setValue ( double  ang,
unsigned char  lsb,
unsigned char  msb,
double  measurementUnits 
)
void ULaserData::setValue ( double  ang,
double  distance,
bool  inA,
bool  inB,
bool  inZ 
)

Set values from tag data

void ULaserData::setValue ( int  idx,
unsigned char  lsb,
unsigned char  msb 
)

Member Data Documentation

double ULaserData::angle
private

Edge value Curvature value Angle of measurement in radians

Referenced by getAngle(), print(), setFromTag(), and setValue().

double ULaserData::angleResolution
protected

angle resolution in degrees

double ULaserData::angleStart
protected

Start angle - zero is front

int ULaserData::device
protected

Device number for data

bool ULaserData::fake
protected

Are the current range data from a fake source - set true on fake update and false on setAngleResAnsStart()

UPoseV ULaserData::fakePose
protected

Fake robot pose (for fake = 2 or 3)

int ULaserData::flag
private

Measuremnt is in zone A

Referenced by getFlag(), inZoneA(), inZoneB(), isDazzled(), setFromTag(), setValue(), and ULaserData().

int ULaserData::flags[MAX_RANGE_VALUES]
protected

Flag value related to range measurements

ULaserMeasurement** ULaserData::laserMeasurement
protected

pointer array

int ULaserData::laserMeasurementCnt
protected

size of pointer array - rangeCnt is number of used values

Referenced by ULaserMeasurement::clear(), and copy().

int ULaserData::laserMeasurementMaxCnt
protected

size of pointer array - rangeCnt is number of used values

int ULaserData::laserMeasurementSetCnt[5]
protected

number of (non-zero) measurements in each range bin

double ULaserData::maxValidRange
protected

Maximum (valid) laser range. for sick laser it should be set some distance less than max range to allow to assert range validity.

double ULaserData::range
private

Measuremnt is in zone B Measuremnt is dazzled - not valid e.g. in sunshine debug variable - not used Distance in meter

Referenced by getDistance(), print(), setFromTag(), and setValue().

int ULaserData::range[MAX_RANGE_VALUES]
protected

Measured range values

int ULaserData::rangeCnt
protected

Number of valid ranges (not as measurements)

UTime ULaserData::scanTime
protected

Scantime

unsigned long ULaserData::serial
protected

Scannumber

Referenced by ULaserDataSet::setData().

double ULaserData::tilt
private

Combined variance and curvature tilt of line-fit

Referenced by getTilt(), and setFromTag().

int ULaserData::unit
protected

measurment unit: 0 = cm, 1 = mm, 2 = 10cm

Referenced by ULaserDataSet::print(), and ULaserDataSet::setData().

bool ULaserData::useLaserMeasurementStructure
protected

Get fake range using fake=2 option Advance robot position towards target pose in total 'dt' seconds. Returns the distance to the the target position. Make fake map and path Is new structure used - else just range[...]

bool ULaserData::valid
protected
double ULaserData::varL
private

Variance Variance

Referenced by getSdL(), getVarL(), and setFromTag().


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