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

#include <ulms500.h>

Inheritance diagram for ULms500:
Inheritance graph

Public Member Functions

virtual bool changeMode (int scanangle, double resolution)
 
virtual bool getNewestData (ULaserData *dest, unsigned long lastSerial, int fake)
 
virtual bool isLms500 ()
 
virtual bool isPortOpen ()
 
 ULms500 ()
 
 ~ULms500 ()
 
- Public Member Functions inherited from ULaserDevice
virtual void callGotNewDataWithObject ()
 
virtual void createBaseVars ()
 
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 configLMS5xx (int frq, float res, double scanangle)
 
char * decodeData (char *msg, UTime rxTime, int dataCnt)
 Decode message from laserscanner. Handles all received messagetypes, and stores result as appropriate. More...
 
bool decodeName (char *msg)
 
bool getDataTo (char *msg, ULaserData *dest)
 
virtual double getDefaultDelay ()
 
virtual const char * getNameFromDevice ()
 
virtual bool openPort ()
 
virtual bool receiveData ()
 
virtual bool sendToDevice (const char *msg, int lng)
 
bool setAllEchos ()
 
bool setDataFrqAndRes (int frq, float res)
 
bool setDataOutput ()
 
bool setDataOutputRange (double angle)
 
void toLog (const char *data, int length, const char *pre)
 
- 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 UClientPort
virtual void connectionChange (bool nowConnected)
 
virtual void sendNamespaceOpenTag ()
 
bool blockSend (const char *buffer, int length)
 
void closeConnection ()
 
int getDataFromLine (char *buffer, int bufferSize, int pollTimeoutMs)
 
const char * getHost ()
 
const char * getHostIP ()
 
int getPort ()
 
bool isConnected ()
 
bool isVerbose ()
 
bool sendMsg (const char *message)
 
bool sendWithLock (const char *message)
 
void setHost (const char *toHost)
 
void setPort (int toPort)
 
void setVerbose (bool value)
 
bool tryConnect ()
 
 UClientPort ()
 
virtual ~UClientPort ()
 
- Protected Member Functions inherited from ULock
bool lock ()
 
void lockInit ()
 
void post ()
 
bool tryLock ()
 
bool tryWait ()
 
 ULock ()
 
void unlock ()
 
bool wait ()
 
 ~ULock ()
 

Protected Attributes

char dataBuf [MAX_LMS500_LNG]
 
int dataCnt
 
UTime dataRxTime
 
UTime dataTime
 
ULaserDatalasData
 
ULogFile laslog
 
- 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
 
- Protected Attributes inherited from UClientPort
enum UClientPort:: { ... }  connectionLostReason
 
UTime connectTime
 
char host [MAX_HOST_LENGTH]
 
char hostIP [MAX_HOST_LENGTH]
 
int port
 
unsigned int readCnt
 
bool verboseMessages
 
int rxByteCnt
 
ULock tx
 

Static Protected Attributes

static const char ETX = 3
 
static const char STX = 2
 

Private Attributes

bool finishedScan
 

Additional Inherited Members

- Protected Types inherited from UClientPort
enum  { notLost, forReopen, rxError, txError }
 

Detailed Description

Interface to LMS500 laser scanner

Author
Christian Andersen

Constructor & Destructor Documentation

ULms500::ULms500 ( )
ULms500::~ULms500 ( )

Member Function Documentation

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

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

Reimplemented from ULaserDevice.

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

void ULms500::closePort ( )
protectedvirtual

Close serial port

Reimplemented from ULaserDevice.

References UClientPort::closeConnection(), ULock::lock(), toLog(), and ULock::unlock().

Referenced by isLms500(), and ~ULms500().

bool ULms500::configLMS5xx ( int  frq,
float  res,
double  scanangle 
)
protected

configure data settings for LMS 500 series

Parameters
frqis update frequency 25, 33, 50, 75, 100
resis resolution 0.1667, 0.25, 0.333, 0.5, 0.667, 1.0
scanangleis scanangle 180 deg is from -90 to +90
Returns
true if send

References sendToDevice(), setAllEchos(), setDataFrqAndRes(), setDataOutput(), and setDataOutputRange().

Referenced by changeMode(), getDefaultDelay(), and openPort().

char * ULms500::decodeData ( char *  msg,
UTime  rxTime,
int  dataCnt 
)
protected

Decode message from laserscanner. Handles all received messagetypes, and stores result as appropriate.

Parameters
msgis a 0 terminated string (but may have binary parts). Intial STX and terminating ETX is removed.
rxTimeis time-stamp just after start of receive
dataCntis number of characters in buffer
Returns
pointer to the first unused character. This may be the same as 'msg', as 'msg' may be part of a message only.

References dataRxTime, dataTime, ULaserDevice::deviceNum, ETX, finishedScan, getDataTo(), ULaserDevice::gotNewScan(), lasData, laslog, ULock::lock(), ULaserDevice::maxValidRange, ULaserDevice::mirrorData, UTime::Now(), ULaserDevice::serial, ULaserData::setDeviceNum(), ULaserData::setMaxValidRange(), ULaserData::setMirror(), ULaserData::setScanTime(), ULaserData::setSerial(), ULaserData::setUnit(), ULaserData::setValid(), ULaserDevice::statGoodCnt, ULogFile::toLog(), ULock::unlock(), and ULaserDevice::var.

