2 * RobomonAtlantis.h 07/10/31
4 * Robot's visualization and control GUI for robot of the
5 * Eurobot 2008 competition (Mission to Mars).
7 * Copyright: (c) 2008 CTU Dragons
8 * CTU FEE - Department of Control Engineering
9 * Authors: Martin Zidek, Michal Sojka, Tran Duy Khanh
10 * License: GNU GPL v.2
13 #ifndef ROBOMON_ATLANTIS_H
14 #define ROBOMON_ATLANTIS_H
21 #include "PlaygroundScene.h"
22 #include "playgroundview.h"
25 #include <roboorte_robottype.h>
27 #include "hokuyoscan.h"
28 #include <QMainWindow>
46 class MotorSimulation : QObject {
51 struct robottype_orte_data &orte;
53 MotorSimulation(struct robottype_orte_data &orte) : QObject(), timer(this), orte(orte) {}
56 robottype_publisher_motion_irc_create(&orte, 0, 0);
57 connect(&timer, SIGNAL(timeout()), this, SLOT(updateIRC()));
63 robottype_publisher_motion_irc_destroy(&orte);
65 disconnect(&timer, SIGNAL(timeout()), this, SLOT(updateIRC()));
70 qint64 now = QDateTime::currentMSecsSinceEpoch();
71 orte.motion_irc.left += orte.motion_speed.left * (now - last_time); // TODO: Find constant for speed to irc conversion
72 orte.motion_irc.right+= orte.motion_speed.right * (now - last_time);
73 ORTEPublicationSend(orte.publication_motion_irc);
79 class RobomonAtlantis : public QWidget
84 RobomonAtlantis(QStatusBar *_statusBar = 0);
87 bool event(QEvent *event);
88 void keyPressEvent(QKeyEvent *event);
89 void keyReleaseEvent(QKeyEvent *event);
90 void closeEvent(QCloseEvent *event);
93 void motionStatusReceivedSignal();
94 void actualPositionReceivedSignal();
95 void powerVoltageReceivedSignal();
98 void showMap(bool show);
99 void useOpenGL(bool use);
100 void showTrails(bool show);
101 void showShapeDetect(bool show);
104 /************************************************************
106 ************************************************************/
107 void setVoltage33(int state);
108 void setVoltage50(int state);
109 void setVoltage80(int state);
110 /* void setLeftMotor(int value); */
111 /* void setRightMotor(int value); */
112 /* void stopMotors(); */
114 void setSimulation(int state);
115 void setObstacleSimulation(int state);
116 void simulateObstaclesHokuyo();
117 void changeObstacle(QPointF position);
118 void sendStart(int plug);
119 void setMotorSimulation(int state);
121 /************************************************************
123 ************************************************************/
124 void motionStatusReceived();
125 void actualPositionReceived();
126 void powerVoltageReceived();
129 /************************************************************
131 ************************************************************/
132 void createLeftLayout();
133 void createRightLayout();
135 void createPlaygroundGroupBox();
136 void createPositionGroupBox();
137 void createMiscGroupBox();
138 void createDebugGroupBox();
139 void createActuatorsGroupBox();
140 void createMotorsGroupBox();
141 void createDIOGroupBox();
142 void createSensorsGroupBox();
143 void createPowerGroupBox();
144 void createPickerGroupBox();
145 void createFSMGroupBox();
148 void createActions();
151 QStatusBar *statusBar;
153 QVBoxLayout *leftLayout;
154 QVBoxLayout *rightLayout;
156 QGroupBox *playgroundGroupBox;
157 QGroupBox *positionGroupBox;
158 QGroupBox *miscGroupBox;
159 QGroupBox *debugGroupBox;
160 QGroupBox *actuatorsGroupBox;
161 QGroupBox *powerGroupBox;
162 QGroupBox *fsmGroupBox;
165 PlaygroundScene *playgroundScene;
167 PlaygroundView *playgroundSceneView;
172 QLineEdit *actPosPhi;
176 QLineEdit *estPosPhi;
179 QTextEdit *debugWindow;
180 bool debugWindowEnabled;
183 /* QSlider *leftMotorSlider; */
184 /* QSlider *rightMotorSlider; */
185 /* QCheckBox *bothMotorsCheckBox; */
186 /* QPushButton *stopMotorsPushButton; */
189 /* power management */
190 QCheckBox *voltage33CheckBox;
191 QCheckBox *voltage50CheckBox;
192 QCheckBox *voltage80CheckBox;
193 QLineEdit *voltage33LineEdit;
194 QLineEdit *voltage50LineEdit;
195 QLineEdit *voltage80LineEdit;
196 QLineEdit *voltageBATLineEdit;
199 QCheckBox *obstacleSimulationCheckBox;
200 QCheckBox *motorSimulationCheckBox;
201 QLabel *fsm_main_state;
202 QLabel *fsm_act_state;
203 QLabel *fsm_motion_state;
204 QLabel *system_status;
205 QCheckBox *startPlug;
206 QCheckBox *colorChoser;
210 Robot *robotEstPosBest;
211 Robot *robotEstPosIndepOdo;
212 Robot *robotEstPosOdo;
217 Trail *trailEstPosBest;
218 Trail *trailPosIndepOdo;
221 HokuyoScan *hokuyoScan;
224 double leftMotorValue;
225 double rightMotorValue;
228 void openSharedMemory();
229 bool sharedMemoryOpened;
232 /* obstacle simulation */
233 double distanceToWallHokuyo(int beamnum);
234 double distanceToObstacleHokuyo(int beamnum, Point obstacle, double obstacleSize);
235 int simulationEnabled;
237 QTimer *obstacleSimulationTimer;
238 Point simulatedObstacle;
240 class MotorSimulation motorSimulation;
242 /************************************************************
244 ************************************************************/
247 struct robottype_orte_data orte;
250 #endif /* ROBOMON_ATLANTIS_H */