AURobotServers
4
|
#include <uhokuyo.h>
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) |
UServerPushImplement * | getImplementor () |
int | getPushCmdCnt (int *cmdCnt, int *callCnt) |
UServerPushQueue * | getPushQueue () |
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 () | |
Interface to Hokuyo laserscanner
UHokuyo::UHokuyo | ( | ) |
UHokuyo::~UHokuyo | ( | ) |
Destructor
References ULogFile::closeLog(), laslog, and ULaserDevice::stop().
|
virtual |
Change scanner resolution mode. Returns true if new resolution is set
Reimplemented from ULaserDevice.
References ULaserDevice::angleResolution, mini(), ULaserDevice::modeAngleScan, and roundi().
|
protectedvirtual |
Close serial port
Reimplemented from ULaserDevice.
References ULaserDevice::getDeviceName(), hfd, ULock::lock(), UTime::now(), toLog(), and ULock::unlock().
Referenced by getNameFromDevice(), and isUrg().
|
virtual |
Create entry infor the globas variable database for this device
Reimplemented from ULaserDevice.
References ULaserDevice::createBaseVars(), and ULaserDevice::var.
Referenced by isUrg().
|
protected |
Decode mesaurement data message.
msg | is the mesaage to decode. |
msgCnt | is the length of the message |
dest | is the destination buffer for the scan |
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().
|
protected |
Decode name message
References MAX_DEVICE_NAME_LNG, ULaserDevice::name, and ULaserDevice::var.
Referenced by isUrg(), and receiveData().
|
protected |
Decode this 'msg' data to the 'dest' structure
msg | is the mesaage to decode. |
msgCnt | is the length of the message |
dest | is the destination buffer for the scan |
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().
|
inlineprotectedvirtual |
Get default delat estimate for the device type
Reimplemented from ULaserDevice.
|
protectedvirtual |
Get name of device
Reimplemented from ULaserDevice.
References closePort(), ULaserDevice::getName(), isPortOpen(), ULock::lock(), sendToDevice(), ULaserDevice::start(), ULock::unlock(), and Wait().
Referenced by isUrg().
|
virtual |
Get the newest data unpacked to this structure. Returns true if valid.
Reimplemented from ULaserDevice.
References ULaserData::copy(), ULaserDevice::datalogUsedScans, dataRxTime, ULaserDevice::deviceNum, ULaserDevice::getFakeScan(), ULaserData::getSerial(), isPortOpen(), ULaserData::isValid(), lasData, ULock::lock(), ULaserDevice::logThisScan(), ULaserData::setDeviceNum(), ULaserData::setValid(), and ULock::unlock().
|
virtual |
Is the port to the device open
Reimplemented from ULaserDevice.
References hfd.
Referenced by getNameFromDevice(), getNewestData(), and receiveData().
|
inlinevirtual |
Is laserscanner an URG (Hokuyo) scanner
References closePort(), createBaseVars(), data, decodeData(), decodeName(), getDataTo(), getNameFromDevice(), makeGetDataString(), openPort(), receiveData(), receiveFromDevice(), requestMoreData(), sendToDevice(), ULaserDevice::start(), and toLog().
|
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().
|
protectedvirtual |
Open serial post. Return true if open(ed)
Reimplemented from ULaserDevice.
References badSeries, ULaserDevice::devName, hfd, ULock::lock(), UTime::now(), ULaserDevice::open, requestMoreData(), sendToDevice(), setDeviceSpeed(), toLog(), ULock::unlock(), versionInfoCnt, and Wait().
Referenced by isUrg().
|
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().
|
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().
|
protected |
Request data according to spec in angleResolution and modeAngleScan
References makeGetDataString(), and sendToDevice().
Referenced by isUrg(), openPort(), and receiveData().
|
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().
|
protected |
Send data to log, replacing whitespace with '<'
References data, ULogFile::getF(), UTime::getMicrosec(), UTime::getSec(), UTime::getTimeAsString(), ULogFile::isLogOpen(), laslog, and MAX_DATA_LNG.
Referenced by closePort(), isUrg(), openPort(), receiveFromDevice(), and sendToDevice().
|
protected |
reply since last OK - for error detection
Referenced by openPort(), receiveData(), and UHokuyo().
|
protected |
Data buffer for received data
Referenced by receiveData(), and UHokuyo().
|
protected |
Number of unused characters in buffer
Referenced by receiveData(), and UHokuyo().
|
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().
|
protected |
Time of last received data
Referenced by receiveData().
|
protected |
File device handle for scanner
Referenced by closePort(), isPortOpen(), openPort(), receiveFromDevice(), sendToDevice(), and UHokuyo().
|
protected |
Decoded range data
Referenced by getNewestData(), receiveData(), and UHokuyo().
|
protected |
Logfile
Referenced by decodeData(), getDataTo(), receiveData(), receiveFromDevice(), sendToDevice(), toLog(), UHokuyo(), and ~UHokuyo().
|
protected |
Version info suppress after 5 prints
Referenced by openPort(), receiveData(), and UHokuyo().