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

Checks if there is an obstacle in front the robot. More...

#include <obstacleCheckThread.h>

Collaboration diagram for ObstacleCheckThread:

List of all members.

Public Slots

void setIgnoreArea (short int laser, int area, int start, int end)
void setMinObstacleDistance (int distance)
void setMinObstacleDistanceLaserFront (int distance)
void setMinObstacleDistanceLaserRear (int distance)
void setPassageWidth (int width)
void setSimulationMode (bool status)
void setStraightForwardDeviation (int deviation)
void systemerrorcatcher (int errorlevel)

Signals

void message (QString text)
void newDrivingAngleSet (int largestFreeAreaStart, int largestFreeAreaEnd, int centerOfFreeWay, float width)
void obstacleDetected (int sensors, QDateTime timestamp)

Public Member Functions

void init ()
 ObstacleCheckThread (SensorThread *s, LaserThread *l)
virtual void run ()
void stop ()
 ~ObstacleCheckThread ()

Private Member Functions

double calculateDriveThroughWidth (short int laserscanner, int alpha, float b, float c)

Private Attributes

int actualFreeAreaEnd
int actualFreeAreaStart
int centerOfFreeWayFront
int centerOfFreeWayRear
 this is user for laser1
QString className
QList< int > freeEndAreas
 This stores the free areas after a scan. These will than be analysed and the "best" is chosen.
QList< int > freeStartAreas
 and this is the deviation to 90 degrees, when driving forward
bool initCompleted
float laserAngleFront
 stores the laser resolution when getting the value from the laser thread
float laserAngleRear
 stores the laser angle when getting the value from the laser thread
float laserResolutionFront
 this area will be ignored when there is an obstacle
float laserResolutionRear
 stores the laser resolution when getting the value from the laser thread
int laserscannerFrontIgnoreArea1End
 this area will be ignored when there is an obstacle
int laserscannerFrontIgnoreArea1Start
 this is user for laser2
int laserscannerFrontIgnoreArea2End
 this area will be ignored when there is an obstacle
int laserscannerFrontIgnoreArea2Start
 this area will be ignored when there is an obstacle
int laserscannerRearIgnoreArea1End
 this area will be ignored when there is an obstacle
int laserscannerRearIgnoreArea1Start
 this area will be ignored when there is an obstacle
int laserscannerRearIgnoreArea2End
 this area will be ignored when there is an obstacle
int laserscannerRearIgnoreArea2Start
 this area will be ignored when there is an obstacle
LaserThreadlaserThread
int minObstacleDistance
 see if the init method of this class was already called
int minObstacleDistanceLaserFront
 if the measured distance from a sensor is smaller than this value, than we have an obstacle! This is for the old infrared sensors.
int minObstacleDistanceLaserRear
 if the measured distance from a sensor is smaller than this value, than we have an obstacle! This is for laser scanner 1.
int robotSlotWidth
 stores the laser angle when getting the value from the laser thread
unsigned char sensorValue
 if the measured distance from a sensor is smaller than this value, than we have an obstacle! This is for laser scanner 2.
SensorThreadsensThread
 this will contain the name of this class at runtime for debug messages
bool simulationMode
volatile bool stopped
int straightForwardDeviation
 defines the minimum slot in centimeters (cm), where the robot has to fit through

Static Private Attributes

static const int AREA1 = 1
static const int AREA2 = 2
static const int CENTEROFLARGESTFREEWAY = 3
static const int FREEWAY = 0
 This stores the free areas after a scan. These will than be analysed and the "best" is chosen.
static const int IGNORETHIS = 4
static const int LARGESTFREEWAY = 2
static const short int LASER1 = 1
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 short int NONE = 0
static const int OBSTACLE = 1
static const short int OBSTACLEFRONTLEFT = 512
static const short int OBSTACLEFRONTRIGHT = 1024
static const short int OBSTACLESEVERYWHEREINFRONT = 2048
static const short int SENSOR1 = 1
static const short int SENSOR16 = 256
static const short int SENSOR2 = 2
static const short int SENSOR3 = 4
static const short int SENSOR4 = 8
static const short int SENSOR5 = 16
static const short int SENSOR6 = 32
static const short int SENSOR7 = 64
static const short int SENSOR8 = 128
static const unsigned long THREADSLEEPTIME = 50

Detailed Description

