24 int main(
int argc,
char *argv[])
26 bool consoleMode =
false;
27 bool forceSmallGUI =
false;
28 bool forceLargeGUI =
false;
35 qDebug() << argc - 1 <<
"argument(s) passed...";
37 for (
int i=1; i<argc; i++)
40 if (strcasecmp(argv[i],
"console") == 0)
43 qDebug() <<
"Console mode enabled.";
47 if (strcasecmp(argv[i],
"small") == 0)
50 qDebug() <<
"Using small GUI.";
54 if (strcasecmp(argv[i],
"large") == 0)
57 qDebug() <<
"Using large GUI.";
61 if ((strcasecmp(argv[i],
"-h") == 0) || (strcasecmp(argv[i],
"-help") == 0) || (strcasecmp(argv[i],
"help") == 0) || (strcasecmp(argv[i],
"?") == 0) || (strcasecmp(argv[i],
"-?") == 0))
63 qDebug() <<
"Possible parameters:\n\n";
64 qDebug() <<
"console\tuse console mode";
65 qDebug() <<
"small\tforce small GUI";
66 qDebug() <<
"large\tforce large GUI\n\n";
79 QCoreApplication app(argc, argv);
84 Direcs d(consoleMode, forceSmallGUI, forceLargeGUI);
98 Q_INIT_RESOURCE(direcs);
101 QApplication app(argc, argv);
104 Direcs d(consoleMode, forceSmallGUI, forceLargeGUI);
126 logfile->
appendLog(
"- start -------------------------------------------------------------------------------------------");
132 QString hostname = QHostInfo::localHostName();
134 logfile->
appendLog(QString(
"The hostname of this machine is %1").arg(hostname));
136 if (hostname.contains(
"robot"))
138 logfile->
appendLog(
"Hostname contains 'robot'. We will use the small robot GUI.");
143 logfile->
appendLog(
"Hostname does not contain 'robot'. We will use the large GUI.");
149 logfile->
appendLog(
"Overriding GUI use due to command line argument. We will use the small robot GUI!");
155 logfile->
appendLog(
"Overriding GUI use due to command line argument. We will use the large robot GUI!");
163 #ifdef Q_OS_LINUX // currently supported only under linux (no MAC OS at the moment)
181 splash =
new QSplashScreen(QPixmap(
":/images/images/splash.png"));
185 mutex =
new QMutex();
196 #ifndef BUILDFORROBOT
274 qDebug(
"UNIX OS detected.");
279 qDebug(
"Linux OS detected.");
284 qDebug(
"X11 detected.");
289 qDebug(
"MAC OS detected.");
294 qDebug(
"MAC OS WS detected.");
306 QCoreApplication::setApplicationName(
"direcs");
358 QLocale::setDefault(QLocale::German);
366 connect(
this, SIGNAL(
message(QString) ),
consoleGui, SLOT( appendLog(QString) ));
370 connect(
this, SIGNAL(
message(QString,
bool,
bool,
bool) ),
gui, SLOT( appendLog(QString,
bool,
bool,
bool) ));
388 connect(
interface1, SIGNAL( robotState(
bool) ),
circuit1, SLOT( setRobotState(
bool) ));
389 connect(
interface1, SIGNAL( robotState(
bool) ),
motors, SLOT( setRobotState(
bool) ));
392 connect(
interface1, SIGNAL( robotState(
bool) ),
rgbLeds, SLOT( setRobotState(
bool) ));
396 connect(
interface1, SIGNAL( robotState(
bool) ),
gui, SLOT( setRobotControls(
bool) ));
400 connect(
circuit1, SIGNAL( robotState(
bool) ),
motors, SLOT( setRobotState(
bool) ));
403 connect(
circuit1, SIGNAL( robotState(
bool) ),
rgbLeds, SLOT( setRobotState(
bool) ));
407 connect(
circuit1, SIGNAL( robotState(
bool) ),
gui, SLOT( setRobotControls(
bool) ));
433 connect(
gui, SIGNAL(resetDrivenDistance(
int)),
sensorThread, SLOT(resetDrivenDistance(
int)));
441 connect(
settingsDialog, SIGNAL(setMotorSpeed(
int,
int)),
motors, SLOT(setMotorSpeed(
int,
int)));
485 #ifdef Q_OS_LINUX // currently supported only under linux (no MAC OS at the moment)
497 emit
message(
"Starting speak thread...",
false);
499 emit
message(
"Speak thread started.");
512 #ifndef BUILDFORROBOT
525 connect(
plotThread, SIGNAL( plotDataComplete5(
double *,
double *,
int) ),
gui, SLOT( setPlotData5(
double *,
double *,
int) ));
526 connect(
plotThread, SIGNAL( plotDataComplete6(
double *,
double *,
int) ),
gui, SLOT( setPlotData6(
double *,
double *,
int) ));
527 connect(
plotThread, SIGNAL( plotDataCompleteHeartbeat(
double *,
double *,
int) ),
gui, SLOT( setPlotDataHeartbeat(
double*,
double*,
int) ));
565 connect(
gui, SIGNAL( demo(
bool) ),
this, SLOT(
setDemoMode(
bool) ));
567 #ifdef Q_OS_LINUX // currently supported only under linux (no MAC OS at the moment)
585 emit
splashMessage(
"Opening serial port for microcontroller communication...");
594 emit
message(
"<font color=\"#FF0000\">The robot is OFF!</font>");
631 emit
message(
"Serial port opened.");
651 connect(
gui, SIGNAL( initServos() ),
servos, SLOT(
init() ) );
663 emit
message(
"Robot is <font color=\"#00FF00\">ON</font> and answers.");
687 emit
message(
"Setting motor speed in microcontroller");
692 emit
message(
"Motor speed set.");
706 emit
message(
"RGB LEDs set to default brightness");
730 emit
message(
"Starting sensor thread...",
false);
732 emit
message(
"Sensor thread started.");
738 #ifndef BUILDFORROBOT
747 emit
message(
"Starting plot thread...",
false);
749 emit
message(
"Plot thread started.");
757 emit
message(
"<font color=\"#FF0000\">The robot is OFF! Please turn it ON!</font>");
758 emit
message(
"Heartbeat thread NOT started!");
759 emit
message(
"Sensor thread NOT started!");
760 emit
message(
"Plot thread NOT started!");
771 emit
message(
"Starting timer thread...",
false);
773 emit
message(
"Timer thread started.");
790 emit
message(
"Starting joystick thread...",
false);
792 emit
message(
"Joystick thread started.");
801 emit
message(
"Joystick thread NOT started.");
809 connect(
gui, SIGNAL(
drive(
int) ),
this, SLOT(
drive(
int) ));
825 connect(
sensorThread, SIGNAL(
message(QString,
bool,
bool,
bool) ),
gui, SLOT( appendLog(QString,
bool,
bool,
bool) ));
831 connect(
sensorThread, SIGNAL( compassDataComplete(
float,
float,
float,
float) ),
gui, SLOT( showCompassData(
float,
float,
float,
float) ) );
841 connect(
sensorThread, SIGNAL( heartbeat(
unsigned char)),
gui, SLOT( setLEDHeartbeat(
unsigned char) ) );
860 connect(
obstCheckThread, SIGNAL(newDrivingAngleSet(
int,
int,
int,
float)),
gui, SLOT(showLaserFrontAngles(
int,
int,
int,
float)));
890 connect(
netThread, SIGNAL(heartbeat(
unsigned char)),
gui, SLOT( setLEDMasterSlave(
unsigned char) ) );
899 connect(
netThread, SIGNAL( dataReceived(QString) ),
gui, SLOT( appendNetworkLog(QString) ));
903 connect(
netThread, SIGNAL( dataReceived(QString) ),
consoleGui, SLOT( appendNetworkLog(QString) ));
913 connect(
demoThread, SIGNAL(setRGBLEDBrightness(
unsigned char,
unsigned char)),
rgbLeds, SLOT(setBrightness(
unsigned char,
unsigned char)));
915 #ifdef ACTIVELASERVIEW
922 qRegisterMetaType < QList <float> > (
"QList <float>");
923 qRegisterMetaType < QList <int> > (
"QList <int>");
925 connect(
laserThread, SIGNAL( laserDataCompleteFront(QList <float>, QList <int>) ),
gui, SLOT( refreshLaserViewFront(QList <float>, QList <int>) ));
926 connect(
laserThread, SIGNAL( laserDataCompleteRear(QList <float>, QList <int>) ),
gui, SLOT( refreshLaserViewRear(QList <float>, QList <int>) ));
955 connect(
joystick, SIGNAL(joystickButtonPressed(
int,
bool)),
joystickDialog, SLOT(showJoystickButtons(
int,
bool)));
956 #ifdef Q_OS_MAC // for Mac OS only:
957 connect(
joystick, SIGNAL(joystickPOVButtonPressed(
int)),
joystickDialog, SLOT(showJoystickPOVButtons(
int)));
967 emit
message(
"Detecting Kinect camera...");
978 emit
message(
"Initialising Kinect camera...");
991 connect(
camThread, SIGNAL( camImageComplete(QImage*) ),
gui, SLOT( setCamImage(QImage*) ));
992 connect(
camThread, SIGNAL( camImageDepthComplete(QImage*) ),
gui, SLOT( setCamImageDepth(QImage*) ));
993 connect(
camThread, SIGNAL( camImageOpenCVComplete(QImage*) ),
gui, SLOT( setCamImageOpenCV(QImage*) ));
996 connect(
camThread, SIGNAL( faceDetected(
int,
int,
int,
int,
int,
int) ),
this, SLOT(
faceTracking(
int,
int,
int,
int) ));
997 connect(
camThread, SIGNAL( faceDetected(
int,
int,
int,
int,
int,
int) ),
gui, SLOT( showFaceTrackData(
int,
int,
int,
int,
int,
int) ));
1000 connect(
gui, SIGNAL( enableFaceDetection(
int) ),
camThread, SLOT( enableFaceDetection(
int) ));
1024 connect(
gui, SIGNAL(setThreshold(
int)),
camThread, SLOT(setThreshold(
int)));
1060 emit
message(
"Kinect camera not found.",
false);
1067 emit
message(
"No Kinect detected.");
1086 connect(
gui, SIGNAL( writeLaserData() ),
laserThread, SLOT( saveLaserData() ));
1109 emit
message(
"Front laser scanner found.");
1113 emit
message(
"Front laser scanner NOT found.");
1118 emit
message(
"Rear laser scanner found.");
1122 emit
message(
"Rear laser scanner NOT found.");
1128 if (!QGLFormat::hasOpenGL())
1130 qDebug() <<
"This system has no OpenGL support" << endl;
1140 emit
message(
"Starting Laser thread...",
false);
1142 emit
message(
"Laser thread started.");
1148 emit
splashMessage(
"Initializing obstacle check thread...");
1149 emit
message(
"Initializing obstacle check thread...",
false);
1151 emit
message(
"Obstacle check thread initialized.");
1154 emit
message(
"Starting obstacle check thread...",
false);
1156 emit
message(
"Obstacle check thread started.");
1161 emit
message(
"<font color=\"#FF0000\">NO laser scanners found! Thread NOT started!</font>");
1177 int number = rand() % 6 +1;
1178 qDebug(
"file number %d", number);
1187 mediaObject->setCurrentSource(Phonon::MediaSource(QString(
"../../../../media/%1").arg(number)));
1189 mediaObject->setCurrentSource(Phonon::MediaSource(QString(
"../../../../media/%1.mp3").arg(number)));
1192 Phonon::AudioOutput *audioOutput =
new Phonon::AudioOutput(Phonon::MusicCategory,
this);
1214 QDesktopWidget *desktop = QApplication::desktop();
1219 if (desktop->width() > 1024)
1222 gui->move( (desktop->width() -
gui->width())/2, (desktop->height() -
gui->height())/2 );
1234 gui->showMaximized();
1240 #ifdef ACTIVELASERVIEW
1242 gui->initLaserView();
1263 QMessageBox msgbox(QMessageBox::Critical,
1265 tr(
"Required configuration file \"%1\" not found! File perhaps not in the same directory?\n%2\n\nSorry, exiting direcs NOW...").arg(
inifile1->
getInifileName()).arg( QDir::currentPath() ),
1266 QMessageBox::Ok | QMessageBox::Default);
1284 emit
message(
"----------------");
1285 emit
message(
"Shutting down...");
1286 emit
message(
"----------------");
1334 emit
message(
"Writing settings...");
1358 emit
message(
"Settings written.");
1371 if (QMessageBox::question(0,
"Exiting...",
"Are you sure?", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape) == QMessageBox::No)
1407 emit
message(
"Stopping camera thread...");
1414 camThread->setPriority(QThread::IdlePriority);
1424 }
while ((
camThread->isFinished() ==
false) && (t.elapsed() <= 2000));
1428 emit
message(
"Camera thread stopped.");
1432 emit
message(
"ERROR: Terminating camera thread because it doesn't answer...");
1433 emit
splashMessage(
"Terminating camera thread because it doesn't answer...");
1436 emit
message(
"Camera thread terminated.");
1448 emit
message(
"Stopping obstacle check thread...");
1465 }
while ((
obstCheckThread->isFinished() ==
false) && (t.elapsed() <= 2000));
1469 emit
message(
"Obstacle check thread stopped.");
1473 emit
message(
"ERROR: Terminating obstacle check thread because it doesn't answer...");
1474 emit
splashMessage(
"Terminating obstacle check thread because it doesn't answer...");
1477 emit
message(
"Obstacle check thread terminated.");
1487 emit
message(
"Stopping laser thread...");
1504 }
while ((
laserThread->isFinished() ==
false) && (t.elapsed() <= 2000));
1508 emit
message(
"Laser thread stopped.");
1512 emit
message(
"ERROR: Terminating laser thread because it doesn't answer...");
1513 emit
splashMessage(
"Terminating laser thread because it doesn't answer...");
1516 emit
message(
"Laser thread terminated.");
1521 #ifdef Q_OS_LINUX // currently supported only under linux (no MAC OS at the moment)
1527 emit
message(
"Stopping speak thread...");
1544 }
while ((
speakThread->isFinished() ==
false) && (t.elapsed() <= 2000));
1548 emit
message(
"Speak thread stopped.");
1552 emit
message(
"ERROR: Terminating speak thread because it doesn't answer...");
1553 emit
splashMessage(
"Terminating speak thread because it doesn't answer...");
1556 emit
message(
"Speak thread terminated.");
1567 emit
message(
"Stopping joystick thread...");
1574 joystick->setPriority(QThread::IdlePriority);
1584 }
while ((
joystick->isFinished() ==
false) && (t.elapsed() <= 2000));
1586 if (
joystick->isFinished() ==
true)
1588 emit
message(
"Joystick thread stopped.");
1592 emit
message(
"ERROR: Terminating joystick thread because it doesn't answer...");
1593 emit
splashMessage(
"Terminating joystick thread because it doesn't answer...");
1596 emit
message(
"Joystick thread terminated.");
1606 emit
message(
"Stopping timer thread...");
1623 }
while ((
timerThread->isFinished() ==
false) && (t.elapsed() <= 2000));
1627 emit
message(
"Timer thread stopped.");
1631 emit
message(
"ERROR: Terminating timer thread because it doesn't answer...");
1632 emit
splashMessage(
"Terminating timer thread because it doesn't answer...");
1635 emit
message(
"Timer thread terminated.");
1645 emit
message(
"Stopping demo thread...");
1652 demoThread->setPriority(QThread::IdlePriority);
1662 }
while ((
demoThread->isFinished() ==
false) && (t.elapsed() <= 2000));
1666 emit
message(
"Timer thread stopped.");
1670 emit
message(
"ERROR: Terminating demo thread because it doesn't answer...");
1671 emit
splashMessage(
"Terminating demo thread because it doesn't answer...");
1674 emit
message(
"Demo thread terminated.");
1680 #ifndef BUILDFORROBOT
1688 emit
message(
"Stopping Plot thread...");
1695 plotThread->setPriority(QThread::IdlePriority);
1705 }
while ((
plotThread->isFinished() ==
false) && (t.elapsed() <= 2000));
1709 emit
message(
"Plot thread stopped.");
1713 emit
message(
"ERROR: Terminating Plot thread because it doesn't answer...");
1714 emit
splashMessage(
"Terminating Plot thread because it doesn't answer...");
1717 emit
message(
"Plot thread terminated.");
1730 emit
message(
"Stopping sensor thread...");
1747 }
while ((
sensorThread->isFinished() ==
false) && (t.elapsed() <= 2000));
1751 emit
message(
"Sensor thread stopped.");
1755 emit
message(
"ERROR: Terminating sensor thread because it doesn't answer...");
1756 emit
splashMessage(
"Terminating sensor thread because it doesn't answer...");
1759 emit
message(
"Sensor thread terminated.");
1809 emit
message(
"Stopping network thread...");
1820 netThread->setPriority(QThread::IdlePriority);
1830 }
while ((
netThread->isFinished() ==
false) && (t.elapsed() <= 2000));
1834 emit
message(
"Network thread stopped.");
1838 emit
message(
"ERROR: Terminating network thread because it doesn't answer...");
1839 emit
splashMessage(
"Terminating network thread because it doesn't answer...");
1842 emit
message(
"Network thread terminated.");
1853 emit
message(
"Putting robot to sleep...");
1859 emit
message(
"Closing serial port to microcontroller...");
1864 emit
splashMessage(
"Shutdown forced, no circuit communication anymore...");
1865 emit
message(
"Shutdown forced, no circuit communication anymore...");
1873 logfile->
appendLog(
"-------------------------------------------------------------------------------------------- stop -");
1896 QCoreApplication::quit();
1909 #ifdef Q_OS_LINUX // currently supported only under linux (no MAC OS at the moment)
1916 #ifndef BUILDFORROBOT
1956 emit
message(
"<font color=\"#FF0000\">THERE IS A BIG COMMUNICATION PROBLEM WITH THE SERIAL PORT TO THE ROBOT!</font>");
1984 QApplication::processEvents();
1988 QByteArray textForConsole;
1997 start = text.indexOf(
"<");
2001 text.remove(start, text.indexOf(
">") + 1 - start );
2003 }
while (text.contains(
">"));
2008 textForConsole = text.toLatin1();
2009 qDebug(
"%s", textForConsole.data());
2028 static short int lastSensorValue = -1;
2051 if ((sensorAlarm == lastSensorValue) && (
robotDrives))
2054 lastSensorValue = sensorAlarm;
2060 if (sensorAlarm ==
NONE)
2070 lastSensorValue = sensorAlarm;
2114 lastSensorValue = sensorAlarm;
2122 emit
message(
"<b>Obstacle front left. Turning right.</b>");
2157 lastSensorValue = sensorAlarm;
2165 emit
message(
"<b>Obstacle front right. Turning left.</b>");
2190 lastSensorValue = sensorAlarm;
2199 emit
message(
"<b>Obstacles everywhere in front of the robot. Waiting.</b>");
2206 emit
speak(
"I think, I need some help!");
2216 if (state == Qt::Checked)
2232 Q_UNUSED(faceRadius);
2468 static unsigned char lastCommand = 255;
2472 if (command == lastCommand)
2478 lastCommand = command;
2483 emit
message(
"FORWARD... ",
false);
2496 emit
message(
"ok",
true,
false,
false);
2506 emit
message(
"BACKWARD... ",
false);
2519 emit
message(
"ok",
true,
false,
false);
2529 emit
message(
"LEFT... ",
false);
2542 emit
message(
"ok",
true,
false,
false);
2552 emit
message(
"RIGHT... ",
false);
2565 emit
message(
"ok",
true,
false,
false);
2575 emit
message(
"TURNLEFT... ",
false);
2588 emit
message(
"ok",
true,
false,
false);
2598 emit
message(
"TURNRIGHT... ",
false);
2611 emit
message(
"ok",
true,
false,
false);
2622 emit
message(
"Starting to drive...");
2623 emit
message(
"START... ",
false);
2665 emit
message(
"WAIT... ",
false);
2682 emit
message(
"ok",
true,
false,
false);
2695 emit
message(
"STOP... ",
false);
2712 emit
message(
"ok",
true,
false,
false);
2726 emit
message(
"Motor 1 forward");
2732 emit
message(
"ERROR motor 1 CCW");
2737 emit
message(
"Motor 1 backward");
2743 emit
message(
"ERROR motor 1 CW");
2754 emit
message(
"ERROR motor 1 OFF");
2759 emit
message(
"Motor 2 forward");
2769 emit
message(
"Motor 2 backward");
2789 emit
message(
"Motor 3 forward");
2799 emit
message(
"Motor 3 backward");
2819 emit
message(
"Motor 4 forward");
2829 emit
message(
"Motor 4 backward");
2849 emit
message(QString(
"<font color=\"#FF0000\">ERROR: Driving direction '%1' not implemented or set in Drive()!</font>").arg(command));
2867 int currentSpeed1 = 0;
2868 int currentSpeed2 = 0;
2869 int currentSpeed3 = 0;
2870 int currentSpeed4 = 0;
2878 currentSpeed1 += increaseInterval;
2891 currentSpeed2 += increaseInterval;
2903 currentSpeed3 += increaseInterval;
2915 currentSpeed4 += increaseInterval;
2937 emit
message(
"Reading settings...");
2945 emit
message(
"<font color=\"#FF0000\">Value \"writeLogFile\"not found in ini-file!</font>");
2949 emit
message(
"Not writing a logfile.");
2953 emit
message(
"Writing a logfile!");
2957 connect(
this, SIGNAL(
message(QString) ),
logfile, SLOT( appendLog(QString) ));
2965 QString portString =
"serialPortMicrocontrollerLinux";
2969 QString portString =
"serialPortMicrocontrollerMac";
2976 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(portString));
2994 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerTypeFront\" not found in ini-file!</font>");
3006 portString =
"serialPortLaserscannerFrontLinux";
3010 portString =
"serialPortLaserscannerFrontMac";
3018 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(portString));
3033 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerMountingFront\" not found in ini-file!</font>");
3048 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerAngleFront\"not found in ini-file!</font>");
3068 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerResolutionFront\" not found in ini-file!</font>");
3082 emit
message(QString(
"Front laser scanner resolution set to <b>%1</b>.").arg(
floatValue));
3091 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerFrontIgnoreArea1Start\"not found in ini-file!</font>");
3102 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerFrontIgnoreArea1End\"not found in ini-file!</font>");
3129 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerFrontIgnoreArea2Start\"not found in ini-file!</font>");
3140 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerFrontIgnoreArea2End\"not found in ini-file!</font>");
3173 emit
message(
"<font color=\"#FF0000\">ini-file is not writeable!</font>");
3180 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerTypeRear\" not found in ini-file!</font>");
3195 emit
message(
"<font color=\"#FF0000\">ini-file is not writeable!</font>");
3202 emit
message(
"<font color=\"#FF0000\">Value \"serialPortLaserscannerRear\" not found in ini-file!</font>");
3217 emit
message(
"<font color=\"#FF0000\">ini-file is not writeable!</font>");
3224 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerMountingRear\" not found in ini-file!</font>");
3239 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerAngleRear\"not found in ini-file!</font>");
3259 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerResolutionRear\" not found in ini-file!</font>");
3273 emit
message(QString(
"Rear laser scanner resolution set to <b>%1</b>.").arg(
floatValue));
3281 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerRearIgnoreArea1Start\"not found in ini-file!</font>");
3292 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerRearIgnoreArea1End\"not found in ini-file!</font>");
3318 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerRearIgnoreArea2Start\"not found in ini-file!</font>");
3329 emit
message(
"<font color=\"#FF0000\">Value \"laserscannerRearIgnoreArea2End\"not found in ini-file!</font>");
3359 #ifdef ACTIVELASERVIEW
3365 gui->initLaserStuff();
3374 emit
message(
"<font color=\"#FF0000\">Value \"useCamera\"not found in ini-file!</font>");
3384 emit
message(
"<font color=\"#FF0000\">No camera usage! (see ini-file)</font>");
3399 if (cameraDevice == -2)
3402 emit
message(
"<font color=\"#FF0000\">ini-file is not writeable!</font>");
3406 if (cameraDevice == -1)
3409 emit
message(
"<font color=\"#FF0000\">Value \"cameraDevice\" not found in ini-file!</font>");
3424 QString haarClassifierCascade =
inifile1->
readString(
"Config",
"haarClassifierCascade");
3426 if (haarClassifierCascade ==
"error2")
3429 emit
message(
"<font color=\"#FF0000\">ini-file is not writeable!</font>");
3433 if (haarClassifierCascade ==
"error1")
3436 emit
message(
"<font color=\"#FF0000\">Value \"haarClassifierCascade\" not found in ini-file!</font>");
3445 emit
message(QString(
"Haar classifier cascade file set to<br><b>%1</b>.").arg(haarClassifierCascade));
3473 emit
message(
"<font color=\"#FF0000\">Value \"noHardwareErrorMessages\"not found in ini-file!</font>");
3480 emit
message(
"<font color=\"#808080\">Suppressing hardware error messages (see ini-file)</font>");
3489 emit
message(
"<font color=\"#FF0000\">Value \"saveOnExit\"not found in ini-file!</font>");
3512 emit
message(
"<font color=\"#FF0000\">Value \"exitDialog\"not found in ini-file!</font>");
3526 switch (minObstacleDistance)
3529 emit
message(
"<font color=\"#FF0000\">Value \"minObstacleDistance\"not found in ini-file!</font>");
3541 emit
message(QString(
"Min. obstacle distance set to <b>%1 cm</b>.").arg(minObstacleDistance));
3547 int minObstacleDistanceLaserScannerFront =
inifile1->
readSetting(
"Config",
"minObstacleDistanceLaserScannerFront");
3549 switch (minObstacleDistanceLaserScannerFront)
3552 emit
message(
"<font color=\"#FF0000\">Value \"minObstacleDistanceLaserScannerFront\"not found in ini-file!</font>");
3564 emit
message(QString(
"Min. obstacle distance front laser scanner set to <b>%1 cm</b>.").arg(minObstacleDistanceLaserScannerFront));
3570 int minObstacleDistanceLaserScannerRear =
inifile1->
readSetting(
"Config",
"minObstacleDistanceLaserScannerRear");
3572 switch (minObstacleDistanceLaserScannerRear)
3575 emit
message(
"<font color=\"#FF0000\">Value \"minObstacleDistanceLaserScannerRear\"not found in ini-file!</font>");
3587 emit
message(QString(
"Min. obstacle distance rear laser scanner set to <b>%1 cm</b>.").arg(minObstacleDistanceLaserScannerRear));
3595 switch (passageWidth)
3598 emit
message(
"<font color=\"#FF0000\">Value \"robotPassageWidth\"not found in ini-file!</font>");
3610 emit
message(QString(
"Robot passage width width set to <b>%1 cm.</b>").arg(passageWidth));
3616 int straightForwardDeviation =
inifile1->
readSetting(
"Config",
"straightForwardDeviation");
3618 switch (straightForwardDeviation)
3621 emit
message(
"<font color=\"#FF0000\">Value \"straightForwardDeviation\"not found in ini-file!</font>");
3633 emit
message(QString(
"Straight forward deviation set to <b>%1 deg.</b>").arg(straightForwardDeviation));
3641 if (joystickPort ==
"error2")
3643 emit
message(
"<font color=\"#FF0000\">ini-file is not writeable!</font>");
3647 if (joystickPort ==
"error1")
3649 emit
message(
"<font color=\"#FF0000\">Value \"joystickPort\" not found in ini-file!</font>");
3658 emit
message(QString(
"Joystick port set to <b>%1</b>.").arg(joystickPort));
3669 emit
message(
"<font color=\"#FF0000\">Value \"motor1Speed\" not found in ini-file!</font>");
3675 emit
message(QString(
"<font color=\"#FF0000\">Value \"motor1Speed\" is greater than %1!! Value set to %1!</font>").arg(
MAXPWM));
3697 emit
message(
"<font color=\"#FF0000\">Value \"motor2Speed\" not found in ini-file!</font>");
3703 emit
message(QString(
"<font color=\"#FF0000\">Value \"motor2Speed\" is greater than %1!! Value set to %1!</font>").arg(
MAXPWM));
3725 emit
message(
"<font color=\"#FF0000\">Value \"motor3Speed\" not found in ini-file!</font>");
3731 emit
message(QString(
"<font color=\"#FF0000\">Value \"motor3Speed\" is greater than %1!! Value set to %1!</font>").arg(
MAXPWM));
3753 emit
message(
"<font color=\"#FF0000\">Value \"motor4Speed\" not found in ini-file!</font>");
3759 emit
message(QString(
"<font color=\"#FF0000\">Value \"motor1Speed\" is greater than %1!! Value set to %1!</font>").arg(
MAXPWM));
3781 emit
message(
"<font color=\"#FF0000\">Value \"minimumSpeed\" not found in ini-file!</font>");
3787 emit
message(QString(
"<font color=\"#FF0000\">Value \"minimumSpeed\" is greater than %1!! Value set to %1!</font>").arg(
MAXPWM));
3809 emit
message(
"<font color=\"#FF0000\">Value \"maximumSpeed\" not found in ini-file!</font>");
3815 emit
message(QString(
"<font color=\"#FF0000\">Value \"maximumSpeed\" is greater than %1!! Value set to %1!</font>").arg(
MAXPWM));
3834 QString settingName = QString(
"servo%1").arg(servo+1).append(
"StartPos");
3837 switch (settingValue)
3840 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(settingName));
3844 if (settingValue > 254)
3846 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" is greater than 255!! Value set to 255!</font>").arg(settingName));
3858 emit
message(
"Servo start settings read and set.");
3864 QString settingName = QString(
"servo%1").arg(servo+1).append(
"EndPos");
3867 switch (settingValue)
3870 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(settingName));
3874 if (settingValue > 254)
3876 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" is greater than 255!! Value set to 255!</font>").arg(settingName));
3888 emit
message(
"Servo end settings read and set.");
3894 QString settingName = QString(
"servo%1").arg(servo+1).append(
"MinPos");
3897 switch (settingValue)
3900 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(settingName));
3904 if (settingValue > 254)
3906 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" is greater than 255!! Value set to 255!</font>").arg(settingName));
3918 emit
message(
"Servo min. settings read and set.");
3924 QString settingName = QString(
"servo%1").arg(servo+1).append(
"MaxPos");
3927 switch (settingValue)
3930 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(settingName));
3934 if (settingValue > 254)
3936 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" is greater than 255!! Value set to 255!</font>").arg(settingName));
3948 emit
message(
"Servo max. settings read and set.");
3954 QString settingName = QString(
"servo%1").arg(servo+1).append(
"DefaultPos");
3957 switch (settingValue)
3960 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(settingName));
3964 if (settingValue > 254)
3966 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" is greater than 255!! Value set to 255!</font>").arg(settingName));
3978 emit
message(
"Servo default settings read and set.");
3986 QString settingName = QString(
"RGBLED%1").arg(led+1).append(
"MinBrightness");
3989 switch (settingValue)
3992 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(settingName));
3996 if (settingValue >
MAXPWM)
3998 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" is greater than %2!! Value set to %2!</font>").arg(settingName).arg(
MAXPWM));
4006 emit
message(QString(
"%1 set to <b>%2</b>.").arg(settingName).arg(settingValue));
4010 emit
message(
"RGB LED min. settings read and set.");
4016 QString settingName = QString(
"RGBLED%1").arg(led+1).append(
"MaxBrightness");
4019 switch (settingValue)
4022 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(settingName));
4026 if (settingValue >
MAXPWM)
4028 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" is greater than %2!! Value set to %2!</font>").arg(settingName).arg(
MAXPWM));
4036 emit
message(QString(
"%1 set to <b>%2</b>.").arg(settingName).arg(settingValue));
4040 emit
message(
"RGB LED max. settings read and set.");
4046 QString settingName = QString(
"RGBLED%1").arg(led+1).append(
"DefaultBrightness");
4049 switch (settingValue)
4052 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" not found in ini-file!</font>").arg(settingName));
4056 if (settingValue >
MAXPWM)
4058 emit
message(QString(
"<font color=\"#FF0000\">Value \"%1\" is greater than %2!! Value set to %2!</font>").arg(settingName).arg(
MAXPWM));
4066 emit
message(QString(
"%1 set to <b>%2</b>.").arg(settingName).arg(settingValue));
4070 emit
message(
"RGB LED default settings read and set.");
4080 emit
message(
"<font color=\"#FF0000\">Value \"networkPortListen\" not found in ini-file!</font>");
4092 emit
message(
"<font color=\"#FF0000\">Value \"networkPortSend\" not found in ini-file!</font>");
4109 emit
message(QString(
"<font color=\"#FF0000\">Error setting network ports to <b>%1 and %2</b>.</font>").arg(
value).arg(
networkPortSend));
4128 emit
message(
"<font color=\"#FF0000\">Value \"threshold\" not found in ini-file!</font>");
4137 emit
message(QString(
"Setting threshold to <b>%1</b>.").arg(
value));
4156 emit
message(
"Starting network thread... ",
false);
4162 emit
message(
"started.",
true,
false,
false);
4173 emit
message(
"Stopping network thread...",
false);
4179 emit
message(
"Network thread stopped.");
4214 if (command.contains(
"*master#"))
4252 if (command ==
"start")
4254 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4260 if (command ==
"forward")
4262 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4268 if (command ==
"backward")
4270 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4276 if (command ==
"stop")
4278 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4284 if (command ==
"left")
4286 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4292 if (command ==
"right")
4294 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4300 if (command ==
"increasespeedmotor1")
4302 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4316 if (command ==
"increasespeedmotor2")
4318 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4332 if (command ==
"reducespeedmotor1")
4334 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4348 if (command ==
"reducespeedmotor2")
4350 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4363 if (command ==
"shutdown")
4365 emit
message(tr(
"<font color=\"#0000FF\">Executing remote command \"%1\".</font>").arg(command));
4793 emit
message(QString(
"Servo 1 moved to %1.").arg(servo1Pos));
4939 static bool toggle0 =
false;
4940 static bool toggle1 =
false;
4945 static bool toggle10 =
false;
4946 static bool toggle11 =
false;
4950 switch (buttonNumber)
4953 if (buttonState==
true)
4955 if (toggle0 ==
false)
4979 if (buttonState==
true)
4981 if (toggle1 ==
false)
4984 emit
message(
"<font color=\"#0000FF\">Servo test mode ON.</front>");
4986 emit
speak(
"Servo test mode");
4991 emit
message(
"<font color=\"#0000FF\">Servo test mode OFF.</front>");
4992 emit
speak(
"Servo test mode disabled");
5007 if (buttonState==
true)
5018 if (buttonState==
true)
5031 if (buttonState==
true)
5033 if (toggle10 ==
false)
5036 emit
message(
"<font color=\"#0000FF\">Mecanum test mode enabled.</front>");
5037 emit
speak(
"Mecanum test mode.");
5042 emit
message(
"<font color=\"#0000FF\">Mecanum test mode disabled.</front>");
5043 emit
speak(
"Mecanum test mode disabled.");
5045 toggle10 = !toggle10;
5052 if (buttonState==
true)
5054 if (toggle11 ==
false)
5069 toggle11 = !toggle11;
5088 emit
message(
"<font color=\"#0000FF\">Simulation mode enabled!!</front>");
5092 emit
message(
"Starting Laser thread...",
false);
5099 emit
message(
"Starting Sensor thread...",
false);
5104 #ifndef BUILDFORROBOT
5109 emit
message(
"Starting plot thread...",
false);
5118 emit
message(
"Initializing obstacle check thread...",
false);
5121 emit
message(
"Starting obstacle check thread...",
false);
5134 emit
message(
"<font color=\"#0000FF\">Simulation mode disabled.</font>");
5149 if (
arguments.contains(
"console", Qt::CaseInsensitive))
5153 qDebug(
"CONSOLE mode activated. Now passing all messages to the console.");
5160 static int iPhase = phase;
5165 emit
message(QString(
"demo phase=%1").arg(iPhase));
5175 emit
speak(
"Hello Campuseros. I will introduce myself now for you guys. My name is direx 1. And I hope everything works fine now in the next minutes. Since Marcus updated my software yesterday night very late.", ++phase);
5179 emit
speak(
"I am able of driving araound autonomically without hitting any obstacles. Well. Hopefully. I am using a laserscanner. and I can show my status with some R G B LEDs. I can also send my data over wireless network to show them on another laptop, or so.", ++phase);
5183 emit
speak(
"But I do not want to bore you any longer. See me driving around and enjoy it. We should do some party now. The music is played by random. Because Sebastian complained that I played the same title all night long. So if the next song is still boring, Markus cann skip it on the touchscreen. Okay. lets go! Put your hands up in the air and wave them like you just dont care!", ++phase);
5213 emit
message(
"<font color=\"#0000FF\">Demo mode enabled!!</front>");
5217 emit
message(
"Starting demo thread...",
false);
5221 emit
speak(
"Okay, here we go.", 1);
5229 emit
message(
"<font color=\"#0000FF\">Demo mode disabled!!</front>");
5237 emit
message(
"Stopping demo thread...",
false);
5246 int number = rand() % 6 +1;
5251 emit
message(QString(
"Media player restart with file %1.").arg(number));
5257 mediaObject->setCurrentSource(Phonon::MediaSource(QString(
"../../../../media/%1").arg(number)));
5259 mediaObject->setCurrentSource(Phonon::MediaSource(QString(
"../../../../media/%1.mp3").arg(number)));
5275 emit
message(
"<font color=\"#0000FF\"Emergency stop due to laserscanner problems!/font>");
5287 emit
message(
"Error with sensor thread. Forcing shutdown when exitng direcs later (No last hardware init).");
5288 logfile->
appendLog(
"Error with sensor thread. Forcing shutdown when exitng direcs later (No last hardware init).");
5289 #ifndef BUILDFORROBOT
5384 emit
speak(tr(
"Hello world"));