direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
LaserThread Class Reference

Handles all Laser scanners. More...

#include <laserThread.h>

Collaboration diagram for LaserThread:

List of all members.

Public Slots

void saveLaserData ()
void setMeasureMode (bool state)
void setSimulationMode (bool state)

Signals

void laserDataCompleteFront (QList< float > laserScannerValuesFront, QList< int > laserScannerFlagsFront)
void laserDataCompleteRear (QList< float > laserScannerValuesRear, QList< int > laserScannerFlagsRear)
void message (QString text)
void sendNetworkString (QString text)
void systemerror (int errorlevel)

Public Member Functions

int getAngle (short int laserScanner)
int getFlag (short int laserScanner, int angle)
float getResolution (short int laserScanner)
float getValue (short int laserScanner, int angle)
bool isConnected (short int laserScanner)
 LaserThread ()
virtual void run ()
void setAngle (short int laserScanner, int angle)
void setFlag (short int laserScanner, int angle, int flag)
void setMounting (short int laserScanner, QString mounting)
void setResolution (short int laserScanner, float resolution)
void setSerialPort (short int laserScanner, QString serialPort)
void setType (short int laserScanner, QString laserType)
void stop ()
 ~LaserThread ()

Private Member Functions

void getAndStoreLaserValuesFront ()
void getAndStoreLaserValuesRear ()
bool readSimulationValues ()

Private Attributes

Inifileinifile1
InifileinifileLaserdata
SickS300laserS300
 this values holds the resolution of the laserscanner. e.g. 0.5 degrees
int laserscannerAngleFront
 cane be "normal" or "flipped"
int laserscannerAngleRear
 this values holds the range of the laserscanner viewing angle. e.g. 180 or 270 degrees
QList< int > laserScannerFlagsFront
 The measured distances from the rear laser scanner. This method also flippes the values when the laser is mounted flipped!
QList< int > laserScannerFlagsRear
 Some flags for each front laser line (like "free way", "obstacle" etc.)
bool laserScannerFrontIsConnected
bool laserScannerRearIsConnected
float laserscannerResolutionFront
 this values holds the range of the laserscanner viewing angle. e.g. 180 or 270 degrees
float laserscannerResolutionRear
 this values holds the resolution of the laserscanner. e.g. 0.5 degrees
unsigned char laserscannerTypeFront
unsigned char laserscannerTypeRear
QList< float > laserScannerValuesFront
QList< float > laserScannerValuesRear
 The measured distances from the front laser scanner. This method also flippes the values when the laser is mounted flipped!
bool measureMode
QString mountingLaserscannerFront
QString mountingLaserscannerRear
 cane be "normal" or "flipped"
int numReadingsFront
int numReadingsRear
bool simulationMode
QList< float > simulationValuesFront
 Some flags for each rear laser line (like "free way", "obstacle" etc.)
QList< float > simulationValuesRear
 The simulated distances for the front laser scanner.
volatile bool stopped
 Reads the laser line simulation values and sets these as currrent 'real' laser values.

Static Private Attributes

static const int FREEWAY = 0
static const unsigned char HOKUYO_URG = 2
static const short int LASER1 = 1
 The simulated distances for the rear laser scanner.
static const short int LASER2 = 2
static const short int LASER3 = 4
static const short int LASER4 = 8
static const short int LASER5 = 16
static const unsigned char LMS = 0
static const short int MAXERRORS = 2
static const unsigned char NONE = 255
static const int OBSTACLE = 1
static const unsigned char PLS = 1
static const unsigned char S300 = 4
static const unsigned char SIMULATED_LASER = 3
static const unsigned long THREADSLEEPTIME = 50

Detailed Description

Handles all Laser scanners.

Author:
Markus Knapp It checks, if they are connected, accesses them and emits all read data via Signal. It also provides a simulation mode.

Definition at line 35 of file laserThread.h.


Constructor & Destructor Documentation

LaserThread::LaserThread ( )