Checks if there is an obstacle in front the robot.

Author:
Markus Knapp If there is an obstacle in front of the robot the robot ("forward"), the signal
See also:
obstacleDetected() will be emitted which contains the direction, where the obstacle is. e.g. OBSTACLEFRONTLEFT. If there is no obstacle, NONE is emitted. If there is no free way, OBSTACLESEVERYWHEREINFRONT is emitted. The signal
newDrivingAngleSet() with all some from the laserscanner is also emmited which shows where we should drive to. This for displaying them in the GUI.

Definition at line 49 of file obstacleCheckThread.h.


Constructor & Destructor Documentation

ObstacleCheckThread::ObstacleCheckThread ( SensorThread s,
LaserThread l 
)

Definition at line 23 of file obstacleCheckThread.cpp.

ObstacleCheckThread::~ObstacleCheckThread ( )

Definition at line 68 of file obstacleCheckThread.cpp.


Member Function Documentation

double ObstacleCheckThread::calculateDriveThroughWidth ( short int  laserscanner,
int  alpha,
float  b,
float  c 
)
private

Calculate the width of the estimated drive-trough direction/area with the 'Kosinussatz' (a² = b² + c² - 2bc * cos alpha) where 'a' is the width

Parameters:
laserscannercan be LASER1 or LASER2
alphais the angle
bis one length
cis the other length
Returns:
width

Definition at line 633 of file obstacleCheckThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void ObstacleCheckThread::init ( )

Init all important class members, get settings/parameters from laser or sensor thread.

Definition at line 73 of file obstacleCheckThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void ObstacleCheckThread::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:

void ObstacleCheckThread::newDrivingAngleSet ( int  largestFreeAreaStart,
int  largestFreeAreaEnd,
int  centerOfFreeWay,
float  width 
)
signal

Emits a signal to set the angle where the robot can drive through.

Parameters:
largestFreeAreaStartis the start angle of the largest free area.
largestFreeAreaEndis the end angle of the largest free area.
centerOfFreeWayis the center of the largest free area.
widthof the estimated drive-trough area

Here is the caller graph for this function:

void ObstacleCheckThread::obstacleDetected ( int  sensors,
QDateTime  timestamp 
)
signal

Emits a signal to the logical unit of

See also:
Direcs
Parameters:
sensorsconsists of the sum of all infrared and ultrasonic sensor numbers, which had an alarm.
timestampis the timestmap when the signal was emitted.

Here is the caller graph for this function:

void ObstacleCheckThread::run ( )
virtual

holds the first angle index

holds the last last angle index

this is for detecting the driving direction ("drive left" means "drive left from the middle of the laser")

Todo:
correct to reset the centerOfFreeway here?!?

Definition at line 116 of file obstacleCheckThread.cpp.

Here is the call graph for this function:

void ObstacleCheckThread::setIgnoreArea ( short int  laser,
int  area,
int  start,
int  end 
)
slot

Set the laser area which will be ignored when checking for an obstacle.

Parameters:
laseris the number of the laser
areais the number of the area
startis the start angle in degrees
endis the end angle in degrees

Definition at line 667 of file obstacleCheckThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void ObstacleCheckThread::setMinObstacleDistance ( int  distance)
slot

This slot set the minimum distance, which the robot needs. Used by the infrared and ultra sonic sensors.

Parameters:
distancein centimeters

Definition at line 649 of file obstacleCheckThread.cpp.

Here is the caller graph for this function:

void ObstacleCheckThread::setMinObstacleDistanceLaserFront ( int  distance)
slot

This slot set the minimum distance, which the robot needs. Used by the laser scanner. Has to be a seperate method because of the signal from the GUI slider for each laser!

Parameters:
distancein centimeters

Definition at line 655 of file obstacleCheckThread.cpp.

Here is the caller graph for this function:

void ObstacleCheckThread::setMinObstacleDistanceLaserRear ( int  distance)
slot
  This slot set the minimum distance, which the robot needs. Used by the laser scanner.

Has to be a seperate method because of the signal from the GUI slider for each laser!

Parameters:
distancein centimeters

Definition at line 661 of file obstacleCheckThread.cpp.

Here is the caller graph for this function:

void ObstacleCheckThread::setPassageWidth ( int  width)
slot

This slot sets the width in centimeters (cm), where the robots has to fit through.

