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