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

#include <uhokuyo.h>

Inheritance diagram for UHokuyo:
Inheritance graph

Public Member Functions

virtual bool changeMode (int scanangle, double resolution)
 
virtual void createBaseVars ()
 
virtual bool getNewestData (ULaserData *dest, unsigned long lastSerial, int fake)
 
virtual bool isPortOpen ()
 
virtual bool isUrg ()
 
 UHokuyo ()
 
 ~UHokuyo ()
 
- Public Member Functions inherited from ULaserDevice
virtual void callGotNewDataWithObject ()
 
unsigned int getBad ()
 
char * getDeviceName ()
 
int getDeviceNum ()
 
UPosition getDevicePos ()
 
UPosRot getDevicePose ()
 
URotation getDeviceRot ()
 
unsigned int getGood ()
 
char * getLogFileName (char *buffer, int bufferCnt)
 
int getLogInterval ()
 
bool getLogUsedScans ()
 
int getMaxMeasurements ()
 
bool getMirror ()
 
double getMsgRate ()
 
char * getName ()
 
int getScanAngle ()
 
double getScanAngle (int measurement)
 
double getScanResolution ()
 
unsigned long getSerial ()
 
void gotNewScan (ULaserData *gotData)
 
virtual bool isLogFileOpen ()
 
virtual bool isReplayDevice ()
 
bool isRunning ()
 
bool isSend ()
 
virtual bool isVerbose ()
 
void logFileClose ()
 
bool logFileOpen ()
 
void logThisScan (ULaserData *scan)
 
void openRequest (bool toOpen)
 
void print (char *preString)
 
virtual const char * print (const char *preString, char *buff, int buffCnt)
 
void send (char *msg)
 
virtual void setCore (UCmdExe *pCore)
 
virtual void setDeviceName (const char *device)
 
void setDeviceNum (int value)
 
void setDevicePose (UPosRot *newPose)
 
void setLogInterval (int value)
 
void setLogUsedScans (bool value)
 
void setMirror (bool value)
 
void setVarStructure (UVarPool *varStruct)
 
void setVerbose (bool value)
 
bool start ()
 
void stop (bool justClosePort)
 
void threadRunLoop ()
 
 ULaserDevice ()
 
virtual ~ULaserDevice ()
 
- Public Member Functions inherited from UServerPush
int addPushCommand (UServerInMsg *msg)
 
bool doPushCall (UServerPushElement *pe, const char *value)
 
void flushClientCmds (int clientIdx)
 
UServerPushImplementgetImplementor ()
 
int getPushCmdCnt (int *cmdCnt, int *callCnt)
 
UServerPushQueuegetPushQueue ()
 
bool gotCmdExe ()
 
void gotNewData (void *pData)
 
bool isUpdated (int lastCnt, int *newCnt)
 
bool needNewData ()
 
void print (const char *preString)
 
void print (const char *preString, char *buff, int buffCnt)
 
void servicePendingPushCmds ()
 
void setCmdExe (UServerPushImplement *executor)
 
void setImplementor (UServerPushImplement *executor)
 
bool setResource (UResBase *resource, bool remove)
 
bool setUpdated (const char *value)
 Add watch object if needed. An image or other object is updated. set object as updated, with an extra qualifier, that may be used as a parameter in a push call. this push list is then added to the to the push list examined by the server thread. when server thread reach this push list it will call to get a possible associated data structure by a call to needNewData() whish is expected to call gotNewData(void * data_structure) - but now in the server thread. More...
 
 UServerPush ()
 
virtual ~UServerPush ()
 

Protected Member Functions

virtual void closePort ()
 
bool decodeData (char *msg, const int msgCnt, ULaserData *dest)
 
bool decodeName (char *msg)
 
bool getDataTo (char *msg, const int msgCnt, ULaserData *dest)
 
virtual double getDefaultDelay ()
 
virtual const char * getNameFromDevice ()
 
char * makeGetDataString (char *cmdStr, const int cmdStrCnt)
 
virtual bool openPort ()
 
virtual bool receiveData ()
 
int receiveFromDevice (char *start, int maxLng, double timeoutSec)
 
bool requestMoreData ()
 
virtual bool sendToDevice (const char *msg, int lng)
 
void toLog (const char *data, int length, const char *pre, UTime ts)
 
- Protected Member Functions inherited from ULaserDevice
void getFakeScan (ULaserData *dest, unsigned long lastSerial, int fake, double fakeDt=0.2)
 
void updateScanData (UTime scanTime)
 
- Protected Member Functions inherited from ULock
bool lock ()
 
void lockInit ()
 
void post ()
 
bool tryLock ()
 
bool tryWait ()
 
 ULock ()
 
void unlock ()
 
bool wait ()
 
 ~ULock ()
 

Protected Attributes

