MapView.h
Go to the documentation of this file.
00001 #pragma once
00002 
00022 #ifndef __MAPVIEW_H
00023 #define __MAPVIEW_H
00024  
00025  
00026  
00027 
00028 #include "GLWindow2.h"
00029 #include <deque>
00030 #include "cvd/thread.h"
00031 #include "TooN/se3.h"
00032 #include "MouseKeyHandler.h"
00033 
00034 
00035 class DroneKalmanFilter;
00036 class PTAMWrapper;
00037 class Predictor;
00038 class EstimationNode;
00039 
00040 class TrailPoint
00041 {
00042 public:
00043         inline TrailPoint(TooN::Vector<3> filter)
00044         {
00045                 pointFilter = filter;
00046                 PTAMValid = false;
00047         }
00048         inline TrailPoint(TooN::Vector<3> filter, TooN::Vector<3> ptam)
00049         {
00050                 pointFilter = filter;
00051                 pointPTAM = ptam;
00052                 PTAMValid = true;
00053         }
00054         TooN::Vector<3> pointPTAM;
00055         TooN::Vector<3> pointFilter;
00056         bool PTAMValid;
00057 };
00058 
00059 class MapView : private CVD::Thread, private MouseKeyHandler
00060 {
00061 private:
00062         // base window
00063         GLWindow2* myGLWindow;
00064         CVD::ImageRef desiredWindowSize;                // size the window scould get changed to if [changeSizeNextRender]
00065         CVD::ImageRef defaultWindowSize;                // size the window gets opened with
00066         bool changeSizeNextRender;
00067 
00068 
00069         // the associated thread's run function.
00070         // calls control() every time a new PTAM info is available or every 20ms.
00071         void run();
00072 
00073         // main routine; uses all available information, 
00074         // in order to calculate and send a new control command to the drone
00075         void control();
00076 
00077         // renders map view
00078         void Render();
00079 
00080         DroneKalmanFilter* filter;
00081         PTAMWrapper* ptamWrapper;
00082         EstimationNode* node;
00083 
00084         bool resetRequested;
00085 
00086         // keep Running
00087         bool keepRunning;
00088 
00089         Predictor* predConvert;
00090 
00091 
00092         // ---------- rendering stuff ---------------------------
00093         char charBuf[1000];
00094         std::string msg;
00095         enum {UI_NONE = 0, UI_DEBUG = 1, UI_PRES = 2} drawUI;
00096         float lineWidthFactor;
00097 
00098         // plot stuff
00099         void plotMapPoints();
00100         void plotGrid();
00101         void plotKeyframes();
00102         void SetupFrustum();
00103         void SetupModelView(TooN::SE3<> se3WorldFromCurrent = TooN::SE3<>());
00104 
00105         // viewing options
00106         TooN::SE3<> mse3ViewerFromWorld;
00107         TooN::Vector<3> mv3MassCenter;
00108         bool resetMapViewFlag;
00109 
00110         void plotCam(TooN::SE3<> droneToGlobal, bool xyCross, float thick, float len, float alpha);
00111         void drawTrail();
00112 
00113         // resets tracking. private as it needs to be called from internal thread.
00114         void ResetInternal();
00115 
00116         // values for rendering.
00117         TooN::Vector<10> lastFramePoseSpeed;
00118         bool inControl;
00119         bool clearTrail;
00120 
00121 
00122         // trail for rendering
00123         std::vector<TrailPoint> trailPoints;
00124 
00125 public:
00126 
00127         MapView(DroneKalmanFilter* f, PTAMWrapper* p, EstimationNode* nde);
00128         ~MapView(void);
00129 
00130         bool handleCommand(std::string s);
00131 
00132         inline void Reset() {resetRequested = true;};
00133 
00134         // Event handling routines.
00135         // get called by the myGLWindow on respective event.
00136         void on_key_down(int key);
00137         //virtual void on_mouse_move(CVD::ImageRef where, int state);
00138         //virtual void on_mouse_down(CVD::ImageRef where, int state, int button);
00139         //virtual void on_event(int event);
00140 
00141 
00142         static pthread_mutex_t trailPointsVec_CS; //pthread_mutex_lock( &cs_mutex );
00143 
00144         // start and stop system and respective thread.
00145         void startSystem();
00146         void stopSystem();
00147 
00148         void resetMapView();
00149 };
00150 #endif /* __MAPVIEW_H */
00151 


uga_tum_ardrone
Author(s):
autogenerated on Sat Jun 8 2019 20:30:11