Definition at line 24 of file laserThread.cpp.

Here is the call graph for this function:

LaserThread::~LaserThread ( )

Definition at line 48 of file laserThread.cpp.


Member Function Documentation

void LaserThread::getAndStoreLaserValuesFront ( )
private

Definition at line 154 of file laserThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void LaserThread::getAndStoreLaserValuesRear ( )
private
Todo:
use one common getAndStoreLaserValue method!
Todo:
add S300 stuff

Definition at line 228 of file laserThread.cpp.

int LaserThread::getAngle ( short int  laserScanner)

Returns the physical angle of the laserscanner in degrees, e.g. 180 or 270.

Parameters:
laserScannercan be LASER1 or LASER2
Returns:
the angle in degrees

Definition at line 574 of file laserThread.cpp.

Here is the caller graph for this function:

int LaserThread::getFlag ( short int  laserScanner,
int  angle 
)
Parameters:
laserScannercan be LASER1 or LASER2
angleis the wanted angle in degrees
Returns:
the laser scanner line flag (the flag shows if there is an obstacle at this line or not)

Definition at line 263 of file laserThread.cpp.

Here is the caller graph for this function:

float LaserThread::getResolution ( short int  laserScanner)

Returns the physical resolution of the laserscanner in degrees, e.g. 1.0 or 0.5.

Parameters:
laserScannercan be LASER1 or LASER2
Returns:
the resolution in degrees

Definition at line 591 of file laserThread.cpp.

Here is the caller graph for this function:

float LaserThread::getValue ( short int  laserScanner,
int  angle 
)
Returns:
the (last) measuread value (distance) in meters(!)

Definition at line 237 of file laserThread.cpp.

Here is the caller graph for this function:

bool LaserThread::isConnected ( short int  laserScanner)

Returns the state of a connected laser scanner. This method also does some init stuff for all the important mebers like the QList (laser values etc.).

Parameters:
laserScannercan be LASER1 or LASER2
Returns:
true, if connected
Todo:
Support two S300 scanners
Todo:
S300 stuff

Definition at line 608 of file laserThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void LaserThread::laserDataCompleteFront ( QList< float >  laserScannerValuesFront,
QList< int >  laserScannerFlagsFront 
)
signal

Emits a list containing all front laser values (distances) and their flags.

Here is the caller graph for this function:

void LaserThread::laserDataCompleteRear ( QList< float >  laserScannerValuesRear,
QList< int >  laserScannerFlagsRear 
)
signal

Emits a list containing all rear laser values (distances) and their flags.

Here is the caller graph for this function:

void LaserThread::message ( QString  text)
signal

Emits a info or error message to a slot. This slot can be used to display a text on a splash screen, log file, to print it to a console...

Parameters:
textis the message to be emitted

Here is the caller graph for this function:

bool LaserThread::readSimulationValues ( )
private
Todo:
use one common getAndStoreLaserValue method!

Definition at line 727 of file laserThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void LaserThread::run ( )
virtual
Todo:
add support for 2 lasers...

Definition at line 73 of file laserThread.cpp.

Here is the call graph for this function:

void LaserThread::saveLaserData ( )
slot

Saves the current laser line simulation values to disk (.sim file). Resulting filename will look like direcs-YYYY_MM_DD__HH_MM_SS.sim

Todo:
Stop laser thread here for saving the values or is a mutex lock for the QList okay or are QLists able to handle this?

Definition at line 776 of file laserThread.cpp.

Here is the call graph for this function:

void LaserThread::sendNetworkString ( QString  text)
signal

Sends a string over the network.

Here is the caller graph for this function:

void LaserThread::setAngle ( short int  laserScanner,
int  angle 
)

Defines the angle of the laserscanner e.g. 180 or 270 degrees.

Parameters:
laserScannercan be LASER1 or LASER2
angleis the angle

Definition at line 536 of file laserThread.cpp.

Here is the caller graph for this function:

