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

#include <usick.h>

Inheritance diagram for USick:
Inheritance graph

Public Member Functions

virtual bool changeMode (int scanangle, double resolution)
 
char * getDeviceName ()
 
virtual bool getNewestData (ULaserData *dest, unsigned long lastSerial, int fake)
 
USickDatagetNewestLocked ()
 
virtual bool isPortOpen ()
 
virtual bool isSick ()
 
 USick ()
 
 ~USick ()
 
- 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 ()
 
virtual const char * getNameFromDevice ()
 
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

void addCRC16 (unsigned char *CommData)
 
void close_port ()
 
virtual void closePort ()
 
bool enter_continous_mode ()
 
void enter_installation_mode ()
 
unsigned int getCCRC (unsigned char *CommData)
 
virtual double getDefaultDelay ()
 
USickDatagetNextBuffLocked ()
 
USickDataLMS_send_receive (unsigned char *telegram)
 
USickDataLMS_send_receive (unsigned char *telegram, int repeats)
 
int open_port (void)
 
virtual bool openPort ()
 
bool receive_continous_data (int *length)
 
virtual bool receiveData ()
 
bool receiveSimulatedData (int *length)
 
void request_status ()
 
void set_configuration ()
 
bool set_fast_speed ()
 
virtual bool set_resolution (int scanAngleDeg, int resolutionCdeg, int repeats)
 
bool set_serial (int fd, int speed)
 
bool set_slow_speed ()
 
unsigned short specialCCRC (unsigned char *CommData, unsigned int uLen)
 
bool stop_continous_mode ()
 
int toLMS (int fd, unsigned char *msg, unsigned int datalen)
 
- Protected Member Functions inherited from ULaserDevice
void getFakeScan (ULaserData *dest, unsigned long lastSerial, int fake, double fakeDt=0.2)
 
virtual bool sendToDevice (const char *msg, int lng)
 
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 byteCnt
 
int LMS_fd
 
unsigned char LMS_response_buffer [RECEIVE_BUFFER_SIZE]
 
int lostBytes
 
USickData packs [PACK_BUF_SIZE]
 
int packsNew
 
int portSpeed
 
int serialspeed
 
bool verbose
 
int wastedData
 
- 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

Holds basic laser scanner functions

Author
Christian Andersen

Constructor & Destructor Documentation

USick::USick ( )
USick::~USick ( )

Destructor

References ULaserDevice::stop().

Member Function Documentation

void USick::addCRC16 ( unsigned char *  CommData)
protected

Add CRC to this message

References getCCRC(), and TSIZE.

Referenced by isSick(), and LMS_send_receive().

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

Get number of measurements in scan-mode Get angle from measurement number - result is in degrees Print status Change scanner resolution mode. Returns true if new resolution is set

Reimplemented from ULaserDevice.

References ULaserDevice::angleResolution, ULaserDevice::devName, enter_continous_mode(), LMS_fd, ULock::lock(), ULaserDevice::modeAngleScan, roundi(), set_fast_speed(), set_resolution(), set_serial(), set_slow_speed(), SLOWSERIAL_BAUDRATE, stop_continous_mode(), and ULock::unlock().

Referenced by getDeviceName(), and openPort().

void USick::close_port ( )
protected

Close serial port

References LMS_fd.

Referenced by closePort(), and isSick().

void USick::closePort ( )
protectedvirtual

Close serial port

Reimplemented from ULaserDevice.

References close_port(), LMS_fd, set_slow_speed(), and stop_continous_mode().

Referenced by isSick().

bool USick::enter_continous_mode ( )
protected

Start continoious mode operation from SICK scanner

References data, LMS_send_receive(), and LMScontinous_mode.

Referenced by changeMode(), and isSick().

void USick::enter_installation_mode ( )
protected

Change to installation mode

References LMS_send_receive(), and LMSinstallation_mode.

Referenced by isSick().

unsigned int USick::getCCRC ( unsigned char *  CommData)
protected

