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