int badSeries
 
char dataBuf [MAX_DATA_LNG]
 
int dataCnt
 
UTime dataRxTime
 
UTime dataTime
 
int hfd
 
ULaserDatalasData
 
ULogFile laslog
 
int versionInfoCnt
 
- Protected Attributes inherited from ULaserDevice
double angleResolution
 
ULogFile datalog
 
int datalogSeq
 
bool datalogUsedScans
 
int deviceNum
 
char devName [MAX_DEVICE_NAME_LNG]
 
UTime lastScanTime
 
int loopCnt
 
double maxValidRange
 
bool mirrorData
 
int modeAngleScan
 
char name [MAX_NAME_LNG]
 
ULaserDatapushData
 
bool replayOrFake
 
bool sendNewData
 
char sendStr [MAX_SEND_MSG_LNG]
 
int sendStrCnt
 
unsigned long serial
 
unsigned int statBadCnt
 
unsigned int statGoodCnt
 
double statMsgRate
 
pthread_t threadHandle
 
bool threadRunning
 
bool threadStop
 
struct {
   UVariable *   framerate
 
   UVariable *   logData
 
   UVariable *   logDataInterval
 
   UVariable *   logSource
 
   UVariable *   maxRange
 
   UVariable *   name
 
   UVariable *   open
 
   UVariable *   pose
 
   UVariable *   scanDelay
 
   UVariable *   scanres
 
   UVariable *   scanwidth
 
   UVariable *   serial
 
   UVariable *   type
 
   UVariable *   versionInfo
 
var
 
UVarPoolvars
 
bool verbose
 

Detailed Description

Interface to Hokuyo laserscanner

Author
Christian Andersen

Constructor & Destructor Documentation

UHokuyo::UHokuyo ( )
UHokuyo::~UHokuyo ( )

Destructor

References ULogFile::closeLog(), laslog, and ULaserDevice::stop().

Member Function Documentation

bool UHokuyo::changeMode ( int  scanangle,
double  resolution 
)
virtual

Change scanner resolution mode. Returns true if new resolution is set

Reimplemented from ULaserDevice.

References ULaserDevice::angleResolution, mini(), ULaserDevice::modeAngleScan, and roundi().

void UHokuyo::closePort ( )
protectedvirtual

Close serial port

Reimplemented from ULaserDevice.

References ULaserDevice::getDeviceName(), hfd, ULock::lock(), UTime::now(), toLog(), and ULock::unlock().

Referenced by getNameFromDevice(), and isUrg().

void UHokuyo::createBaseVars ( )
virtual

Create entry infor the globas variable database for this device

Reimplemented from ULaserDevice.

References ULaserDevice::createBaseVars(), and ULaserDevice::var.

Referenced by isUrg().

bool UHokuyo::decodeData ( char *  msg,
const int  msgCnt,
ULaserData dest 
)
protected

Decode mesaurement data message.

Parameters
msgis the mesaage to decode.
msgCntis the length of the message
destis the destination buffer for the scan
Returns
true if scan is valid

References ULaserDevice::datalog, dataRxTime, getDataTo(), ULogFile::isOpen(), laslog, makeGetDataString(), ULaserDevice::serial, ULaserData::setScanTime(), ULaserData::setSerial(), ULaserData::setUnit(), ULaserData::setValid(), ULogFile::toLog(), ULaserDevice::var, and ULaserDevice::verbose.

Referenced by isUrg(), and receiveData().

bool UHokuyo::decodeName ( char *  msg)
protected

Decode name message

References MAX_DEVICE_NAME_LNG, ULaserDevice::name, and ULaserDevice::var.

Referenced by isUrg(), and receiveData().

bool UHokuyo::getDataTo ( char *  msg,
const int  msgCnt,
ULaserData dest 
)
protected

Decode this 'msg' data to the 'dest' structure

Parameters
msgis the mesaage to decode.
msgCntis the length of the message
destis the destination buffer for the scan
Returns
true if successful (scan is valid)

References ULaserData::addMeasurements(), dataRxTime, UTime::getTimeAsString(), laslog, MAX_RANGE_VALUES, ULaserDevice::mirrorData, ULaserData::reInitMeasurements(), ULaserData::setMeasurement(), ULaserData::setMirror(), ULogFile::toLog(), and ULaserDevice::verbose.

Referenced by decodeData(), and isUrg().

virtual double UHokuyo::getDefaultDelay ( )
inlineprotectedvirtual

Get default delat estimate for the device type

