]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/robomon/RobomonAtlantis.h
7a8c32c0e0282e446d312b968efb10a665d1566c
[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
85         /************************************************************
86          * ORTE
87          ************************************************************/
88         void motionStatusReceived();
89         void actualPositionReceived();
90         void powerVoltageReceived();
91
92 private:
93         /************************************************************
94          * GUI
95          ************************************************************/
96         void createLeftLayout();
97         void createRightLayout();
98
99         void createPlaygroundGroupBox();
100         void createPositionGroupBox();
101         void createMiscGroupBox();
102         void createDebugGroupBox();
103         void createActuatorsGroupBox();
104         void createMotorsGroupBox();
105         void createDIOGroupBox();
106         void createSensorsGroupBox();
107         void createPowerGroupBox();
108         void createPickerGroupBox();
109         void createFSMGroupBox();
110
111         void createRobots();
112         void createActions();
113         void createMap();
114
115         QVBoxLayout *leftLayout;
116         QVBoxLayout *rightLayout;
117
118         QGroupBox *playgroundGroupBox;
119         QGroupBox *positionGroupBox;
120         QGroupBox *miscGroupBox;
121         QGroupBox *debugGroupBox;
122         QGroupBox *actuatorsGroupBox;
123         QGroupBox *powerGroupBox;
124         QGroupBox *fsmGroupBox;
125
126 public:
127         PlaygroundScene *playgroundScene;
128 private:
129         PlaygroundView *playgroundSceneView;
130
131         /* position state */
132         QLineEdit *actPosX;
133         QLineEdit *actPosY;
134         QLineEdit *actPosPhi;
135
136         QLineEdit *estPosX;
137         QLineEdit *estPosY;
138         QLineEdit *estPosPhi;
139
140         /* debug window */
141         QTextEdit *debugWindow;
142         bool debugWindowEnabled;
143
144         /* actuators */
145 /*      QSlider *leftMotorSlider; */
146 /*      QSlider *rightMotorSlider; */
147 /*      QCheckBox *bothMotorsCheckBox; */
148 /*      QPushButton *stopMotorsPushButton; */
149         //QDial *vidle;
150
151         /* power management */
152         QCheckBox *voltage33CheckBox;
153         QCheckBox *voltage50CheckBox;
154         QCheckBox *voltage80CheckBox;
155         QLineEdit *voltage33LineEdit;
156         QLineEdit *voltage50LineEdit;
157         QLineEdit *voltage80LineEdit;
158         QLineEdit *voltageBATLineEdit;
159
160         /* misc */
161         QCheckBox *obstacleSimulationCheckBox;
162         QLabel *fsm_main_state;
163         QLabel *fsm_act_state;
164         QLabel *fsm_motion_state;
165         QCheckBox *startPlug;
166         QCheckBox *colorChoser;
167 public:
168         /* robot */
169         Robot *robotRefPos;
170         Robot *robotEstPosBest;
171         Robot *robotEstPosIndepOdo;
172         Robot *robotEstPosOdo;
173
174         Map *mapImage;
175 private:
176         Trail *trailRefPos;
177         Trail *trailEstPosBest;
178         Trail *trailPosIndepOdo;
179         Trail *trailOdoPos;
180
181         HokuyoScan *hokuyoScan;
182
183         /* keypad */
184         double leftMotorValue;
185         double rightMotorValue;
186
187         /* map */
188         void openSharedMemory();
189         bool sharedMemoryOpened;
190         QTimer *mapTimer;
191
192         /* obstacle simulation */
193         double distanceToWallHokuyo(int beamnum);
194         double distanceToObstacleHokuyo(int beamnum, Point obstacle, double obstacleSize);
195         double distanceToCircularObstacleHokuyo(int beamnum, Point center, double diameter);
196         int simulationEnabled;
197
198         QTimer *obstacleSimulationTimer;
199         Point simulatedObstacle;
200
201         /************************************************************
202          * ORTE
203          ************************************************************/
204         void createOrte();
205
206         struct robottype_orte_data orte;
207 };
208
209 #endif /* ROBOMON_ATLANTIS_H */