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