Definition at line 708 of file obstacleCheckThread.cpp.

Here is the caller graph for this function:

void ObstacleCheckThread::setSimulationMode ( bool  status)
slot

This slot enables or disables the simulation mode.

Definition at line 720 of file obstacleCheckThread.cpp.

void ObstacleCheckThread::setStraightForwardDeviation ( int  deviation)
slot

This slot sets the deviation to 90 degrees when the robot drives forward. When the laser angle is 180 degrees, the middle is 90 degrees, at 270 degrees it's 135.

Parameters:
deviationis the angle in degrees.

Definition at line 714 of file obstacleCheckThread.cpp.

Here is the caller graph for this function:

void ObstacleCheckThread::stop ( )

Definition at line 110 of file obstacleCheckThread.cpp.

Here is the caller graph for this function:

void ObstacleCheckThread::systemerrorcatcher ( int  errorlevel)
slot

This slot catches all signals from the signal

See also:
systemerror

Definition at line 742 of file obstacleCheckThread.cpp.

Here is the call graph for this function:


Member Data Documentation

int ObstacleCheckThread::actualFreeAreaEnd
private

Definition at line 170 of file obstacleCheckThread.h.

int ObstacleCheckThread::actualFreeAreaStart
private

Definition at line 169 of file obstacleCheckThread.h.

const int ObstacleCheckThread::AREA1 = 1
staticprivate

This are areas to be ignored when checking the laser distances.

Definition at line 207 of file obstacleCheckThread.h.

const int ObstacleCheckThread::AREA2 = 2
staticprivate

Definition at line 208 of file obstacleCheckThread.h.

int ObstacleCheckThread::centerOfFreeWayFront
private

Definition at line 172 of file obstacleCheckThread.h.

int ObstacleCheckThread::centerOfFreeWayRear
private

this is user for laser1

Definition at line 173 of file obstacleCheckThread.h.

const int ObstacleCheckThread::CENTEROFLARGESTFREEWAY = 3
staticprivate

Definition at line 201 of file obstacleCheckThread.h.

QString ObstacleCheckThread::className
private

Definition at line 158 of file obstacleCheckThread.h.

QList<int> ObstacleCheckThread::freeEndAreas
private

This stores the free areas after a scan. These will than be analysed and the "best" is chosen.

Definition at line 195 of file obstacleCheckThread.h.

QList<int> ObstacleCheckThread::freeStartAreas
private

and this is the deviation to 90 degrees, when driving forward

Definition at line 194 of file obstacleCheckThread.h.

const int ObstacleCheckThread::FREEWAY = 0
staticprivate

This stores the free areas after a scan. These will than be analysed and the "best" is chosen.

the tags for the laser lines

See also:
Gui

Definition at line 198 of file obstacleCheckThread.h.

const int ObstacleCheckThread::IGNORETHIS = 4
staticprivate

Definition at line 202 of file obstacleCheckThread.h.

bool ObstacleCheckThread::initCompleted
private

Definition at line 162 of file obstacleCheckThread.h.

const int ObstacleCheckThread::LARGESTFREEWAY = 2
staticprivate

Definition at line 200 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::LASER1 = 1
staticprivate

Definition at line 241 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::LASER2 = 2
staticprivate

Definition at line 242 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::LASER3 = 4
staticprivate

Definition at line 243 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::LASER4 = 8
staticprivate

Definition at line 244 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::LASER5 = 16
staticprivate

Definition at line 245 of file obstacleCheckThread.h.

float ObstacleCheckThread::laserAngleFront
private

stores the laser resolution when getting the value from the laser thread

Definition at line 187 of file obstacleCheckThread.h.

float ObstacleCheckThread::laserAngleRear
private

stores the laser angle when getting the value from the laser thread

Definition at line 188 of file obstacleCheckThread.h.

float ObstacleCheckThread::laserResolutionFront
private

this area will be ignored when there is an obstacle

Definition at line 185 of file obstacleCheckThread.h.

float ObstacleCheckThread::laserResolutionRear
private

stores the laser resolution when getting the value from the laser thread

Definition at line 186 of file obstacleCheckThread.h.

int ObstacleCheckThread::laserscannerFrontIgnoreArea1End
private

this area will be ignored when there is an obstacle

Definition at line 176 of file obstacleCheckThread.h.

