direcs
2012-09-30
|
The main class of the whole robot programm. More...
#include <direcs.h>
Public Slots | |
void | drive (const int command) |
void | enableFaceTracking (int state) |
void | enableRemoteControlListening (bool status) |
void | executeJoystickCommand (int axisNumber, int axisValue) |
void | executeJoystickCommand (int buttonNumber, bool buttonState) |
void | executeRemoteCommand (QString command) |
void | faceTracking (int faces, int faceX, int faceY, int faceRadius) |
void | finishSplash () |
void | increaseDrivingSpeed (void) |
void | logicalUnit (int sensorAlarm, QDateTime timestamp) |
void | mediaPlayerFinished () |
void | nextDemoPhase (int phase) |
void | setDemoMode (bool status) |
void | setNetworkState () |
void | setSimulationMode (bool status) |
void | showExitDialog () |
void | showSensorData () |
void | showSplashMessage (QString text) |
void | shutdown () |
void | systemerrorcatcher (int errorlevel) |
void | test () |
Signals | |
void | initCircuit () |
void | look (QString direction) |
void | message (QString text, bool CR=true, bool sayIt=false, bool addTimestamp=true) |
void | publishConsoleMode (bool state) |
void | sendNetworkString (QString text) |
void | showFaceTrackDirection (QString direction) |
void | showPreferredDirection (QString direction) |
void | speak (QString text, int phase=0) |
void | splashMessage (QString text) |
Public Member Functions | |
Direcs (bool bConsoleMode, bool bForceSmallGUI, bool bForceLargeGUI) | |
void | init () |
bool | simulationMode () const |
~Direcs () |
Public Attributes | |
bool | exitDialog |
bool | noHardwareErrorMessages |
Private Member Functions | |
void | checkArguments () |
void | drivingLight (unsigned char color) |
void | readSettings () |
void | resetDrivingSpeedTimer (void) |
Private Attributes | |
AboutDialog * | aboutDialog |
The joystick dialog. | |
QStringList | arguments |
The splash screen text color. | |
bool | cameraTestMode |
CamThread * | camThread |
Circuit * | circuit1 |
contains the list of command-line arguments | |
QString | commaSeparator |
ConsoleGui * | consoleGui |
bool | consoleMode |
int | currentPreferredDirection |
is enabled, when the robot is controlled via joystick and should use special mecanum wheel driving | |
int | currentTestServo |
bool | demoMode |
A Phonon media player for e.g. playing a mp3 file. | |
DemoThread * | demoThread |
QTimer * | drivingSpeedTimer |
bool | endSpeedMotor1Reached |
bool | endSpeedMotor2Reached |
bool | endSpeedMotor3Reached |
bool | endSpeedMotor4Reached |
bool | eyeTestMode |
bool | faceTrackingIsEnabled |
bool | firstDataReceived |
Indicates if this program is the master and sends data from the robot over the network. | |
float | floatValue |
bool | forceLargeGUI |
is enabled if the argument 'small' was passed by command-line. This will result in a startup with the small GUI - regardless of the hostname. | |
bool | forceShutdown |
bool | forceSmallGUI |
is enabled if the argument 'console' was passed by command-line. Sends all GUI messages to the command line. | |
Gui * | gui |
Head * | head |
bool | iAmTheMaster |
Stores the state, if the remote mode is enabled (control via LAN or joystick es enabled. | |
Inifile * | inifile1 |
InterfaceAvr * | interface1 |
Joystick * | joystick |
JoystickDialog * | joystickDialog |
The settings dialog. | |
int | laserscannerAngleFront |
int | laserscannerAngleRear |
bool | laserScannerFrontFound |
if a camera is connected, but should not be used (just for testing, for a faster program start) | |
int | laserscannerIgnoreAreaEnd |
int | laserscannerIgnoreAreaStart |
QString | laserscannerMounting |
bool | laserScannerRearFound |
QString | laserscannerTypeFront |
QString | laserscannerTypeRear |
LaserThread * | laserThread |
Logfile * | logfile |
int | maximumSpeed |
bool | mecanumDriveMode |
is enabled, when the robot is controlled via joystick | |
Phonon::MediaObject * | mediaObject |
A list of obstacle alarms that occured right the last n times. | |
int | minimumSpeed |
int | mot1Speed |
int | mot2Speed |
int | mot3Speed |
int | mot4Speed |
Motor * | motors |
QMutex * | mutex |
NetworkThread * | netThread |
unsigned int | networkPortListen |
Indicates that network data were received already and we do not check if we are master or slave. | |
unsigned int | networkPortSend |
QList< QDateTime > | obstacleAlarmFrontLeftList |
if true, we will use a small GUI for fitting on a small onboard TFT. By default this is decided by the local hostname of the system. | |
QList< QDateTime > | obstacleAlarmFrontRightList |
A list of obstacle alarms that occured left the last n times. | |
ObstacleCheckThread * | obstCheckThread |
PlotThread * | plotThread |
The about dialog. | |
int | preferredDrivingDirection |
RgbLed * | rgbLeds |
bool | robotDrives |
bool | robotRemoteMode |
Stores the robots simulation state. | |
bool | robotSimulationMode |
Stores the robots driving state. TRUE, when the robot drives. | |
SensorThread * | sensorThread |
QString | serialPortLaserscannerFront |
QString | serialPortLaserscannerRear |
QString | serialPortMicrocontroller |
Servo * | servos |
bool | servoTestMode |
SettingsDialog * | settingsDialog |
bool | shutdownAlreadyCalled |
is enabled if the argument 'large' was passed by command-line. This will result in a startup with the large GUI - regardless of the hostname. | |
SpeakThread * | speakThread |
QSplashScreen * | splash |
QColor | splashTextColor |
bool | testDriveMode |
TimerThread * | timerThread |
bool | useCamera |
if true, a logfile is written of all pgm messages (see ini-file) | |
bool | useSmallGUI |
this is set to true, when no ini-file was found at startup. This make the program leave without the stupid AreYouSure-Question. | |
unsigned int | value |
bool | writeLogFile |
Static Private Attributes | |
static const int | ALLMOTORS = 250 |
Motor 4 back right. | |
static const int | AREA1 = 1 |
static const int | AREA2 = 2 |
static const int | BACKWARD = 20 |
Motor direction (formerly "clockwise") | |
static const unsigned char | BLUE = 3 |
static const unsigned int | DRIVINGSPEEDINCREASER = 10 |
The time between one de/increase of the motor speed (to its minimum/maximum) and the next in ms. | |
static const int | FORWARD = 10 |
Some driving directions and motor directions for the robot. | |
static const unsigned char | GREEN = 2 |
static const int | JOYSTICKAXISX3 = 3 |
static const int | JOYSTICKAXISX4 = 4 |
static const int | JOYSTICKAXISY2 = 2 |
this is analog to the value in microcontroller software | |
static const int | JOYSTICKAXISY5 = 5 |
static const int | JOYSTICKDIVISOR = 128 |
Joystick conversion divisor. Converts the joystick axis value to the robot speed. | |
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 unsigned char | LEDOFF = 0 |
static const int | LEFT = 30 |
Motor direction (formerly "counterclockwise". | |
static const short int | MAXFALSEALARMS = 2 |
static const int | MAXPWM = 99 |
this is analog to the value in microcontroller software | |
static const float | MINIMUMVOLTAGE1 = 10.80 |
The minimum voltages for an acoustic and optical alarm. | |
static const float | MINIMUMVOLTAGE2 = 21.60 |
static const int | MINPWM = 1 |
static const int | MOTOR1 = 210 |
Motor direction/power "same like before". | |
static const int | MOTOR1BW = 310 |
static const int | MOTOR1FW = 300 |
used for letting the robot getting only one command for all motors (like 'forward all'). This is to reduce commands on the serial line. | |
static const int | MOTOR1OFF = 320 |
static const int | MOTOR2 = 220 |
Motor 1 front left. | |
static const int | MOTOR2BW = 340 |
static const int | MOTOR2FW = 330 |
static const int | MOTOR2OFF = 350 |
static const int | MOTOR3 = 230 |
Motor 2 front right. | |
static const int | MOTOR3BW = 370 |
static const int | MOTOR3FW = 360 |
static const int | MOTOR3OFF = 380 |
static const int | MOTOR4 = 240 |
Motor 3 back left. | |
static const int | MOTOR4BW = 400 |
static const int | MOTOR4FW = 390 |
static const int | MOTOR4OFF = 410 |
static const short int | MOTORSENSOR1 = 0 |
number of false alarms which are allowed in the logical unit | |
static const short int | MOTORSENSOR2 = 1 |
static const short int | NONE = 0 |
Value, if no sensor has a value to react. | |
static const unsigned char | NUMBEROFRGBLEDS = 6 |
the RGB LED numbers | |
static const unsigned char | NUMBEROFSERVOS = 6 |
static const short int | OBSTACLEFRONTLEFT = 512 |
static const short int | OBSTACLEFRONTRIGHT = 1024 |
static const short int | OBSTACLESEVERYWHEREINFRONT = 2048 |
static const bool | OFF = false |
static const bool | ON = true |
static const int | READ_AXIS_X = 500 |
static const int | READ_AXIS_Y = 510 |
static const int | READ_AXIS_Z = 520 |
static const unsigned char | RED = 1 |
static const unsigned char | RGBLED1 = 0 |
static const unsigned char | RGBLED2 = 1 |
static const unsigned char | RGBLED3 = 2 |
static const unsigned char | RGBLED4 = 3 |
static const unsigned char | RGBLED5 = 4 |
static const unsigned char | RGBLED6 = 5 |
static const unsigned char | RGBLEDACTUAL = 1 |
static const unsigned char | RGBLEDDEFAULT = 0 |
the possible rgbLed data | |
static const unsigned char | RGBLEDMAX = 3 |
static const unsigned char | RGBLEDMIN = 2 |
static const int | RIGHT = 40 |
static const int | SAME = 200 |
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 char | SERVO1 = 0 |
the servo numbers | |
static const unsigned char | SERVO2 = 1 |
static const unsigned char | SERVO3 = 2 |
static const unsigned char | SERVO4 = 3 |
static const unsigned char | SERVO5 = 4 |
static const unsigned char | SERVO6 = 5 |
static const unsigned int | SPLASHTIME = 2000 |
The splash screen time of view in ms. | |
static const int | START = 70 |
static const int | STOP = 80 |
static const unsigned char | SVCURRENT = 3 |
static const unsigned char | SVDEFAULT = 2 |
static const unsigned char | SVEND = 1 |
static const unsigned char | SVMAX = 5 |
static const unsigned char | SVMIN = 4 |
static const unsigned char | SVSTART = 0 |
the possible servo data | |
static const int | TURNLEFT = 50 |
static const int | TURNRIGHT = 60 |
static const short int | VOLTAGESENSOR1 = 0 |
The voltage sensors. | |
static const short int | VOLTAGESENSOR2 = 1 |
static const int | WAIT = 90 |
static const unsigned char | WHITE = 4 |
Direcs::Direcs | ( | bool | bConsoleMode, |
bool | bForceSmallGUI, | ||
bool | bForceLargeGUI | ||
) |
The parameters are given from a main method which gets them from the console (startup arguments).
\xrefitem todo 2.
Definition at line 114 of file direcs.cpp.
Direcs::~Direcs | ( | ) |
Definition at line 1901 of file direcs.cpp.
|
private |
Checks the command-line arguments passed to the program.
Definition at line 5147 of file direcs.cpp.
|
slot |
Instructs the robot to drive FORWARD, BACKWARD, LEFT, RIGHT, TURNLEFT and TURNRIGHT. The commands START, STOP or WAIT are also possible.
command |
Definition at line 2466 of file direcs.cpp.
|
private |
Turns the driving light to RED, GREEN, BLUE, WHITE or LEDOFF.
color |
Definition at line 5303 of file direcs.cpp.
|
slot |
Enables or disables the face tracking. When activated, a face will be tracked by the camera.
state | has to be Qt::Checked to enable the detection. All other states disable. |
Definition at line 2214 of file direcs.cpp.
|
slot |
Enables or disables the listening for the robot remote control. This slot is called from an event from the GUI (enable remote button).
status |
Definition at line 4144 of file direcs.cpp.
|
slot |
This slot executes commands from a connected joystick.
Definition at line 4373 of file direcs.cpp.
|
slot |
Definition at line 4936 of file direcs.cpp.
|
slot |
This slot executes remote commands it receives via network (e.g. WLAN).
Definition at line 4208 of file direcs.cpp.
|
slot |
This method moves the camera and/or the robots eyes in the direction of a detected face.
Definition at line 2227 of file direcs.cpp.
|
slot |
Finishes the splash screen and displays the main window.
Definition at line 2014 of file direcs.cpp.
|
slot |
Increases the driving speed to its maximum speed. This is used to have a smooth driveaway of the robot and works together with a timer.
increase interval is 10%.
Definition at line 2865 of file direcs.cpp.
void Direcs::init | ( | ) |
Initalises the complete program and robot. Conntect all signals and slots.
connect(camThread, SIGNAL( disableFaceDetection() ), gui, SLOT( disableFaceDetection() )); \xrefitem todo 8.
connect(camThread, SIGNAL( disableCamera() ), gui, SLOT( disableCamera() )); \xrefitem todo 9.
Definition at line 225 of file direcs.cpp.
|
signal |
Initialize the robots basic circuit.
|
slot |
The locialUnit handles the behavior of the robot. This slot is called if an obstacle is detected from the obstacleCheckThread. It lets the robot "react" depending on which sensor made the alarm. The number of alarms are also counted. The class member preferredDrivingDirection is also set here and will be used when the robot gets the
sensorAlarm | consists of the sum of all infrared and ultrasonic sensor numbers, which had an alarm or if we use a laser scanner, a value like OBSTACLEFRONTLEFT. |
timestamp | is the timestmap when the signal was emitted. |
Definition at line 2023 of file direcs.cpp.
|
signal |
This is for the robots head.
direction | where to look can be LEFT, RIGHT... |
|
slot |
Restarts the mediaplayer because this Slot recevied the 'finished' Signal from the mediaplayer
same file again
Definition at line 5244 of file direcs.cpp.
|
signal |
Emits a string to the GUI log / console.
text | is the message to be emitted |
CR | is true when a CR/LF should be added at the end of the line (default) |
sayIt | is true when the text for the log also should be spoken (default=false) |
addTimestamp | If true, the a timestamp is added in front of the text. This parameter is optional. |
|
slot |
Enters the next demo phase and says some more text, drives around or whatever.
Definition at line 5158 of file direcs.cpp.
|
signal |
Let the other classes know if we are in the console mode (activated via command-line argument)
|
private |
Reads all settings for the robot from an ini-file.
camThread->setCameraDevice(-2);
camThread->setCameraDevice(-2);
camThread->setCameraDevice(cameraDevice); \xrefitem todo 28.
camThread->setCascadePath("none");
camThread->setCascadePath("none");
camThread->setCascadePath(haarClassifierCascade);
Definition at line 2932 of file direcs.cpp.
|
private |
Resets the driving speed timer, so at the next drive command, the robots start with a smooth drive - not with maximum speed.
Definition at line 2856 of file direcs.cpp.
|
signal |
Sends a string over the network.
|
slot |
This slot enables or disables the demo mode.
status |
Definition at line 5205 of file direcs.cpp.
|
slot |
Sets the network state of this program. If it receives / received a 'master' strin form another direcs program, running on a robot, it sets this program to slave mode. Otherwise we will run in (normal) master mode.
Definition at line 4185 of file direcs.cpp.
|
slot |
This slot enables or disables the simulation mode.
status |
Definition at line 5082 of file direcs.cpp.
|
slot |
Shows the yes-no exit dialog for the main program. This slot is called when massive communication errors occur while talking to the robots interface!
Definition at line 1954 of file direcs.cpp.
|
signal |
Shows the face tracking direction in a lable.
|
signal |
Shows the preferred driving direction of the robot in the GUI
|
slot |
Shows the sensor data in a graphical way (progressBars) and as a number in the GUI. This slot is called from the Signal sensorDataComplete from the sensorThread.
Definition at line 2380 of file direcs.cpp.
|
slot |
Shows a text on the current splash screen.
Definition at line 1978 of file direcs.cpp.
|
slot |
Ends the programm, after asking "really?". Calls the destructor of this class, after saving settings and some other exit stuff.
Definition at line 1282 of file direcs.cpp.
bool Direcs::simulationMode | ( | ) | const |
Returns the status of the main program. True, if the simulationMode ist active.
Definition at line 5076 of file direcs.cpp.
|
signal |
Emits a speak signal. This signal is sent to the speakThread.
phase | is an optional value. This could be a special phase which could be returned when the speech ends or so. |
|
signal |
Emits a string to the splash screen.
text | is the message to be emitted |
|
slot |
This slot catches all signals from the signal
Definition at line 5268 of file direcs.cpp.
|
slot |
The method for the test button in the GUI.
Definition at line 5354 of file direcs.cpp.
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
bool Direcs::exitDialog |
|
private |
|
private |
|
private |
|
staticprivate |
Some driving directions and motor directions for the robot.
For motor or robot "OFF"
|
private |
|
private |
|
staticprivate |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
staticprivate |
The minimum voltages for an acoustic and optical alarm.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
bool Direcs::noHardwareErrorMessages |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
if true, we will use a small GUI for fitting on a small onboard TFT. By default this is decided by the local hostname of the system.
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
staticprivate |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
staticprivate |