00001 #pragma once 00002 00022 #ifndef __PREDICTOR_H 00023 #define __PREDICTOR_H 00024 00025 00026 00027 00028 #include "TooN/TooN.h" 00029 #include "TooN/so3.h" 00030 #include "TooN/se3.h" 00031 #include <string> 00032 #include <ardrone_autonomy/Navdata.h> 00033 00034 00035 // handles the drone's coordinate frames. 00036 // drone: coordinate system of drone. at zero equals global CS 00037 // positive z: "up" 00038 // positive x: "right" 00039 // positive y: "front" 00040 00041 // front: axis directions as in drone. 00042 // center at (0,0.2,0.025)_drone 00043 // positive z: "front" 00044 // positive x: "right" 00045 // positive y: "down" 00046 00047 // bottom: 00048 // positive z: "down" 00049 // positive x: "right" 00050 // positive y: "back" 00051 // center at (0,0,0)_drone 00052 00053 // scale is meters. 00054 class Predictor 00055 { 00056 private: 00057 void calcGtDRodTransFromSE3(); 00058 void calcDtGRodTransFromSE3(); 00059 void calcRPYXYZFromRodDisp(); 00060 void calcCombinedTransformations(); 00061 00062 public: 00063 00064 // --------------------- static transformation matrices ------------------------ 00065 // matrix from bottom cam CO to drone CO 00066 static const TooN::SE3<double> bottomToDrone; 00067 static const TooN::SE3<double> droneToBottom; 00068 00069 // matrix from front cam CO to drone CO 00070 static const TooN::SE3<double> frontToDrone; 00071 static const TooN::SE3<double> droneToFront; 00072 00073 // matrix from front cam CO to drone CO, without translation (!) 00074 static const TooN::SE3<double> frontToDroneNT; 00075 static const TooN::SE3<double> droneToFrontNT; 00076 00077 // --------------------- current drone state in various represenatations ----------------------- 00078 // current quadcopter position saved in three ways: 00079 // as SE3 transformation (matrix+displacement) 00080 TooN::SE3<double> globaltoDrone; //translation is globalToDroneDisp; rotation is matrix of globalToDroneRod 00081 TooN::SE3<double> droneToGlobal; //translation is droneToGlobalDisp=(x,y,z); rotation is matrix of droneToGlobalRod 00082 00083 TooN::SE3<double> globalToFront; 00084 TooN::SE3<double> frontToGlobal; 00085 TooN::SE3<double> globalToBottom; 00086 TooN::SE3<double> bottmoToGlobal; 00087 00088 00089 // xyz-position is center of drone CS in global coordinates. 00090 // rpy-rotation is rpy of drone. 00091 double roll; 00092 double pitch; 00093 double yaw; 00094 double x; 00095 double y; 00096 double z; 00097 bool zCorrupted; 00098 double lastAddedDronetime; 00099 double zCorruptedJump; 00100 00101 00102 00103 // ------------------------- set internal pose from some representation.----------------------------------------- 00104 // all representations are automatically adjusted. 00105 void setPosRPY(double newX, double newY, double newZ, double newRoll, double newPitch, double newYaw); 00106 void setPosSE3_globalToDrone(TooN::SE3<double> newGlobaltoDrone); 00107 void setPosSE3_droneToGlobal(TooN::SE3<double> newDroneToGlobal); 00108 00109 // -------------------------- prediction ----------------------------------------------------------------------- 00110 00111 void predictOneStep(ardrone_autonomy::Navdata* nfo); 00112 void resetPos(); 00113 00114 Predictor(std::string basePath=""); 00115 ~Predictor(void); 00116 }; 00117 #endif /* __PREDICTOR_H */ 00118