]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/robomon/src2/RobomonExplorer.h
Robomon: deleted solved FIXMEs
[eurobot/public.git] / src / robomon / src2 / RobomonExplorer.h
1 /*
2  * RobomonExplorer.h                    07/10/31
3  *
4  * Robot's visualization and control GUI for robot of the
5  * Eurobot 2008 competition (Mission to Mars).
6  *
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
11  */
12
13 #ifndef ROBOMON_EXPLORER_H
14 #define ROBOMON_EXPLORER_H
15
16 #define SHARP_LONG_CNT 4
17 #define SHARP_SHORT_CNT 2
18
19 #define SIM_OBST_SIZE_M 0.5
20
21 #include <QDialog>
22
23 #include <sharp.h>
24 #include <trgen.h>
25 #include "PlaygroundScene.h"
26 #include "Robot.h"
27 #include <roboorte_generic.h>
28 #include <roboorte_eb2008.h>
29
30 class QHBoxLayout;
31 class QVBoxLayout;
32 class QGridLayout;
33 class QGroupBox;
34 class QGraphicsView;
35 class QLabel;
36 class QPushButton;
37 class QCheckBox;
38 class QLineEdit;
39 class QTextEdit;
40 class QDial;
41 class QSlider;
42 class QProgressBar;
43 class QFont;
44
45 #define PG_X 600
46 #define PG_Y 420
47
48 #define TOP_LEFT QPointF(10,0)
49 #define TOP_LEFT_X 10
50 #define TOP_LEFT_Y 0
51
52 class RobomonExplorer : public QWidget
53 {
54         Q_OBJECT
55
56 public:
57         RobomonExplorer(QWidget *parent = 0);
58
59 protected:
60         bool event(QEvent *event);
61         void keyPressEvent(QKeyEvent *event);
62         void keyReleaseEvent(QKeyEvent *event);
63         void closeEvent(QCloseEvent *event);
64
65 signals:
66         void motionStatusReceivedSignal();
67         void actualPositionReceivedSignal();
68         void estimatedPositionReceivedSignal();
69         void sharpsReceivedSignal();
70         void sharpLongsReceivedSignal(); //FIXME rm
71         void sharpShortsReceivedSignal(); //FIXME rm
72         void diReceivedSignal();
73         void accelerometerReceivedSignal();
74         void accumulatorReceivedSignal();
75         void powerVoltageReceivedSignal();
76
77 private slots:
78         /************************************************************
79          * GUI actions 
80          ************************************************************/
81         void setVoltage33(int state);
82         void setVoltage50(int state);
83         void setVoltage80(int state);
84         void setLeftMotor(int value);
85         void setRightMotor(int value);
86         void setDrives(int value);
87         void setLeftBrushDriveCB(int value);
88         void setRightBrushDriveCB(int value);
89         void setBagrDriveCB(int value);
90         void stopMotors();
91         void moveServos(int value);
92         void moveFrontDoor(int state);
93         void moveTopDoor(int state);
94         void moveBackDoor(int state);
95         void moveLeftBrush(int state);
96         void moveRightBrush(int state);
97         void setDO(int state);
98         void setLaser(int state);
99         void showMap();
100         void showPlayground();
101         void paintMap();
102         void setSharpValues(int value);
103         void setSimulation(int state);
104         void setObstacleSimulation(int state);
105         void simulateObstacles();
106         void changeObstacle(QPointF position);
107
108         /************************************************************
109          * ORTE 
110          ************************************************************/
111         void motionStatusReceived();
112         void actualPositionReceived();
113         void estimatedPositionReceived();
114         void sharpsReceived();
115         void diReceived();
116         void accelerometerReceived();
117         void accumulatorReceived();
118         void powerVoltageReceived();
119
120 private:
121         /************************************************************
122          * GUI
123          ************************************************************/
124         void createLeftLayout();
125         void createRightLayout();
126
127         void createPlaygroundGroupBox();
128         void createPositionGroupBox();
129         void createMiscGroupBox();
130         void createDebugGroupBox();
131         void createActuatorsGroupBox();
132         void createMotorsGroupBox();
133         void createServosGroupBox();
134         void createDrivesGroupBox();
135         void createDIOGroupBox();
136         void createSensorsGroupBox();
137         void createPowerGroupBox();
138
139         void createSharpSensorsLayout();
140
141         void createRobots();
142         void createActions();
143
144         QVBoxLayout *leftLayout;
145         QVBoxLayout *rightLayout;
146         QVBoxLayout *sharpSensorsLayout;
147
148         QGroupBox *playgroundGroupBox;
149         QGroupBox *positionGroupBox;
150         QGroupBox *miscGroupBox;
151         QGroupBox *debugGroupBox;
152         QGroupBox *actuatorsGroupBox;
153         QGroupBox *enginesGroupBox;
154         QGroupBox *servosGroupBox;
155         QGroupBox *drivesGroupBox;
156         QGroupBox *dioGroupBox;
157         QGroupBox *sensorsGroupBox;
158         QGroupBox *powerGroupBox;
159
160         PlaygroundScene *playgroundScene;
161         QGraphicsView *playgroundSceneView;
162
163         /* position state */
164         QLineEdit *actPosX;
165         QLineEdit *actPosY;
166         QLineEdit *actPosPhi;
167
168         QLineEdit *estPosX;
169         QLineEdit *estPosY;
170         QLineEdit *estPosPhi;
171
172         /* debug window */
173         QTextEdit *debugWindow;
174         bool debugWindowEnabled;
175
176         /* actuators */
177         QSlider *leftMotorSlider;
178         QSlider *rightMotorSlider;
179         QCheckBox *bothMotorsCheckBox;
180         QPushButton *stopMotorsPushButton;
181
182         QCheckBox *bottomDoorCheckBox;
183         QCheckBox *backDoorCheckBox;
184         QCheckBox *topDoorCheckBox;
185         QCheckBox *leftBrushCheckBox;
186         QCheckBox *rightBrushCheckBox;
187
188         QDial *leftBrushDial;
189         QDial *rightBrushDial;
190         QDial *bagrDial;
191         QDial *carouselDial;
192
193         QCheckBox *leftBrushDriveCheckBox;
194         QCheckBox *rightBrushDriveCheckBox;
195         QCheckBox *bagrDriveCheckBox;
196
197         /* power management */
198         QCheckBox *voltage33CheckBox;
199         QCheckBox *voltage50CheckBox;
200         QCheckBox *voltage80CheckBox;
201         QLineEdit *voltage33LineEdit;
202         QLineEdit *voltage50LineEdit;
203         QLineEdit *voltage80LineEdit;
204         QLineEdit *voltageBATLineEdit;
205
206         /* sensors */
207         QLabel *sharpLongsLabel[SHARP_LONG_CNT];
208         QLabel *sharpShortsLabel[SHARP_SHORT_CNT];
209         QProgressBar *sharpLongsProgressBar[SHARP_LONG_CNT];
210         QProgressBar *sharpShortsProgressBar[SHARP_SHORT_CNT];
211         QCheckBox *sensorsSimulationCheckBox;
212         QSlider *sharpLongsSlider[SHARP_LONG_CNT];
213         QSlider *sharpShortsSlider[SHARP_SHORT_CNT];
214
215         QCheckBox *diCheckBox[8];
216         QCheckBox *doCheckBox[8];
217
218         /* misc */
219         QCheckBox *sensorSimulationCheckBox;
220         QCheckBox *obstacleSimulationCheckBox;
221         QPushButton *showMapPushButton;
222         QCheckBox *laserEngineCheckBox;
223
224         /* robot */
225         Robot *robotActPos;
226         Robot *robotEstPos;
227
228         /* keypad */
229         double leftMotorValue;
230         double rightMotorValue;
231
232         /* map */
233         void openSharedMemory();
234         bool sharedMemoryOpened;
235         int cellSize;
236         QTimer *mapTimer;
237
238         /* obstacle simulation */
239         double distanceToWall(int sharpnum);
240         double distanceToObstacle(int sharpnum, Point obstacle, double obstacleSize);
241         int simulationEnabled;
242
243         QTimer *obstacleSimulationTimer;
244         Point simulatedObstacle;
245
246         /************************************************************
247          * ORTE 
248          ************************************************************/
249         void createOrte();
250
251         struct generic_orte_data orte_generic;
252         struct eb2008_orte_data orte_eb2008;
253 };
254
255 #endif /* ROBOMON_EXPLORER_H */