]> 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
86         /************************************************************
87          * ORTE 
88          ************************************************************/
89         void motionStatusReceived();
90         void actualPositionReceived();
91         void estimatedPositionReceived();
92         void diReceived();
93         void accelerometerReceived();
94         void accumulatorReceived();
95         void powerVoltageReceived();
96
97 private:
98         /************************************************************
99          * GUI
100          ************************************************************/
101         void createLeftLayout();
102         void createRightLayout();
103
104         void createPlaygroundGroupBox();
105         void createPositionGroupBox();
106         void createMiscGroupBox();
107         void createDebugGroupBox();
108         void createActuatorsGroupBox();
109         void createMotorsGroupBox();
110         void createDIOGroupBox();
111         void createSensorsGroupBox();
112         void createPowerGroupBox();
113         void createPickerGroupBox();
114         void createFSMGroupBox();
115
116         void createRobots();
117         void createActions();
118
119         QVBoxLayout *leftLayout;
120         QVBoxLayout *rightLayout;
121
122         QGroupBox *playgroundGroupBox;
123         QGroupBox *positionGroupBox;
124         QGroupBox *miscGroupBox;
125         QGroupBox *debugGroupBox;
126         QGroupBox *actuatorsGroupBox;
127         QGroupBox *enginesGroupBox;
128         QGroupBox *dioGroupBox;
129         QGroupBox *sensorsGroupBox;
130         QGroupBox *powerGroupBox;
131         QGroupBox *pickerGroupBox;
132         QGroupBox *fsmGroupBox;
133
134         PlaygroundScene *playgroundScene;
135         QGraphicsView *playgroundSceneView;
136
137         /* position state */
138         QLineEdit *actPosX;
139         QLineEdit *actPosY;
140         QLineEdit *actPosPhi;
141
142         QLineEdit *estPosX;
143         QLineEdit *estPosY;
144         QLineEdit *estPosPhi;
145
146         /* debug window */
147         QTextEdit *debugWindow;
148         bool debugWindowEnabled;
149
150         /* actuators */
151         QSlider *leftMotorSlider;
152         QSlider *rightMotorSlider;
153         QCheckBox *bothMotorsCheckBox;
154         QPushButton *stopMotorsPushButton;
155
156         QCheckBox *leftBeltCheckBox;
157         QCheckBox *rightBeltCheckBox;
158         QCheckBox *leftChelaCheckBox;
159         QCheckBox *rightChelaCheckBox;
160
161         QDial *leftBeltDial;
162         QDial *rightBeltDial;
163         QDial *leftChelaDial;
164         QDial *rightChelaDial;
165         QPushButton *pickPushButton;
166
167         /* power management */
168         QCheckBox *voltage33CheckBox;
169         QCheckBox *voltage50CheckBox;
170         QCheckBox *voltage80CheckBox;
171         QLineEdit *voltage33LineEdit;
172         QLineEdit *voltage50LineEdit;
173         QLineEdit *voltage80LineEdit;
174         QLineEdit *voltageBATLineEdit;
175
176         QCheckBox *diCheckBox[8];
177         QCheckBox *doCheckBox[8];
178
179         /* misc */
180         QCheckBox *obstacleSimulationCheckBox;
181         QCheckBox *showMapPushButton;
182         QLabel *fsm_main_state;
183         QLabel *fsm_act_state;
184         QLabel *fsm_motion_state;
185         QCheckBox *startPlug;
186
187         /* robot */
188         Robot *robotActPos;
189         Robot *robotEstPos;
190
191         /* keypad */
192         double leftMotorValue;
193         double rightMotorValue;
194
195         /* map */
196         void openSharedMemory();
197         bool sharedMemoryOpened;
198         QTimer *mapTimer;
199         
200         /* sensors */
201         QProgressBar *sharpPuck;
202         QProgressBar *liftPos;
203         QProgressBar *pusherPos;
204
205         /* obstacle simulation */
206         double distanceToWallHokuyo(int beamnum);
207         double distanceToObstacleHokuyo(int beamnum, Point obstacle, double obstacleSize);
208         int simulationEnabled;
209
210         QTimer *obstacleSimulationTimer;
211         Point simulatedObstacle;
212
213         /************************************************************
214          * ORTE 
215          ************************************************************/
216         void createOrte();
217
218         struct robottype_orte_data orte;
219 };
220
221 #endif /* ROBOMON_ATLANTIS_H */