Set next buffer unlocked and if the result is true advance packsNew to this buffer Test af data pakkerne der modtages fra SICK sensoren (CRC) Der undersoeges om der er fejl paa data pakken Denne funktion er taget fra SICK manualen

References CRC16_GEN_POL, MKSHORT, and TSIZE.

Referenced by addCRC16(), and isSick().

virtual double USick::getDefaultDelay ( )
inlineprotectedvirtual

Get default delat estimate for the device type

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

Reimplemented from ULaserDevice.

char* USick::getDeviceName ( )
inline

Start the receive loop for continous messages Set simulated mode Set scan angle mode (180 or 100 deg) Set scan resolution mode (100, 50 or 25 centi degrees) Get actual scan resolution in centi degrees Get actual scan angle in degrees Get statistics - good count Get statistics - bad count Get statistics - number of good messages per second Get serial device name

References changeMode(), ULaserDevice::devName, getNewestData(), and isPortOpen().

bool USick::getNewestData ( ULaserData dest,
unsigned long  lastSerial,
int  fake 
)
virtual
USickData * USick::getNewestLocked ( )

Is sick scanner running Set device name Start sick scanner and grap the data Stop sick scanner port. Stop also thread - if not 'justClosePort'. Get newest data packet

References USickData::isValid(), PACK_BUF_SIZE, packs, packsNew, ULock::tryLock(), and ULock::unlock().

Referenced by getNewestData().

USickData * USick::getNextBuffLocked ( )
protected

Get next buffer that can be locked and return pointer to this

References PACK_BUF_SIZE, packs, packsNew, and ULock::tryLock().

Referenced by isSick(), LMS_send_receive(), and receiveData().

bool USick::isPortOpen ( )
virtual

Is the port to the device open

Reimplemented from ULaserDevice.

References LMS_fd.

Referenced by getDeviceName().

virtual bool USick::isSick ( )
inlinevirtual
USickData * USick::LMS_send_receive ( unsigned char *  telegram)
protected
USickData * USick::LMS_send_receive ( unsigned char *  telegram,
int  repeats 
)
protected

Send data to sick, and try up to 'repeat' times for a successfull reply

References data, and LMS_send_receive().

int USick::open_port ( void  )
protected

Open serial post

References ULaserDevice::devName, and ULaserDevice::open.

Referenced by isSick(), and openPort().

bool USick::openPort ( )
protectedvirtual

Open serial post. Return true if open(ed)

Reimplemented from ULaserDevice.

References ULaserDevice::angleResolution, bool2str(), changeMode(), LMS_fd, MAX_NAME_LNG, ULaserDevice::modeAngleScan, ULaserDevice::name, and open_port().

Referenced by isSick().

bool USick::receive_continous_data ( int *  length)
protected

Get next full package from serial device. Returnes the data length at the given adress 'length'. NB! on entry the length of the previous message must be maintained in length, to discard used data properly. Returns true if data has passed the CRC check.

References byteCnt, LMS_fd, LMS_response_buffer, RECEIVE_BUFFER_SIZE, ULaserDevice::serial, specialCCRC(), ULaserDevice::statBadCnt, and wastedData.

Referenced by isSick(), and receiveData().

bool USick::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 byteCnt, data, USickData::getData(), getNextBuffLocked(), ULaserDevice::gotNewScan(), LMS_response_buffer, ULock::lock(), receive_continous_data(), USickData::setTime(), USickData::setValid(), ULaserDevice::statGoodCnt, ULock::unlock(), ULaserDevice::var, and Wait().

Referenced by isSick().

bool USick::receiveSimulatedData ( int *  length)
protected

Make a simulated reply - old recording in place of real Sick data Returnes the data length at the given adress 'length'. Returns true if message is valid.

Referenced by isSick().

void USick::request_status ( )
protected

Request status

References LMS_send_receive(), and LMSstatus.

Referenced by isSick().

void USick::set_configuration ( )
protected

Set scanner configuration

References LMS_send_receive(), and LMSset_configuration.

