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