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