void LaserThread::setFlag ( short int  laserScanner,
int  angle,
int  flag 
)

This method sets the a flag for each laser line (angle) which represents a free way, an obstackle etc.

Parameters:
laserScannercan be LASER1 or LASER2
angleis the angle in degrees
flagcan be FREEWAY, OBSTACLE, LARGESTFREEWAY or CENTEROFLARGESTFREEWAY.
See also:
ObstacleCheckThread

Definition at line 289 of file laserThread.cpp.

Here is the caller graph for this function:

void LaserThread::setMeasureMode ( bool  state)
slot

This slot sets the measure mode. If activated one can walk around the laser, and the lessest value will only be stored. With this one can set a new alarm distance by walking around the robot.

Definition at line 411 of file laserThread.cpp.

void LaserThread::setMounting ( short int  laserScanner,
QString  mounting 
)

Sets the mounting for a laser scanner to flip the data for example from 0-179 to 179-0, when the laser scanner is mounted flipped.

Parameters:
laserScannercan be LASER1 or LASER2
mountingcan be "normal" or "flipped"
See also:
setDevicePort, read_parameters, laser.h

Definition at line 460 of file laserThread.cpp.

Here is the caller graph for this function:

void LaserThread::setResolution ( short int  laserScanner,
float  resolution 
)

Defines the resolution of the laserscanner e.g. 0.5 or 1.0 degrees.

Parameters:
laserScannercan be LASER1 or LASER2
resolutioncan be 0.5 or 1.00 degree

Definition at line 555 of file laserThread.cpp.

Here is the caller graph for this function:

void LaserThread::setSerialPort ( short int  laserScanner,
QString  serialPort 
)

Sets the serial port for a laser scanner.

Parameters:
laserScannercan be LASER1 or LASER2
serialPortis the port of the laser scanner
See also:
setDevicePort, read_parameters, laser.h
Todo:
support two S300 lasers

Definition at line 418 of file laserThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void LaserThread::setSimulationMode ( bool  state)
slot

This slot enables or disables the simulation mode.

Definition at line 315 of file laserThread.cpp.

Here is the call graph for this function:

void LaserThread::setType ( short int  laserScanner,
QString  laserType 
)

Sets the type of the laser

Parameters:
laserScannercan be LASER1 or LASER2
laserTypecan be S300

Definition at line 477 of file laserThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void LaserThread::stop ( )

Definition at line 65 of file laserThread.cpp.

Here is the caller graph for this function:

void LaserThread::systemerror ( int  errorlevel)
signal

Emits a emergency signal for letting other modules know that we have a massive sensor error. So in that case an emergency stop or so could be initiated.

Parameters:
errorlevelneeds to be defined. Temporariliy we use -1 in case of error.

Here is the caller graph for this function:


Member Data Documentation

const int LaserThread::FREEWAY = 0
staticprivate

Definition at line 236 of file laserThread.h.

const unsigned char LaserThread::HOKUYO_URG = 2
staticprivate

Definition at line 206 of file laserThread.h.

Inifile* LaserThread::inifile1
private

Definition at line 196 of file laserThread.h.

Inifile* LaserThread::inifileLaserdata
private

Definition at line 197 of file laserThread.h.

const short int LaserThread::LASER1 = 1
staticprivate

The simulated distances for the rear laser scanner.

The names for addressing the laser scanner array For the integrated DIRECS laser module

Definition at line 229 of file laserThread.h.

const short int LaserThread::LASER2 = 2
staticprivate

Definition at line 230 of file laserThread.h.

const short int LaserThread::LASER3 = 4
staticprivate

Definition at line 231 of file laserThread.h.

const short int LaserThread::LASER4 = 8
staticprivate

Definition at line 232 of file laserThread.h.

const short int LaserThread::LASER5 = 16
staticprivate

Definition at line 233 of file laserThread.h.

SickS300* LaserThread::laserS300
private

this values holds the resolution of the laserscanner. e.g. 0.5 degrees