Referenced by isLms500(), and receiveData().

bool ULms500::decodeName ( char *  msg)
protected

Decode name message

References MAX_DEVICE_NAME_LNG, and ULaserDevice::name.

Referenced by isLms500().

bool ULms500::getDataTo ( char *  msg,
ULaserData dest 
)
protected

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

Parameters

References ULaserData::addMeasurements(), ULaserDevice::getMirror(), and ULaserData::setMeasurement().

Referenced by decodeData(), and isLms500().

virtual double ULms500::getDefaultDelay ( )
inlineprotectedvirtual

Get default delay estimate for the device type

  • here expected to be a bit more than half a scan-time (at 50 scans per second)

Reimplemented from ULaserDevice.

References configLMS5xx(), setAllEchos(), setDataFrqAndRes(), setDataOutput(), and setDataOutputRange().

const char * ULms500::getNameFromDevice ( )
protectedvirtual

Get name of device

Reimplemented from ULaserDevice.

References ULaserDevice::getName().

Referenced by isLms500().

bool ULms500::getNewestData ( ULaserData dest,
unsigned long  lastSerial,
int  fake 
)
virtual
virtual bool ULms500::isLms500 ( )
inlinevirtual
bool ULms500::isPortOpen ( )
virtual

Is the port to the device open

Reimplemented from ULaserDevice.

References UClientPort::isConnected().

Referenced by getNewestData(), and receiveData().

bool ULms500::openPort ( )
protectedvirtual

Open serial post. Return true if open(ed)

Reimplemented from ULaserDevice.

References configLMS5xx(), ULaserDevice::devName, finishedScan, UClientPort::setHost(), UClientPort::setPort(), toLog(), UClientPort::tryConnect(), and Wait().

Referenced by isLms500().

bool ULms500::receiveData ( )
protectedvirtual

Receive data from device – called from device loop, should return as fast as possible after doing 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 dataBuf, dataCnt, dataRxTime, dataTime, decodeData(), ETX, finishedScan, UClientPort::getDataFromLine(), UTime::getTimePassed(), isPortOpen(), laslog, ULock::lock(), MAX_LMS500_LNG, UTime::now(), sendToDevice(), ULaserDevice::statBadCnt, STX, ULogFile::toLog(), and ULock::unlock().

Referenced by isLms500().

bool ULms500::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 UClientPort::blockSend(), ETX, ULaserDevice::name, STX, and toLog().

Referenced by configLMS5xx(), isLms500(), receiveData(), setAllEchos(), setDataFrqAndRes(), setDataOutput(), and setDataOutputRange().

bool ULms500::setAllEchos ( )
protected

set all data (up to 5 echos per pulse) (after login) true if send

References sendToDevice().

Referenced by configLMS5xx(), and getDefaultDelay().

bool ULms500::setDataFrqAndRes ( int  frq,
float  res 
)
protected

Set data rate and resolution (after login)

Parameters
frqis update frequency 25, 33, 50, 75, 100
resis resolution 0.1667, 0.25, 0.333, 0.5, 0.667, 1.0
Returns
true if send

References sendToDevice().

Referenced by configLMS5xx(), and getDefaultDelay().

bool ULms500::setDataOutput ( )
protected

Set output type - e.g. remission (after login)

Returns
true if send

References sendToDevice().

Referenced by configLMS5xx(), and getDefaultDelay().

bool ULms500::setDataOutputRange ( double  angle)
protected

Set output scan angle

Parameters
angleis angle width 180 is from -90 to +90 degrees
Returns
true if send.

References roundi(), and sendToDevice().

Referenced by configLMS5xx(), and getDefaultDelay().

void ULms500::toLog ( const char *  data,
int  length,
const char *  pre 
)
protected

Send data to log, replacing whitespace with '<'

References data, ULogFile::isOpen(), laslog, MAX_LMS500_LNG, and ULogFile::toLog().

Referenced by closePort(), isLms500(), openPort(), and sendToDevice().

Member Data Documentation

char ULms500::dataBuf[MAX_LMS500_LNG]
protected

Data buffer for received data

Referenced by receiveData(), and ULms500().

int ULms500::dataCnt
protected

Number of unused characters in buffer

Referenced by isLms500(), receiveData(), and ULms500().

UTime ULms500::dataRxTime
protected

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

Referenced by decodeData(), and receiveData().

UTime ULms500::dataTime
protected

Time of last received data

Referenced by decodeData(), and receiveData().

const char ULms500::ETX = 3
staticprotected
bool ULms500::finishedScan
private
ULaserData* ULms500::lasData
protected

Decoded range data

Referenced by decodeData(), getNewestData(), and ULms500().

ULogFile ULms500::laslog
protected

Log file

Referenced by decodeData(), receiveData(), toLog(), ULms500(), and ~ULms500().

const char ULms500::STX = 2
staticprotected

Referenced by receiveData(), and sendToDevice().


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