int ObstacleCheckThread::laserscannerFrontIgnoreArea1Start
private

this is user for laser2

Definition at line 175 of file obstacleCheckThread.h.

int ObstacleCheckThread::laserscannerFrontIgnoreArea2End
private

this area will be ignored when there is an obstacle

Definition at line 178 of file obstacleCheckThread.h.

int ObstacleCheckThread::laserscannerFrontIgnoreArea2Start
private

this area will be ignored when there is an obstacle

Definition at line 177 of file obstacleCheckThread.h.

int ObstacleCheckThread::laserscannerRearIgnoreArea1End
private

this area will be ignored when there is an obstacle

Definition at line 181 of file obstacleCheckThread.h.

int ObstacleCheckThread::laserscannerRearIgnoreArea1Start
private

this area will be ignored when there is an obstacle

Definition at line 180 of file obstacleCheckThread.h.

int ObstacleCheckThread::laserscannerRearIgnoreArea2End
private

this area will be ignored when there is an obstacle

Definition at line 183 of file obstacleCheckThread.h.

int ObstacleCheckThread::laserscannerRearIgnoreArea2Start
private

this area will be ignored when there is an obstacle

Definition at line 182 of file obstacleCheckThread.h.

LaserThread* ObstacleCheckThread::laserThread
private

Definition at line 160 of file obstacleCheckThread.h.

int ObstacleCheckThread::minObstacleDistance
private

see if the init method of this class was already called

Definition at line 163 of file obstacleCheckThread.h.

int ObstacleCheckThread::minObstacleDistanceLaserFront
private

if the measured distance from a sensor is smaller than this value, than we have an obstacle! This is for the old infrared sensors.

Definition at line 164 of file obstacleCheckThread.h.

int ObstacleCheckThread::minObstacleDistanceLaserRear
private

if the measured distance from a sensor is smaller than this value, than we have an obstacle! This is for laser scanner 1.

Definition at line 165 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::NONE = 0
staticprivate

Definition at line 238 of file obstacleCheckThread.h.

const int ObstacleCheckThread::OBSTACLE = 1
staticprivate

Definition at line 199 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::OBSTACLEFRONTLEFT = 512
staticprivate
Todo:
make these values nicer

Definition at line 233 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::OBSTACLEFRONTRIGHT = 1024
staticprivate

Definition at line 234 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::OBSTACLESEVERYWHEREINFRONT = 2048
staticprivate

Definition at line 235 of file obstacleCheckThread.h.

int ObstacleCheckThread::robotSlotWidth
private

stores the laser angle when getting the value from the laser thread

Definition at line 190 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::SENSOR1 = 1
staticprivate
Todo:
make these values nicer

Definition at line 220 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::SENSOR16 = 256
staticprivate

Definition at line 230 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::SENSOR2 = 2
staticprivate

Definition at line 221 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::SENSOR3 = 4
staticprivate

Definition at line 222 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::SENSOR4 = 8
staticprivate

Definition at line 223 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::SENSOR5 = 16
staticprivate

Definition at line 224 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::SENSOR6 = 32
staticprivate

Definition at line 225 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::SENSOR7 = 64
staticprivate

Definition at line 226 of file obstacleCheckThread.h.

const short int ObstacleCheckThread::SENSOR8 = 128
staticprivate

Definition at line 227 of file obstacleCheckThread.h.

unsigned char ObstacleCheckThread::sensorValue
private

if the measured distance from a sensor is smaller than this value, than we have an obstacle! This is for laser scanner 2.

Definition at line 166 of file obstacleCheckThread.h.

SensorThread* ObstacleCheckThread::sensThread
private

this will contain the name of this class at runtime for debug messages

Definition at line 159 of file obstacleCheckThread.h.

bool ObstacleCheckThread::simulationMode
private

Definition at line 167 of file obstacleCheckThread.h.

volatile bool ObstacleCheckThread::stopped
private

Definition at line 161 of file obstacleCheckThread.h.

int ObstacleCheckThread::straightForwardDeviation
private

defines the minimum slot in centimeters (cm), where the robot has to fit through

Definition at line 192 of file obstacleCheckThread.h.

const unsigned long ObstacleCheckThread::THREADSLEEPTIME = 50
staticprivate

Definition at line 212 of file obstacleCheckThread.h.


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