Definition at line 195 of file laserThread.h.

int LaserThread::laserscannerAngleFront
private

cane be "normal" or "flipped"

Definition at line 190 of file laserThread.h.

int LaserThread::laserscannerAngleRear
private

this values holds the range of the laserscanner viewing angle. e.g. 180 or 270 degrees

Definition at line 191 of file laserThread.h.

QList<int> LaserThread::laserScannerFlagsFront
private

The measured distances from the rear laser scanner. This method also flippes the values when the laser is mounted flipped!

Definition at line 214 of file laserThread.h.

QList<int> LaserThread::laserScannerFlagsRear
private

Some flags for each front laser line (like "free way", "obstacle" etc.)

Definition at line 215 of file laserThread.h.

bool LaserThread::laserScannerFrontIsConnected
private

Definition at line 182 of file laserThread.h.

bool LaserThread::laserScannerRearIsConnected
private

Definition at line 183 of file laserThread.h.

float LaserThread::laserscannerResolutionFront
private

this values holds the range of the laserscanner viewing angle. e.g. 180 or 270 degrees

Definition at line 192 of file laserThread.h.

float LaserThread::laserscannerResolutionRear
private

this values holds the resolution of the laserscanner. e.g. 0.5 degrees

Definition at line 193 of file laserThread.h.

unsigned char LaserThread::laserscannerTypeFront
private

Definition at line 180 of file laserThread.h.

unsigned char LaserThread::laserscannerTypeRear
private

Definition at line 181 of file laserThread.h.

QList<float> LaserThread::laserScannerValuesFront
private

Definition at line 211 of file laserThread.h.

QList<float> LaserThread::laserScannerValuesRear
private

The measured distances from the front laser scanner. This method also flippes the values when the laser is mounted flipped!

Definition at line 212 of file laserThread.h.

const unsigned char LaserThread::LMS = 0
staticprivate

Definition at line 204 of file laserThread.h.

const short int LaserThread::MAXERRORS = 2
staticprivate

Nuber of tries reading from laser scanner. In case of error, we send the Signal systemerror, which lets the robot stop. In case of good reading, we decrease the errorcounter by one to zero.

Definition at line 243 of file laserThread.h.

bool LaserThread::measureMode
private

Definition at line 187 of file laserThread.h.

QString LaserThread::mountingLaserscannerFront
private

Definition at line 188 of file laserThread.h.

QString LaserThread::mountingLaserscannerRear
private

cane be "normal" or "flipped"

Definition at line 189 of file laserThread.h.

const unsigned char LaserThread::NONE = 255
staticprivate

Definition at line 209 of file laserThread.h.

int LaserThread::numReadingsFront
private

Definition at line 184 of file laserThread.h.

int LaserThread::numReadingsRear
private

Definition at line 185 of file laserThread.h.

const int LaserThread::OBSTACLE = 1
staticprivate

Definition at line 237 of file laserThread.h.

const unsigned char LaserThread::PLS = 1
staticprivate

Definition at line 205 of file laserThread.h.

const unsigned char LaserThread::S300 = 4
staticprivate

Definition at line 208 of file laserThread.h.

const unsigned char LaserThread::SIMULATED_LASER = 3
staticprivate

Definition at line 207 of file laserThread.h.

bool LaserThread::simulationMode
private

Definition at line 186 of file laserThread.h.

QList<float> LaserThread::simulationValuesFront
private

Some flags for each rear laser line (like "free way", "obstacle" etc.)

Definition at line 217 of file laserThread.h.

QList<float> LaserThread::simulationValuesRear
private

The simulated distances for the front laser scanner.

Definition at line 218 of file laserThread.h.

volatile bool LaserThread::stopped
private

Reads the laser line simulation values and sets these as currrent 'real' laser values.

Definition at line 179 of file laserThread.h.

const unsigned long LaserThread::THREADSLEEPTIME = 50
staticprivate

Definition at line 201 of file laserThread.h.


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