]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/robomon/RobomonAtlantis.h
robomon controls map and trail visibility from the new View menu
[eurobot/public.git] / src / robomon / RobomonAtlantis.h
1 /*
2  * RobomonAtlantis.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_ATLANTIS_H
14 #define ROBOMON_ATLANTIS_H
15
16 #define SIM_OBST_SIZE_M 0.5
17
18 #include <QDialog>
19
20 #include <trgen.h>
21 #include "PlaygroundScene.h"
22 #include "Robot.h"
23 #include <roboorte_robottype.h>
24 #include <roboorte.h>
25 #include "trail.h"
26
27 class QHBoxLayout;
28 class QVBoxLayout;
29 class QGridLayout;
30 class QGroupBox;
31 class QGraphicsView;
32 class QLabel;
33 class QPushButton;
34 class QCheckBox;
35 class QLineEdit;
36 class QTextEdit;
37 class QDial;
38 class QSlider;
39 class QProgressBar;
40 class QFont;
41
42 class RobomonAtlantis : public QWidget
43 {
44         Q_OBJECT
45
46 public:
47         RobomonAtlantis(QWidget *parent = 0);
48
49 protected:
50         bool event(QEvent *event);
51         void keyPressEvent(QKeyEvent *event);
52         void keyReleaseEvent(QKeyEvent *event);
53         void closeEvent(QCloseEvent *event);
54
55 signals:
56         void motionStatusReceivedSignal();
57         void actualPositionReceivedSignal();
58         void estimatedPositionReceivedSignal();
59         void diReceivedSignal();
60         void accelerometerReceivedSignal();
61         void accumulatorReceivedSignal();
62         void powerVoltageReceivedSignal();
63         
64 public slots:
65         void showMap(bool show);
66         void showTrails(bool show);
67         void resetTrails();
68 private slots:
69         /************************************************************
70          * GUI actions 
71          ************************************************************/
72         void setVoltage33(int state);
73         void setVoltage50(int state);
74         void setVoltage80(int state);
75         void setLeftMotor(int value);
76         void setRightMotor(int value);
77         void stopMotors();
78         void setDO(int state);
79         void paintMap();
80         void setSimulation(int state);
81         void setObstacleSimulation(int state);
82         void simulateObstaclesHokuyo();
83         void changeObstacle(QPointF position);
84         void pick();
85         void setBelts(int value);
86         void setChelae(int value);
87         void sendStart(int plug);
88         void sendPuckInside(int value);
89
90         /************************************************************
91          * ORTE 
92          ************************************************************/
93         void motionStatusReceived();
94         void actualPositionReceived();
95         void estimatedPositionReceived();
96         void diReceived();
97         void accelerometerReceived();
98         void accumulatorReceived();
99         void powerVoltageReceived();
100
101 private:
102         /************************************************************
103          * GUI
104          ************************************************************/
105         void createLeftLayout();
106         void createRightLayout();
107
108         void createPlaygroundGroupBox();
109         void createPositionGroupBox();
110         void createMiscGroupBox();
111         void createDebugGroupBox();
112         void createActuatorsGroupBox();
113         void createMotorsGroupBox();
114         void createDIOGroupBox();
115         void createSensorsGroupBox();
116         void createPowerGroupBox();
117         void createPickerGroupBox();
118         void createFSMGroupBox();
119
120         void createRobots();
121         void createActions();
122
123         QVBoxLayout *leftLayout;
124         QVBoxLayout *rightLayout;
125
126         QGroupBox *playgroundGroupBox;
127         QGroupBox *positionGroupBox;
128         QGroupBox *miscGroupBox;
129         QGroupBox *debugGroupBox;
130         QGroupBox *actuatorsGroupBox;
131         QGroupBox *enginesGroupBox;
132         QGroupBox *dioGroupBox;
133         QGroupBox *sensorsGroupBox;
134         QGroupBox *powerGroupBox;
135         QGroupBox *pickerGroupBox;
136         QGroupBox *fsmGroupBox;
137
138         PlaygroundScene *playgroundScene;
139         QGraphicsView *playgroundSceneView;
140
141         /* position state */
142         QLineEdit *actPosX;
143         QLineEdit *actPosY;
144         QLineEdit *actPosPhi;
145
146         QLineEdit *estPosX;
147         QLineEdit *estPosY;
148         QLineEdit *estPosPhi;
149
150         /* debug window */
151         QTextEdit *debugWindow;
152         bool debugWindowEnabled;
153
154         /* actuators */
155         QSlider *leftMotorSlider;
156         QSlider *rightMotorSlider;
157         QCheckBox *bothMotorsCheckBox;
158         QPushButton *stopMotorsPushButton;
159
160         QCheckBox *leftBeltCheckBox;
161         QCheckBox *rightBeltCheckBox;
162         QCheckBox *leftChelaCheckBox;
163         QCheckBox *rightChelaCheckBox;
164
165         QDial *leftBeltDial;
166         QDial *rightBeltDial;
167         QDial *leftChelaDial;
168         QDial *rightChelaDial;
169         QPushButton *pickPushButton;
170
171         /* power management */
172         QCheckBox *voltage33CheckBox;
173         QCheckBox *voltage50CheckBox;
174         QCheckBox *voltage80CheckBox;
175         QLineEdit *voltage33LineEdit;
176         QLineEdit *voltage50LineEdit;
177         QLineEdit *voltage80LineEdit;
178         QLineEdit *voltageBATLineEdit;
179
180         QCheckBox *diCheckBox[8];
181         QCheckBox *doCheckBox[8];
182
183         /* misc */
184         QCheckBox *obstacleSimulationCheckBox;
185         QLabel *fsm_main_state;
186         QLabel *fsm_act_state;
187         QLabel *fsm_motion_state;
188         QCheckBox *startPlug;
189         QCheckBox *puckInside;
190
191         /* robot */
192         Robot *robotActPos;
193         Robot *robotEstPosUzv;
194         Robot *robotEstPosOdo;
195         
196         Trail *trailRefPos;
197         Trail *trailUzvPos;
198         Trail *trailOdoPos;
199
200         /* keypad */
201         double leftMotorValue;
202         double rightMotorValue;
203
204         /* map */
205         void openSharedMemory();
206         bool sharedMemoryOpened;
207         QTimer *mapTimer;
208         
209         /* sensors */
210         QProgressBar *sharpPuck;
211         QProgressBar *liftPos;
212         QProgressBar *pusherPos;
213
214         /* obstacle simulation */
215         double distanceToWallHokuyo(int beamnum);
216         double distanceToObstacleHokuyo(int beamnum, Point obstacle, double obstacleSize);
217         int simulationEnabled;
218
219         QTimer *obstacleSimulationTimer;
220         Point simulatedObstacle;
221
222         /************************************************************
223          * ORTE 
224          ************************************************************/
225         void createOrte();
226
227         struct robottype_orte_data orte;
228 };
229
230 #endif /* ROBOMON_ATLANTIS_H */