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