00001 00002 #ifndef ROMEOMAINWINDOW_H 00003 #define ROMEOMAINWINDOW_H 00004 00005 // QT Includes 00006 #include <QMainWindow> 00007 #include <QCloseEvent> 00008 #include <QMessageBox> 00009 #include <QProcess> 00010 #include <QString> 00011 #include <QSplashScreen> 00012 #include <QGraphicsEllipseItem> 00013 00014 // Romeo HMI Includes 00015 #include "ui_MainWindow_HMI2.h" 00016 #include "scaledialog.h" 00017 #include "trajectoryDialog.h" 00018 #include "mapscene.h" 00019 00020 // YARP Includes 00021 #include <yarp/os/all.h> 00022 #include <yarp/sig/all.h> 00023 00024 // OpenCV Includes 00025 00026 #undef HAVE_IPL 00027 // #ifndef HAVE_IPL 00028 // #define HAVE_IPL 00029 00030 #include <opencv/cv.h> 00031 #include <opencv/highgui.h> 00032 00033 // URUS Includes 00034 #include "../../dcx/comms.h" 00035 #include "../../ekfloc/comms.h" 00036 #include "../../ekfloc6d/comms.h" 00037 #include "../../common/communications/Comms.h" 00038 #include "../../common/trajectory/Trajectory.h" 00039 #include "../../purpur/comms.h" 00040 00041 // Namespaces 00042 using namespace yarp::sig; 00043 using namespace yarp::sig::draw; 00044 using namespace yarp::sig::file; 00045 00046 00047 class RomeoMainWindow : public QMainWindow, private Ui::MainWindow 00048 { 00049 Q_OBJECT 00050 00051 public: /*$PUBLIC_FUNCTIONS$*/ 00052 00053 RomeoMainWindow(QWidget* parent = 0, Qt::WFlags fl = 0 ); 00054 ~RomeoMainWindow(); 00055 00056 00057 public slots: /*$PUBLIC_SLOTS$*/ 00058 00059 signals: /*$SIGNAL$*/ 00060 00061 void message(QString); // info text message signal 00062 00063 00064 protected: /*$PROTECTED_FUNCTIONS$*/ 00065 00066 void closeEvent(QCloseEvent *event); 00067 00068 00069 protected slots: /*$PROTECTED_SLOTS$*/ 00070 00071 private slots: /*$PRIVATE_SLOTS$*/ 00072 00073 void about(); 00074 void aboutQt(); 00075 void exitApplication(); 00076 void openMap(); 00077 void loadMap(QString mapName); 00078 00079 void read_odometry_values(); 00080 void check_YARP_network(); 00081 void read_system_status(); 00082 00083 void initialtrajectorypoint(); // Signals for Control Trajectory and 00084 void nexttrajectorypoint(); // graphic view. 00085 void changeThetaInit(); 00086 00087 void showMessage(QString); // Show message on status bar 00088 void showTrajectory(QString); // Show trajectory on Map 00089 00090 void changeRobotPosition(QPoint position); 00091 void ungrabRomeo(); 00092 00093 void zooming(int value); 00094 void zoomFit(); 00095 00096 void openTraject(); 00097 void loadTrajectory(QString trajectoryName); 00098 void loadSemanticSpots(QString mapname); 00099 void mapPressEvent(QPointF clickedPoint); 00100 00101 void trashtrajectory(); 00102 00103 void upArrow(); 00104 void downArrow(); 00105 void leftArrow(); 00106 void rightArrow(); 00107 void panicEvent(); 00108 void launchEvent(); 00109 void trajetoryFinalized(); 00110 00111 void graphicview2romeo(double *x_graph,double *y_graph); 00112 void romeo2graphicview(double *x_graph,double *y_graph); 00113 void map2graphicview(double *x,double *y); 00114 void graphicview2map(double *x,double *y); 00115 00116 void launch_LAUNCHER_Process(); 00117 void stop_LAUNCHER_Process(); 00118 void stop_ALL_CONTROL_Process(); 00119 00120 // Sensors Views 00121 00122 void connect_LASER2D_sensor(); 00123 void disconnect_LASER2D_sensor(); 00124 void connect_ELEVATIONMAP_sensor(); 00125 void disconnect_ELEVATIONMAP_sensor(); 00126 void connect_TRANSMAP_sensor(); 00127 void disconnect_TRANSMAP_sensor(); 00128 00129 void IplImage2QImage(IplImage *src,QGraphicsPixmapItem * pixmapElement, QGraphicsScene *sensorScene); 00130 00131 void switchElevationView(); 00132 void switchTransView(); 00133 00134 00135 private: 00136 00137 void createActions(); 00138 void initialValues(); 00139 void createGraphicsView(); 00140 void startYarpCommunications(); 00141 00142 // CONTROL PROCESS 00143 QSplashScreen *splash; 00144 00145 QProcess *LAUNCHER_Process; 00146 QString LAUNCHER_Program; 00147 QString LAUNCHER_Directory; 00148 00149 // Main Graphic View 00150 MapScene scene; 00151 QPixmap map; 00152 00153 int zoomPreviousValue; 00154 00155 ScaleDialog MapScale; 00156 trajectoryDialog SelectTrajectory; 00157 00158 QList <QGraphicsEllipseItem *> spots; 00159 QList <QGraphicsEllipseItem *> semanticSpotsList; 00160 QList <QGraphicsTextItem *> semanticSpotsText; 00161 QList <QGraphicsTextItem *> semanticInfo; 00162 00163 QList <QGraphicsPixmapItem *> maps; 00164 QList <QGraphicsLineItem *> lines; 00165 QList <QGraphicsLineItem *> absolutLines; 00166 QList <QGraphicsTextItem *> waypoints; 00167 QList <QGraphicsTextItem *> absolutWaypoints; 00168 QList <QString> trajectory_lines; 00169 00170 QBrush romeo_brush; 00171 QPen romeo_pen; 00172 00173 QGraphicsPixmapItem *romeo; 00174 QGraphicsPixmapItem romeo_local; 00175 // Boolean variables to indicate the actual mode of the Romeo GUI 00176 // Both variables at TRUE not allowed. 00177 00178 bool trajectory_edit_mode; 00179 bool trajectory_executing_mode; 00180 bool setting_initial_point; 00181 bool theta_edit_mode; 00182 00183 bool trajectoriesBYinterface; 00184 00185 // Boolean variable indicating if Yarp Network is UP 00186 bool yarpRunning; 00187 00188 // Trajectory points to use the GUI 00189 00190 QPointF last_trajectory_point; 00191 QPointF initial_trajectory_point; 00192 QPointF global_init_point; 00193 int trajectory_points_number; 00194 00195 // File and textstream for Test Trajectory 00196 00197 QFile file; 00198 QTextStream test_trajectory_line; 00199 00200 double map_width; // in Pixels 00201 double map_height; // in Pixels 00202 00203 double map_x_axis_length; // in meters 00204 double map_y_axis_length; // in meters 00205 00206 double map_X_scale; // Pixels/meter 00207 double map_Y_scale; // Pixels/meter 00208 00209 double scene_x_axis_length; 00210 double scene_y_axis_length; 00211 00212 double x_ini_global; // Romeo Graphic View Initial Position 00213 double y_ini_global; 00214 00215 double x_ini_local; // Romeo Graphic View Initial Position 00216 double y_ini_local; 00217 00218 double theta; 00219 double previous_theta; 00220 double theta_offset; 00221 00222 double locale_romeo_x_ref; 00223 double locale_romeo_y_ref; 00224 00225 double romeo_speed_reference; 00226 00227 double m_stats[4]; // Values from /proc/stat 00228 double m_stats_new[4]; // For CPU Usage evaluation 00229 00230 double tx_net_stats; // Values from /proc/dev/net 00231 double tx_net_stats_new; 00232 double rx_net_stats; // Values from /proc/dev/net 00233 double rx_net_stats_new; 00234 00235 double x_ref; // From EKFLOC 00236 double y_ref; // From EKFLOC 00237 double orient_ref; // From EKFLOC 00238 double previous_orient_ref; 00239 double speed_ref; // From DCX 00240 double curv_ref; // From EKFLOC 00241 double yaw_ref; 00242 double pitch_ref; 00243 double roll_ref; 00244 00245 // YARP Devices and Pointers for reading from the ports 00246 00247 CDcxData * pyarpDcx; // Reading fron DCX 00248 // CLoc6DData * pyarpEkf; // Reading from EkFloc 00249 CLocData * pyarpEkf; // Reading from EkFloc 00250 00251 // yarp::os::BufferedPort<CLoc6DData> locInput; 00252 yarp::os::BufferedPort<CLocData> locInput; 00253 yarp::os::BufferedPort<CDcxData> odomInput; 00254 00255 yarp::os::BufferedPort<CPurpurState> purpurStatePort; 00256 CPurpurState * pyarpPurpur; 00257 int purpurState; 00258 int previousPurpurState; 00259 00260 yarp::os::BufferedPort < yarp::sig::ImageOf<PixelBgr> > laser2DImageInput; 00261 yarp::sig::ImageOf<PixelBgr> * laser2DImage; 00262 IplImage *cvLaser2DImage; 00263 QGraphicsScene laser2Dscene; 00264 QGraphicsTextItem *laser2DInfoText; 00265 QGraphicsPixmapItem *laser2DPixmap; 00266 QGraphicsPixmapItem laser2DPixmap_local; 00267 QGraphicsEllipseItem *laserRange; 00268 QGraphicsPixmapItem *romeoImage; 00269 bool readLaser2DImage; 00270 double laser2D_x_axis_length; 00271 double laser2D_y_axis_length; 00272 00273 yarp::os::BufferedPort < yarp::sig::ImageOf<PixelBgr> > elevationMapImageInput; 00274 yarp::sig::ImageOf<PixelBgr> * elevationMapImage; 00275 IplImage *cvelevationMapImage; 00276 QGraphicsScene elevationMapscene; 00277 QGraphicsTextItem *elevationMapInfoText; 00278 QGraphicsPixmapItem *elevationMapPixmap; 00279 QGraphicsPixmapItem elevationMapPixmap_local; 00280 bool readElevationMapImage; 00281 bool elevationMapMainView; 00282 double elevationMap_x_axis_length; 00283 double elevationMap_y_axis_length; 00284 00285 yarp::os::BufferedPort < yarp::sig::ImageOf<PixelBgr> > transMapImageInput; 00286 yarp::sig::ImageOf<PixelBgr> * transMapImage; 00287 IplImage *cvTransMapImage; 00288 QGraphicsScene transMapscene; 00289 QGraphicsTextItem *transMapInfoText; 00290 QGraphicsPixmapItem *transMapPixmap; 00291 QGraphicsPixmapItem transMapPixmap_local; 00292 bool readTransMapImage; 00293 bool transMapMainView; 00294 double transMap_x_axis_length; 00295 double transMap_y_axis_length; 00296 QFont infoFont; 00297 00298 }; 00299 00300 #endif 00301 00302