Referenced by isSick().

bool USick::set_fast_speed ( )
protected

change communication speed to fast (500 kbps) NB! this may take some time (< 1 sec)

References data, FASTSERIAL, FASTSERIAL_BAUDRATE, LMS_fd, LMS_send_receive(), LMSset_500k_baud, serialspeed, set_serial(), SLOWSERIAL, SLOWSERIAL_BAUDRATE, and Wait().

Referenced by changeMode(), and isSick().

bool USick::set_resolution ( int  scanAngleDeg,
int  resolutionCdeg,
int  repeats 
)
protectedvirtual

Set resolution to either 1 deg or 0.5 deg. The command is repeated up to 'repeats',waiting for a positive reply. Returns true if successful, otherwise false.

References ULaserDevice::angleResolution, LMS_send_receive(), LMSADR, ULaserDevice::modeAngleScan, and STX.

Referenced by changeMode(), and isSick().

bool USick::set_serial ( int  fd,
int  speed 
)
protected

Set serial speed on communication port

References FASTSERIAL, portSpeed, serialspeed, and SLOWSERIAL.

Referenced by changeMode(), isSick(), LMS_send_receive(), set_fast_speed(), and set_slow_speed().

bool USick::set_slow_speed ( )
protected

change communication speed to slow (9600 bps) NB! this may take some time (< 1 sec)

References data, FASTSERIAL, FASTSERIAL_BAUDRATE, LMS_fd, LMS_send_receive(), LMSset_9k6_baud, serialspeed, set_serial(), SLOWSERIAL, SLOWSERIAL_BAUDRATE, and Wait().

Referenced by changeMode(), closePort(), and isSick().

unsigned short USick::specialCCRC ( unsigned char *  CommData,
unsigned int  uLen 
)
protected

Calculate expected CRC on received data

References CRC16_GEN_POL, and MKSHORT.

Referenced by isSick(), and receive_continous_data().

bool USick::stop_continous_mode ( )
protected

Stop continoious mode operation from SICK scanner

References data, LMS_send_receive(), and LMScontinous_mode_stop.

Referenced by changeMode(), closePort(), and isSick().

int USick::toLMS ( int  fd,
unsigned char *  msg,
unsigned int  datalen 
)
protected

Function writes the received message to the delivered file descripter

Referenced by isSick(), and LMS_send_receive().

Member Data Documentation

int USick::byteCnt
protected

Used data in LMS_response_buffer

Referenced by receive_continous_data(), receiveData(), and USick().

int USick::LMS_fd
protected

Is sick scanner running Serial device, where laser scanner is attached File descriptor for connection to laser scanner

Referenced by changeMode(), close_port(), closePort(), isPortOpen(), LMS_send_receive(), openPort(), receive_continous_data(), set_fast_speed(), set_slow_speed(), and USick().

unsigned char USick::LMS_response_buffer[RECEIVE_BUFFER_SIZE]
protected

Thread handle for frame read thread. Is thread actually running Should thread stop - terminate Buffer for received data

Referenced by receive_continous_data(), and receiveData().

int USick::lostBytes
protected

Statistics of lost bytes, counts, when packages are too short

Referenced by USick().

USickData USick::packs[PACK_BUF_SIZE]
protected

Buffers for received data

Referenced by getNewestLocked(), and getNextBuffLocked().

int USick::packsNew
protected

Newest received package buffer

Referenced by getNewestLocked(), getNextBuffLocked(), and USick().

int USick::portSpeed
protected

Speed of serial port

Referenced by set_serial(), and USick().

int USick::serialspeed
protected

Serial speed (1 (slow (typically 9600)) or 2 (fast (500000)))

Referenced by set_fast_speed(), set_serial(), set_slow_speed(), and USick().

bool USick::verbose
protected

Print more (debug) messages

Referenced by LMS_send_receive().

int USick::wastedData
protected

Data left unused before a header is detected

Referenced by receive_continous_data(), and USick().


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