  • here expected to be a bit more than half a scantime (at 10 scans per second)

Reimplemented from ULaserDevice.

const char * UHokuyo::getNameFromDevice ( )
protectedvirtual
bool UHokuyo::getNewestData ( ULaserData dest,
unsigned long  lastSerial,
int  fake 
)
virtual
bool UHokuyo::isPortOpen ( )
virtual

Is the port to the device open

Reimplemented from ULaserDevice.

References hfd.

Referenced by getNameFromDevice(), getNewestData(), and receiveData().

virtual bool UHokuyo::isUrg ( )
inlinevirtual
char * UHokuyo::makeGetDataString ( char *  cmdStr,
const int  cmdStrCnt 
)
protected

Make the get-data command, e.g. "\nG04572501\n" for data element 45 to 725 with 1 measurement in each value. An extra "\n" is added in front as a workaround for an interface problem, where some data are repeated - an error will be received before tha valid data. Takes a string buffer 'cmdStr' of length 'cmdStrCnt'. Returns 'cmdStr'. Nothing is changed if no string is provided or string is too short (at least 11 characters is needed).

References ULaserDevice::angleResolution, ULaserDevice::modeAngleScan, and roundi().

Referenced by decodeData(), isUrg(), and requestMoreData().

bool UHokuyo::openPort ( )
protectedvirtual
bool UHokuyo::receiveData ( )
protectedvirtual

Receive data from device – called from device loop, should return as fast as possible after dooing the job, i.e. no blocking read. Should add number of good and bad blocks of data to statBadCnt and statGootcnt. Returns true if data received.

Reimplemented from ULaserDevice.

References badSeries, bool2str(), dataBuf, dataCnt, dataTime, decodeData(), decodeName(), ULaserDevice::deviceNum, ULaserData::getRangeCnt(), UTime::getTimePassed(), ULaserDevice::gotNewScan(), isPortOpen(), lasData, laslog, ULock::lock(), MAX_DATA_LNG, ULaserDevice::maxValidRange, ULaserDevice::mirrorData, UTime::Now(), receiveFromDevice(), requestMoreData(), sendToDevice(), ULaserData::setDeviceNum(), ULaserData::setMaxValidRange(), ULaserData::setMirror(), ULaserDevice::statBadCnt, ULaserDevice::statGoodCnt, ULogFile::toLog(), ULock::unlock(), ULaserDevice::verbose, and versionInfoCnt.

Referenced by isUrg().

int UHokuyo::receiveFromDevice ( char *  start,
int  maxLng,
double  timeoutSec 
)
protected

Receive data from device, at maximum 'maxLng' of bytes. Return if timeout ('timeoutSec' sec) or when a '

' is received - there may be additional data after '

'. Returns when 'maxLng' is reached too

References ULogFile::closeLog(), dataRxTime, hfd, ULogFile::isLogOpen(), ULogFile::isOpen(), laslog, UTime::now(), ULogFile::openLog(), roundi(), ULaserDevice::start(), toLog(), and ULaserDevice::verbose.

Referenced by isUrg(), and receiveData().

bool UHokuyo::requestMoreData ( )
protected

Request data according to spec in angleResolution and modeAngleScan

References makeGetDataString(), and sendToDevice().

Referenced by isUrg(), openPort(), and receiveData().

bool UHokuyo::sendToDevice ( const char *  msg,
int  lng 
)
protectedvirtual

Send data to device. Sends 'lng' bytes from 'msg'. Data must be a zero-terminated string.

Reimplemented from ULaserDevice.

References hfd, ULogFile::isOpen(), laslog, ULaserDevice::name, UTime::now(), and toLog().

Referenced by getNameFromDevice(), isUrg(), openPort(), receiveData(), and requestMoreData().

void UHokuyo::toLog ( const char *  data,
int  length,
const char *  pre,
UTime  ts 
)
protected

Member Data Documentation

int UHokuyo::badSeries
protected

reply since last OK - for error detection

Referenced by openPort(), receiveData(), and UHokuyo().

char UHokuyo::dataBuf[MAX_DATA_LNG]
protected

Data buffer for received data

Referenced by receiveData(), and UHokuyo().

int UHokuyo::dataCnt
protected

Number of unused characters in buffer

Referenced by receiveData(), and UHokuyo().

UTime UHokuyo::dataRxTime
protected

Time stamp of received data. Timestamp is taken, when first data is received (first chunk of data)

Referenced by decodeData(), getDataTo(), getNewestData(), and receiveFromDevice().

UTime UHokuyo::dataTime
protected

Time of last received data

Referenced by receiveData().

int UHokuyo::hfd
protected

File device handle for scanner

Referenced by closePort(), isPortOpen(), openPort(), receiveFromDevice(), sendToDevice(), and UHokuyo().

ULaserData* UHokuyo::lasData
protected

Decoded range data

Referenced by getNewestData(), receiveData(), and UHokuyo().

ULogFile UHokuyo::laslog
protected
int UHokuyo::versionInfoCnt
protected

Version info suppress after 5 prints

Referenced by openPort(), receiveData(), and UHokuyo().


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