AURobotServers  4
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ULaserPool Class Reference

#include <ulaserpool.h>

Inheritance diagram for ULaserPool:
Inheritance graph

Public Member Functions

bool addDevice (ULaserDevice *newDevice)
 
ULaserDevicegetDefDevice ()
 
int getDefDeviceNumber ()
 
ULaserDevicegetDevice (int deviceNumber)
 
ULaserDevicegetDevice (const char *deviceID)
 
int getDeviceCnt ()
 
int getDeviceMax ()
 
int getDeviceNumber (ULaserDevice *device)
 
UPosRotgetDevicePose (int idx)
 
ULaserDatagetScan (const int device, ULaserDevice **las, ULaserData *dataBuff, ULaserData *pushData, const int fake)
 get the next scan from laser scanner device More...
 
ULaserDatagetScan (const char *device, ULaserDevice **las, ULaserData *dataBuff, ULaserData *pushData, const int fake)
 get the next scan from laser scanner device More...
 
bool gotAllResources (char *missingThese, int missingTheseCnt)
 
const char * print (const char *preString, char *buff, int buffCnt)
 
virtual void replayAdvanceTime (UTime untilTime)
 
virtual bool replayToTime (UTime untilTime)
 
void setCmdExe (UCmdExe *server)
 
void setDefDevice (int value)
 
bool setDefDevice (const char *device)
 
bool setResource (UResBase *ress, bool remove)
 
virtual void stop (bool andWait)
 
 ULaserPool ()
 
void ULaserPoolInit ()
 
 ~ULaserPool ()
 
- Public Member Functions inherited from UResVarPool
int addMethod (const char *formalName, const char *paramTypes, const char *comment)
 
int addMethodV (const char *formalName, const char *paramTypes, const char *comment)
 
UVarPooladdStruct (const char *name, const char *comment, bool copy=false)
 
UVariableaddVar (const char *name, const double initialValue, const char *type, const char *comment)
 
UVariableaddVar (const char *name, const char *initialValue, const char *type, const char *comment)
 
UVariableaddVarA (const char *name, const char *initialValue, const char *type, const char *comment)
 
bool callGlobal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
bool callGlobalV (const char *name, const char *paramOrder, UVariable **params, UDataBase **returnStruct, int *returnStructCnt)
 Call a method from the root var pool scope It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More...
 
bool callLocal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
bool callVS (const char *function, const char *stringParam)
 
int callVSCD (const char *function, const char *strPar, UDataBase *data, int cooSys)
 
void createBaseVar ()
 
virtual bool createVarSpace (const int varCnt, const int structCnt, const int methCnt, const char *note, bool copy=false)
 
bool getGlobalString (const char *name, const char **value)
 
bool getGlobalValue (const char *name, double *value)
 
bool getGlobalValue (const char *name, const char **value)
 
bool getGlobalValue (const char *name, bool *value)
 
bool getGlobalValue (const char *name, UTime *value)
 
bool getLocalValue (const char *name, double *value)
 get a value in this variable tree More...
 
bool getLocalValue (const char *name, bool *value)
 
bool getLocalValue (const char *name, UTime *value)
 
double getLocalValue (int idx)
 
UPosition getLocalValue3D (int idx)
 
UPosRot getLocalValue6D (int idx)
 
bool getLocalValueBool (int idx)
 
int getLocalValueInt (int idx)
 
UTime getLocalValueTime (int idx)
 
const char * getLogFileName ()
 
const char * getVarDescription (int idx)
 
UVarCalcgetVarPool ()
 
bool isLogFileOpen ()
 
bool isLogFileOpen (const char *structName)
 
bool isVarPoolUpdated (int lastCnt, int *newCnt)
 
void logFileClose ()
 
bool logFileOpen ()
 
void logFileStart (const char *structName, bool open)
 
virtual bool methodCall (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct=NULL, int *returnStructCnt=NULL)
 
bool setGlobalVar (const char *name, const double value, bool mayAdd)
 Assigns a value to a variable. The variable may be a part of a structure. More...
 
bool setLocalVar (int idx, double value, const int element)
 
