Jafar
|
00001 #ifndef FUSION_FUSION_HPP 00002 #define FUSION_FUSION_HPP 00003 00004 #include "kernel/jafarException.hpp" 00005 #include "jmath/jblas.hpp" 00006 #include "filter/kalmanFilter.hpp" 00007 #include "filter/predictModel.hpp" 00008 #include "filter/observeModel.hpp" 00009 00010 #include "datareader/DataReader.hpp" 00011 00012 #include "boost/numeric/ublas/io.hpp" 00013 #include "boost/numeric/ublas/lu.hpp" //to use project function 00014 #include "boost/date_time/posix_time/posix_time_types.hpp" 00015 #include <iostream> 00016 #include <iomanip> 00017 #include <fstream> 00018 #include <math.h> 00019 00020 namespace jafar 00021 { 00022 namespace fusion 00023 { 00024 class PredictModelFusion : public filter::JacobianCommandPredictModel 00025 { 00026 public: 00027 PredictModelFusion(std::size_t sizeState, std::size_t sizeCommand); 00028 virtual ~PredictModelFusion(); 00029 virtual void predict(jblas::vec& x, jblas::vec const& u_); 00030 void computeJacobianState(jblas::vec _x, 00031 jblas::vec u, 00032 jblas::mat C, 00033 jblas::mat E); 00034 virtual void setTimeStep(boost::posix_time::time_duration const& timeStep) 00035 { 00036 m_timeStep = timeStep; 00037 } 00038 00039 private: 00040 //the covariance matrix of constrol noise 00041 jblas::mat DCMmatrix(jblas::vec& _x); 00042 jblas::mat RotationRateMatrix(jblas::vec& _x); 00043 jblas::sym_mat W; 00044 00045 };//the predict model class inheritated from the class JacobianPredictModel 00046 00047 class ObservationModelFusion : public filter::JacobianObserveModel 00048 { 00049 public: 00050 ObservationModelFusion(std::size_t sizeObs_, std::size_t sizeState_, int sensor); 00051 virtual ~ObservationModelFusion(); 00052 jblas::vec const& predictObservation(jblas::vec const& x_); 00053 virtual void predictObservationJac(const jblas::vec& x_); 00054 void setUncorrelatedR(jblas::vec R_); 00055 void setSampleTime(double time){m_samplingTime = time;}; 00056 double getSampleTime(){return m_samplingTime;}; 00057 void setObsNum(std::size_t num){m_obsNum = num;}; 00058 jblas::vec eulerPrev; //store the previous euler representation 00059 private: 00060 int m_sensor; //set sensor type 00061 std::size_t m_obsNum; //set observation flag. 2: constraints 6: vision 00062 double m_samplingTime; 00063 00064 }; //the observation model class inheritated from the class JacobianObserveModel 00065 00066 /* 00067 * EKF fusion class 00068 */ 00069 class ExtendedKalmanFilterFusion : public filter::ExtendedKalmanFilter 00070 { 00071 public: 00072 ExtendedKalmanFilterFusion(std::size_t n_); 00073 00074 virtual ~ExtendedKalmanFilterFusion(); 00075 00076 void predict(PredictModelFusion& m, 00077 jblas::vec const& u) ; 00078 00079 void update(ObservationModelFusion& m_, const jblas::vec& z_); 00080 00081 void writeHeader(kernel::DataLogger& log); 00082 void writeData(kernel::DataLogger& log); 00083 void writeVarData(kernel::DataLogger& log); 00084 double NormalizeAngle(double a); 00085 jblas::vec m_eulerPrev; //store the euler representation at previous time 00086 void WriteVecBody(kernel::DataLogger& log); 00087 00088 };//the main ekf fusion class 00089 00090 //the file loaded class for fusion class 00091 class DataLoad 00092 { 00093 public: 00094 DataLoad(datareader::DataReader *dr); 00095 virtual ~DataLoad(); 00096 jblas::vec readImuLine(); 00097 double readVisionDate(int index); 00098 double getStartImuTime(){return m_startTime;}; 00099 private: 00100 int m_ColumnNum; 00101 std::ifstream m_imuLog; 00102 std::string m_path; 00103 double m_startTime; //initial second of IMU 00104 }; 00105 00106 } 00107 } 00108 #endif 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132
Generated on Wed Oct 15 2014 00:37:19 for Jafar by doxygen 1.7.6.1 |