]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/robomon/RobomonAtlantis.h
Revert "Delete old meta-ti"
[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 #include <QDialog>
17
18 #include <trgen.h>
19 #include "PlaygroundScene.h"
20 #include "playgroundview.h"
21 #include "Robot.h"
22 #include "Map.h"
23 #include <roboorte_robottype.h>
24 #include "trail.h"
25 #include "hokuyoscan.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 class QImage;
42
43 class RobomonAtlantis : public QWidget
44 {
45         Q_OBJECT
46
47 public:
48         RobomonAtlantis(QWidget *parent = 0);
49
50 protected:
51         bool event(QEvent *event);
52         void keyPressEvent(QKeyEvent *event);
53         void keyReleaseEvent(QKeyEvent *event);
54         void closeEvent(QCloseEvent *event);
55
56 signals:
57         void motionStatusReceivedSignal();
58         void actualPositionReceivedSignal();
59         void powerVoltageReceivedSignal();
60
61 public slots:
62         void showMap(bool show);
63         void useOpenGL(bool use);
64         void showTrails(bool show);
65         void showShapeDetect(bool show);
66         void resetTrails();
67 private slots:
68         /************************************************************
69          * GUI actions
70          ************************************************************/
71         void setVoltage33(int state);
72         void setVoltage50(int state);
73         void setVoltage80(int state);
74 /*      void setLeftMotor(int value); */
75 /*      void setRightMotor(int value); */
76 /*      void stopMotors(); */
77         void paintMap();
78         void setSimulation(int state);
79         void setObstacleSimulation(int state);
80         void simulateObstaclesHokuyo();
81         void changeObstacle(QPointF position);
82         void sendStart(int plug);
83         void setTeamColor(int plug);
84         void changeStrategy_1();
85         void changeStrategy_0();
86
87         /************************************************************
88          * ORTE
89          ************************************************************/
90         void motionStatusReceived();
91         void actualPositionReceived();
92         void powerVoltageReceived();
93
94 private:
95         /************************************************************
96          * GUI
97          ************************************************************/
98         void createLeftLayout();
99         void createRightLayout();
100
101         void createPlaygroundGroupBox();
102         void createPositionGroupBox();
103         void createMiscGroupBox();
104         void createDebugGroupBox();
105         void createActuatorsGroupBox();
106         void createMotorsGroupBox();
107         void createDIOGroupBox();
108         void createSensorsGroupBox();
109         void createPowerGroupBox();
110         void createPickerGroupBox();
111         void createFSMGroupBox();
112
113         void createRobots();
114         void createActions();
115         void createMap();
116
117         QVBoxLayout *leftLayout;
118         QVBoxLayout *rightLayout;
119
120         QGroupBox *playgroundGroupBox;
121         QGroupBox *positionGroupBox;
122         QGroupBox *miscGroupBox;
123         QGroupBox *debugGroupBox;
124         QGroupBox *actuatorsGroupBox;
125         QGroupBox *powerGroupBox;
126         QGroupBox *fsmGroupBox;
127
128 public:
129         PlaygroundScene *playgroundScene;
130 private:
131         PlaygroundView *playgroundSceneView;
132
133         /* position state */
134         QLineEdit *actPosX;
135         QLineEdit *actPosY;
136         QLineEdit *actPosPhi;
137
138         QLineEdit *estPosX;
139         QLineEdit *estPosY;
140         QLineEdit *estPosPhi;
141
142         /* debug window */
143         QTextEdit *debugWindow;
144         bool debugWindowEnabled;
145
146         /* actuators */
147 /*      QSlider *leftMotorSlider; */
148 /*      QSlider *rightMotorSlider; */
149 /*      QCheckBox *bothMotorsCheckBox; */
150 /*      QPushButton *stopMotorsPushButton; */
151         //QDial *vidle;
152
153         /* power management */
154         QCheckBox *voltage33CheckBox;
155         QCheckBox *voltage50CheckBox;
156         QCheckBox *voltage80CheckBox;
157         QLineEdit *voltage33LineEdit;
158         QLineEdit *voltage50LineEdit;
159         QLineEdit *voltage80LineEdit;
160         QLineEdit *voltageBATLineEdit;
161
162         /* misc */
163         QCheckBox *obstacleSimulationCheckBox;
164         QLabel *fsm_main_state;
165         QLabel *fsm_act_state;
166         QLabel *fsm_motion_state;
167         QCheckBox *startPlug;
168         QCheckBox *colorChoser;
169         QPushButton *strategyButton;
170 public:
171         /* robot */
172         Robot *robotRefPos;
173         Robot *robotEstPosBest;
174         Robot *robotEstPosIndepOdo;
175         Robot *robotEstPosOdo;
176
177         Map *mapImage;
178 private:
179         Trail *trailRefPos;
180         Trail *trailEstPosBest;
181         Trail *trailPosIndepOdo;
182         Trail *trailOdoPos;
183
184         HokuyoScan *hokuyoScan;
185
186         /* keypad */
187         double leftMotorValue;
188         double rightMotorValue;
189
190         /* map */
191         void openSharedMemory();
192         bool sharedMemoryOpened;
193         QTimer *mapTimer;
194
195         /* obstacle simulation */
196         double distanceToWallHokuyo(int beamnum);
197         double distanceToObstacleHokuyo(int beamnum, Point obstacle, double obstacleSize);
198         double distanceToCircularObstacleHokuyo(int beamnum, Point center, double diameter);
199         int simulationEnabled;
200
201         QTimer *obstacleSimulationTimer;
202         Point simulatedObstacle;
203
204         /************************************************************
205          * ORTE
206          ************************************************************/
207         void createOrte();
208
209         struct robottype_orte_data orte;
210 };
211
212 #endif /* ROBOMON_ATLANTIS_H */