bool setLocalVar (const char *name, const double value, bool mayAdd)
 Assigns a value to a variable. The variable may be a part of a structure. More...
 
bool setLocalVar3D (int idx, UPosition *value)
 
bool setLocalVar6D (int idx, UPosRot *value)
 
bool setLocalVarAdd (int idx, double value, const int element)
 
bool setLocalVarPose (int idx, UPose *value)
 
void setVarPool (UVarCalc *sharedVarPool)
 
int updateQTvars (int structIdx)
 
 UResVarPool ()
 
virtual ~UResVarPool ()
 
- Public Member Functions inherited from UResBase
void createReplayVar (UVarPool *pool)
 
virtual void createResources ()
 
UCmdExegetCorePointer ()
 
char * getLogFileName (char *fn, const int fnCnt)
 
int getResFuncIdx ()
 
const char * getResID ()
 
int getResVersion ()
 
bool isA (const char *idStr)
 
bool isAlsoA (const char *id)
 
virtual void print (const char *preString)
 
virtual void saveSettings ()
 
void setCorePointer (UCmdExe *serverCore)
 
void setResFuncIdx (int idx)
 
virtual void setResID (const char *id, const int version)
 
virtual void updateReplayStatus ()
 
 UResBase ()
 
virtual ~UResBase ()
 
- Public Member Functions inherited from UReplay
void addChild (UReplay *child)
 
virtual bool decodeReplayLine (char *)
 
char * getLogFileName (char *fn, const int fnCnt)
 
char * getReplayFileName (char *fn, const int fnCnt)
 
int getReplayLogLine ()
 
bool isReplay ()
 
bool isReplayFileOpen ()
 
void removeChild (UReplay *child)
 
void replaySetBaseFileName (const char *name, const char *preName="")
 
void replaySetFileName (const char *name)
 
virtual bool replayStep ()
 
int replayStep (int steps)
 
void setParent (UReplay *parent)
 
bool setReplay (bool value)
 
 UReplay ()
 
virtual ~UReplay ()
 
- Public Member Functions inherited from ULock
bool lock ()
 
void lockInit ()
 
void post ()
 
bool tryLock ()
 
bool tryWait ()
 
 ULock ()
 
void unlock ()
 
bool wait ()
 
 ~ULock ()
 
- Public Member Functions inherited from UVarMethodImplement
virtual bool methodCallV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct, int *returnStructCnt)
 
virtual ~UVarMethodImplement ()
 

Static Public Member Functions

static const char * getResClassID ()
 
- Static Public Member Functions inherited from UResVarPool
static const char * getResClassID ()
 

Protected Member Functions

void createBaseVar ()
 
- Protected Member Functions inherited from UResVarPool
void setDescription (const char *note, bool copy=false)
 
- Protected Member Functions inherited from UResBase
UResBasegetStaticResource (const char *resName, bool mayCreate, bool staticOnly=true)
 get a pointer to a static resource. More...
 

Protected Attributes

UCmdExecmdExe
 
ULaserDevicelasDevs [MAX_LASER_DEVS]
 
int lasDevsCnt
 
struct {
   UVariable *   def
 
   UVariable *   deviceCnt
 
