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

#include <ulms100.h>

Inheritance diagram for ULms100:
Inheritance graph

Public Member Functions

virtual bool changeMode (int scanangle, double resolution)
 
virtual bool getNewestData (ULaserData *dest, unsigned long lastSerial, int fake)
 
virtual bool isLms100 ()
 
virtual bool isPortOpen ()
 
 ULms100 ()
 
 ~ULms100 ()
 
- 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 ()
 
char * decodeData (char *msg, UTime rxTime)
 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)
 
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_LMS100_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 LMS100 laser scanner

Author
Christian Andersen

Constructor & Destructor Documentation

ULms100::ULms100 ( )
ULms100::~ULms100 ( )

Member Function Documentation

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

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

Reimplemented from ULaserDevice.

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

void ULms100::closePort ( )
protectedvirtual

Close serial port

Reimplemented from ULaserDevice.

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

Referenced by isLms100(), and ~ULms100().

char * ULms100::decodeData ( char *  msg,
UTime  rxTime 
)
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
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 isLms100(), and receiveData().

bool ULms100::decodeName ( char *  msg)
protected

Decode name message

References MAX_DEVICE_NAME_LNG, and ULaserDevice::name.

Referenced by isLms100().

bool ULms100::getDataTo ( char *  msg,
ULaserData dest 
)
protected
virtual double ULms100::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.

const char * ULms100::getNameFromDevice ( )
protectedvirtual

Get name of device

Reimplemented from ULaserDevice.

References ULaserDevice::getName().

Referenced by isLms100().

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

Is the port to the device open

Reimplemented from ULaserDevice.

References UClientPort::isConnected().

Referenced by getNewestData(), and receiveData().

bool ULms100::openPort ( )
protectedvirtual

Open serial post. Return true if open(ed)

Reimplemented from ULaserDevice.

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

Referenced by isLms100().

bool ULms100::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(), finishedScan, UClientPort::getDataFromLine(), UTime::getTimePassed(), isPortOpen(), laslog, ULock::lock(), MAX_LMS100_LNG, UTime::now(), sendToDevice(), ULaserDevice::statBadCnt, STX, ULogFile::toLog(), ULock::unlock(), and Wait().

Referenced by isLms100().

bool ULms100::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 isLms100(), and receiveData().

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

Send data to log, replacing whitespace with '<'

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

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

Member Data Documentation

char ULms100::dataBuf[MAX_LMS100_LNG]
protected

Data buffer for received data

Referenced by receiveData(), and ULms100().

int ULms100::dataCnt
protected

Number of unused characters in buffer

Referenced by receiveData(), and ULms100().

UTime ULms100::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 ULms100::dataTime
protected

Time of last received data

Referenced by decodeData(), and receiveData().

const char ULms100::ETX = 3
staticprotected

Referenced by decodeData(), and sendToDevice().

bool ULms100::finishedScan
private
ULaserData* ULms100::lasData
protected

Decoded range data

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

ULogFile ULms100::laslog
protected

Log file

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

const char ULms100::STX = 2
staticprotected

Referenced by receiveData(), and sendToDevice().


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