]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/robomon/RobomonAtlantis.h
Merge branch 'master' of vokacmic@rtime.felk.cvut.cz:/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 "trail.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 powerVoltageReceivedSignal();
58         
59 public slots:
60         void showMap(bool show);
61         void showTrails(bool show);
62         void resetTrails();
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 paintMap();
74         void setSimulation(int state);
75         void setObstacleSimulation(int state);
76         void simulateObstaclesHokuyo();
77         void changeObstacle(QPointF position);
78         void sendStart(int plug);
79
80         /************************************************************
81          * ORTE 
82          ************************************************************/
83         void motionStatusReceived();
84         void actualPositionReceived();
85         void powerVoltageReceived();
86
87 private:
88         /************************************************************
89          * GUI
90          ************************************************************/
91         void createLeftLayout();
92         void createRightLayout();
93
94         void createPlaygroundGroupBox();
95         void createPositionGroupBox();
96         void createMiscGroupBox();
97         void createDebugGroupBox();
98         void createActuatorsGroupBox();
99         void createMotorsGroupBox();
100         void createDIOGroupBox();
101         void createSensorsGroupBox();
102         void createPowerGroupBox();
103         void createPickerGroupBox();
104         void createFSMGroupBox();
105
106         void createRobots();
107         void createActions();
108
109         QVBoxLayout *leftLayout;
110         QVBoxLayout *rightLayout;
111
112         QGroupBox *playgroundGroupBox;
113         QGroupBox *positionGroupBox;
114         QGroupBox *miscGroupBox;
115         QGroupBox *debugGroupBox;
116         QGroupBox *actuatorsGroupBox;
117         QGroupBox *enginesGroupBox;
118         QGroupBox *powerGroupBox;
119         QGroupBox *fsmGroupBox;
120
121         PlaygroundScene *playgroundScene;
122         QGraphicsView *playgroundSceneView;
123
124         /* position state */
125         QLineEdit *actPosX;
126         QLineEdit *actPosY;
127         QLineEdit *actPosPhi;
128
129         QLineEdit *estPosX;
130         QLineEdit *estPosY;
131         QLineEdit *estPosPhi;
132
133         /* debug window */
134         QTextEdit *debugWindow;
135         bool debugWindowEnabled;
136
137         /* actuators */
138         QSlider *leftMotorSlider;
139         QSlider *rightMotorSlider;
140         QCheckBox *bothMotorsCheckBox;
141         QPushButton *stopMotorsPushButton;
142
143         /* power management */
144         QCheckBox *voltage33CheckBox;
145         QCheckBox *voltage50CheckBox;
146         QCheckBox *voltage80CheckBox;
147         QLineEdit *voltage33LineEdit;
148         QLineEdit *voltage50LineEdit;
149         QLineEdit *voltage80LineEdit;
150         QLineEdit *voltageBATLineEdit;
151
152         /* misc */
153         QCheckBox *obstacleSimulationCheckBox;
154         QLabel *fsm_main_state;
155         QLabel *fsm_act_state;
156         QLabel *fsm_motion_state;
157         QCheckBox *startPlug;
158         QCheckBox *puckInside;
159
160         /* robot */
161         Robot *robotActPos;
162         Robot *robotEstPosIndepOdo;
163         Robot *robotEstPosOdo;
164         
165         Trail *trailRefPos;
166         Trail *trailPosIndepOdo;
167         Trail *trailOdoPos;
168
169         /* keypad */
170         double leftMotorValue;
171         double rightMotorValue;
172
173         /* map */
174         void openSharedMemory();
175         bool sharedMemoryOpened;
176         QTimer *mapTimer;
177         
178         /* obstacle simulation */
179         double distanceToWallHokuyo(int beamnum);
180         double distanceToObstacleHokuyo(int beamnum, Point obstacle, double obstacleSize);
181         int simulationEnabled;
182
183         QTimer *obstacleSimulationTimer;
184         Point simulatedObstacle;
185
186         /************************************************************
187          * ORTE 
188          ************************************************************/
189         void createOrte();
190
191         struct robottype_orte_data orte;
192 };
193
194 #endif /* ROBOMON_ATLANTIS_H */