2 * RobomonExplorer.h 07/10/31
4 * Robot's visualization and control GUI for robot of the
5 * Eurobot 2008 competition (Mission to Mars).
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
13 #ifndef ROBOMON_EXPLORER_H
14 #define ROBOMON_EXPLORER_H
16 #define SHARP_LONG_CNT 4
17 #define SHARP_SHORT_CNT 2
19 #define SIM_OBST_SIZE_M 0.5
25 #include "PlaygroundScene.h"
27 #include <roboorte_generic.h>
28 #include <roboorte_eb2008.h>
48 #define TOP_LEFT QPointF(10,0)
52 class RobomonExplorer : public QWidget
57 RobomonExplorer(QWidget *parent = 0);
60 bool event(QEvent *event);
61 void keyPressEvent(QKeyEvent *event);
62 void keyReleaseEvent(QKeyEvent *event);
63 void closeEvent(QCloseEvent *event);
66 void motionStatusReceivedSignal();
67 void actualPositionReceivedSignal();
68 void estimatedPositionReceivedSignal();
69 void sharpsReceivedSignal();
70 void sharpLongsReceivedSignal(); //FIXME rm
71 void sharpShortsReceivedSignal(); //FIXME rm
72 void diReceivedSignal();
73 void accelerometerReceivedSignal();
74 void accumulatorReceivedSignal();
75 void powerVoltageReceivedSignal();
78 /************************************************************
80 ************************************************************/
81 void setVoltage33(int state);
82 void setVoltage50(int state);
83 void setVoltage80(int state);
84 void setLeftMotor(int value);
85 void setRightMotor(int value);
86 void setDrives(int value);
87 void setLeftBrushDriveCB(int value);
88 void setRightBrushDriveCB(int value);
89 void setBagrDriveCB(int value);
91 void moveServos(int value);
92 void moveFrontDoor(int state);
93 void moveTopDoor(int state);
94 void moveBackDoor(int state);
95 void moveLeftBrush(int state);
96 void moveRightBrush(int state);
97 void setDO(int state);
98 void setLaser(int state);
100 void showPlayground();
102 void setSharpValues(int value);
103 void setSimulation(int state);
104 void setObstacleSimulation(int state);
105 void simulateObstacles();
106 void changeObstacle(QPointF position);
108 /************************************************************
110 ************************************************************/
111 void motionStatusReceived();
112 void actualPositionReceived();
113 void estimatedPositionReceived();
114 void sharpsReceived();
116 void accelerometerReceived();
117 void accumulatorReceived();
118 void powerVoltageReceived();
121 /************************************************************
123 ************************************************************/
124 void createLeftLayout();
125 void createRightLayout();
127 void createPlaygroundGroupBox();
128 void createPositionGroupBox();
129 void createMiscGroupBox();
130 void createDebugGroupBox();
131 void createActuatorsGroupBox();
132 void createMotorsGroupBox();
133 void createServosGroupBox();
134 void createDrivesGroupBox();
135 void createDIOGroupBox();
136 void createSensorsGroupBox();
137 void createPowerGroupBox();
139 void createSharpSensorsLayout();
142 void createActions();
144 QVBoxLayout *leftLayout;
145 QVBoxLayout *rightLayout;
146 QVBoxLayout *sharpSensorsLayout;
148 QGroupBox *playgroundGroupBox;
149 QGroupBox *positionGroupBox;
150 QGroupBox *miscGroupBox;
151 QGroupBox *debugGroupBox;
152 QGroupBox *actuatorsGroupBox;
153 QGroupBox *enginesGroupBox;
154 QGroupBox *servosGroupBox;
155 QGroupBox *drivesGroupBox;
156 QGroupBox *dioGroupBox;
157 QGroupBox *sensorsGroupBox;
158 QGroupBox *powerGroupBox;
160 PlaygroundScene *playgroundScene;
161 QGraphicsView *playgroundSceneView;
166 QLineEdit *actPosPhi;
170 QLineEdit *estPosPhi;
173 QTextEdit *debugWindow;
174 bool debugWindowEnabled;
177 QSlider *leftMotorSlider;
178 QSlider *rightMotorSlider;
179 QCheckBox *bothMotorsCheckBox;
180 QPushButton *stopMotorsPushButton;
182 QCheckBox *bottomDoorCheckBox;
183 QCheckBox *backDoorCheckBox;
184 QCheckBox *topDoorCheckBox;
185 QCheckBox *leftBrushCheckBox;
186 QCheckBox *rightBrushCheckBox;
188 QDial *leftBrushDial;
189 QDial *rightBrushDial;
193 QCheckBox *leftBrushDriveCheckBox;
194 QCheckBox *rightBrushDriveCheckBox;
195 QCheckBox *bagrDriveCheckBox;
197 /* power management */
198 QCheckBox *voltage33CheckBox;
199 QCheckBox *voltage50CheckBox;
200 QCheckBox *voltage80CheckBox;
201 QLineEdit *voltage33LineEdit;
202 QLineEdit *voltage50LineEdit;
203 QLineEdit *voltage80LineEdit;
204 QLineEdit *voltageBATLineEdit;
207 QLabel *sharpLongsLabel[SHARP_LONG_CNT];
208 QLabel *sharpShortsLabel[SHARP_SHORT_CNT];
209 QProgressBar *sharpLongsProgressBar[SHARP_LONG_CNT];
210 QProgressBar *sharpShortsProgressBar[SHARP_SHORT_CNT];
211 QCheckBox *sensorsSimulationCheckBox;
212 QSlider *sharpLongsSlider[SHARP_LONG_CNT];
213 QSlider *sharpShortsSlider[SHARP_SHORT_CNT];
215 QCheckBox *diCheckBox[8];
216 QCheckBox *doCheckBox[8];
219 QCheckBox *sensorSimulationCheckBox;
220 QCheckBox *obstacleSimulationCheckBox;
221 QPushButton *showMapPushButton;
222 QCheckBox *laserEngineCheckBox;
229 double leftMotorValue;
230 double rightMotorValue;
233 void openSharedMemory();
234 bool sharedMemoryOpened;
238 /* obstacle simulation */
239 double distanceToWall(int sharpnum);
240 double distanceToObstacle(int sharpnum, Point obstacle, double obstacleSize);
241 int simulationEnabled;
243 QTimer *obstacleSimulationTimer;
244 Point simulatedObstacle;
246 /************************************************************
248 ************************************************************/
251 struct generic_orte_data orte_generic;
252 struct eb2008_orte_data orte_eb2008;
255 #endif /* ROBOMON_EXPLORER_H */