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