   UVariable *   devices
 
var
 variable pointers More...
 
- Protected Attributes inherited from UResBase
int resFuncIdx
 
char resID [MAX_RESOURCE_ID_LENGTH]
 
char resIsAlso [MAX_RESOURCE_ISALSO_LENGTH]
 
int resVersion
 
- Protected Attributes inherited from UReplay
bool replay
 
FILE * replayFile
 
char replayFileName [REPLAY_FILE_NAME_LENGTH]
 replay filename More...
 
char replayLine [MAX_LOG_LINE_LENGTH]
 
int replayLogLine
 
UReplayreplayParent
 
UTime replayTimeNext
 

Additional Inherited Members

- Public Attributes inherited from UReplay
bool replayTimeAdvancePending
 
UTime replayTimeNow
 
- Static Protected Attributes inherited from UReplay
static const int MAX_LOG_LINE_LENGTH = 10000
 
static const int REPLAY_FILE_NAME_LENGTH = 264
 max length of replay filename More...
 

Detailed Description

Pool of laserscanner devices

Author
Christian Andersen

Constructor & Destructor Documentation

ULaserPool::ULaserPool ( )
inline
ULaserPool::~ULaserPool ( )

Destructor

References lasDevs, and lasDevsCnt.

Referenced by ULaserPool().

Member Function Documentation

bool ULaserPool::addDevice ( ULaserDevice newDevice)
void ULaserPool::createBaseVar ( )
protected

Make the variables that will be available to other plugins

References UResVarPool::addVar(), and var.

Referenced by getDeviceMax(), and ULaserPool().

ULaserDevice* ULaserPool::getDefDevice ( )
inline
int ULaserPool::getDefDeviceNumber ( )
inline
ULaserDevice * ULaserPool::getDevice ( int  deviceNumber)
ULaserDevice * ULaserPool::getDevice ( const char *  deviceID)

Get a device pointer from specification string

References ULaserDevice::getDeviceName(), ULaserDevice::getName(), lasDevs, lasDevsCnt, and MAX_LASER_DEVS.

int ULaserPool::getDeviceCnt ( )
inline

Get number of created devices

References addDevice(), lasDevsCnt, and setDefDevice().

Referenced by UFunctionLaser::handleSetCommand().

int ULaserPool::getDeviceMax ( )
inline

Get maximum number of laser devices allowed in laser pool (a hard coded constant)

References createBaseVar(), getScan(), MAX_LASER_DEVS, replayAdvanceTime(), and replayToTime().

int ULaserPool::getDeviceNumber ( ULaserDevice device)

Get device number from a device pointer. Returns -1 if device is not found.

References lasDevs, and lasDevsCnt.

Referenced by getDefDevice(), and getScan().

UPosRot* ULaserPool::getDevicePose ( int  idx)

Get pose (3D) of the laser scanner sensor

Referenced by getDefDeviceNumber().

static const char* ULaserPool::getResClassID ( )
inlinestatic
ULaserData * ULaserPool::getScan ( const int  device,
ULaserDevice **  las,
ULaserData dataBuff,
ULaserData pushData,
const int  fake 
)

get the next scan from laser scanner device

Parameters
deviceif -1, then scan is from default device, else from the specified device
lasreturns a pointer to the laser scanner device used
dataBuffa data buffer that may be used for the laserscan if a buffer is not allocated already. The buffer is also used to hold information on last used scan (serial number and device)
pushDatamay hold a scan already, if so, then only the corresponding laser device is fetched (lo las).
fakeif > 0 then a fake scan is fetched. 1=random range, 2,3,4 is measurements in a fake building with 4 rooms, with the robot moving through these rooms.
Returns
a pointer to the new scan - or NULL if no scan or if neither dataBuff nor pushData is available.

References device, getDefDeviceNumber(), getDevice(), ULaserData::getDeviceNum(), UResV360::getLastDevice(), UResV360::getNewestData(), ULaserDevice::getNewestData(), ULaserData::getSerial(), UResBase::getStaticResource(), scan, ULaserData::setDeviceNum(), and ULaserData::setSerial().

Referenced by UFuncLaserBase::getDevice(), getDeviceMax(), UFuncLaserBase::getScan(), UFuncLobst::getScan(), UFuncEfLine::getScan(), and getScan().

ULaserData * ULaserPool::getScan ( const char *  device,
ULaserDevice **  las,
ULaserData dataBuff,
ULaserData pushData,
const int  fake 
)

get the next scan from laser scanner device

Parameters
devicethe device name or number as string, e.g. v360 or sick. "-1" or NULL or "" for default scanner.
lasreturns a pointer to the laser scanner device used
dataBuffa data buffer that may be used for the laserscan if a buffer is not allocated already. The buffer is also used to hold information on last used scan (serial number and device)
pushDatamay hold a scan already, if so, then only the corresponding laser device is fetched (lo las).
fakeif > 0 then a fake scan is fetched. 1=random range, 2,3,4 is measurements in a fake building with 4 rooms, with the robot moving through these rooms.
Returns
a pointer to the new scan - or NULL if no scan or if neither dataBuff nor pushData is available.

References getDevice(), getDeviceNumber(), and getScan().

bool ULaserPool::gotAllResources ( char *  missingThese,
int  missingTheseCnt 
)
virtual

Is this resource missing any ressource pointers to function. Returns true if all is OK. If some is missing, then the missing resource name should be added to the missingThese list,

Reimplemented from UResVarPool.

References cmdExe, UCmdExe::getResClassID(), and UResBase::gotAllResources().

Referenced by getDefDeviceNumber().

const char * ULaserPool::print ( const char *  preString,
char *  buff,
int  buffCnt 
)
virtual

Print laser pool status to a string buffer

Returns
pointer to provided buffer.

Reimplemented from UResVarPool.

References lasDevs, lasDevsCnt, and ULaserDevice::print().

Referenced by getDefDeviceNumber(), and UFunctionLaser::handleSetCommand().

void ULaserPool::replayAdvanceTime ( UTime  untilTime)
virtual

Advance replay for all devices in replay mode until just before this time The function sets a flag and the steps are performed in main command thread as soon as possible (before next user queue, and before push events)

Reimplemented from UReplay.

References UReplay::replayAdvanceTime(), and replayToTime().

Referenced by getDeviceMax(), and UFunctionLaser::handleSetCommand().

bool ULaserPool::replayToTime ( UTime  untilTime)
virtual

Advance replay for this resources - if in replay mode - until just before this time

Parameters
untilTimeadvance with steps in logfile until this time is reached
Returns
true if advanced

Reimplemented from UReplay.

References getDevice(), ULaserDevice::isReplayDevice(), lasDevsCnt, and UReplayDevice::replayToTime().

Referenced by getDeviceMax(), and replayAdvanceTime().

void ULaserPool::setCmdExe ( UCmdExe server)

Set command server to be used by push commands. NB! devices must be loaded before this call. (or the call repeated).

References lasDevs, and lasDevsCnt.

Referenced by getDefDeviceNumber().

void ULaserPool::setDefDevice ( int  value)

Set default device. If value is not inside valid range, then the closest valid device is selected.

References lasDevsCnt, maxi(), mini(), and var.

Referenced by getDeviceCnt(), UFunctionLaser::handleScanGetCommand(), and UFunctionLaser::handleSetCommand().

bool ULaserPool::setDefDevice ( const char *  device)

Set default device to the lase device of the type (name) of 'device'. Returns true if such a name match is found

References device, getDevice(), ULaserDevice::getName(), lasDevsCnt, and var.

bool ULaserPool::setResource ( UResBase ress,
bool  remove 
)
virtual

Fixed varsion number for this resource type. Should follow release version, i.e. version 1.28 gives number 128. Should be incremented only when there is change to this class definition, i.e new or changed functions or variables. Set ressources as needed

Reimplemented from UResVarPool.

References cmdExe, UCmdExe::getResClassID(), UResBase::isA(), and UResBase::setResource().

Referenced by getResClassID().

void ULaserPool::stop ( bool  andWait)
virtual

Stop any running subthread - we are going down

Reimplemented from UResBase.

References lasDevs, lasDevsCnt, and ULaserDevice::stop().

Referenced by getResClassID().

void ULaserPool::ULaserPoolInit ( )

Initialize laser pool

References cmdExe, lasDevs, lasDevsCnt, MAX_LASER_DEVS, UResBase::replay, and UFakeMap::varPool.

Referenced by ULaserPool().

Member Data Documentation

UCmdExe* ULaserPool::cmdExe
protected

Default device Pointer to server core

Referenced by addDevice(), gotAllResources(), setResource(), and ULaserPoolInit().

UVariable* ULaserPool::def
UVariable* ULaserPool::deviceCnt
UVariable* ULaserPool::devices
ULaserDevice* ULaserPool::lasDevs[MAX_LASER_DEVS]
protected

Array of pointers to laser devices (already created

Referenced by addDevice(), getDevice(), getDeviceNumber(), print(), setCmdExe(), stop(), ULaserPoolInit(), and ~ULaserPool().

int ULaserPool::lasDevsCnt
protected
struct { ... } ULaserPool::var

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