00001 /************************************************************************************************/ 00002 /*! \file LKFexample.cpp 00003 * \brief An example implementation of a linear Kalman filter using the KalmanFilter class. 00004 * \author $Author: simpliciter $ 00005 * \version $Revision: 1.1 $ 00006 * \date $Date: 2003/07/04 16:19:43 $ 00007 ************************************************************************************************/ 00008 /*! 00009 * 00010 ************************************************************************************************/ 00011 00012 #include "KalmanFilter.h" 00013 #include "SequentialFilterHistory.h" 00014 #include <iostream> 00015 using namespace std; 00016 using namespace O_SESSAME; 00017 00018 int main() { 00019 00020 Vector x(2); 00021 Vector z(2); 00022 Vector zeroVector(2); 00023 00024 Matrix P(2,2); 00025 P(1,1) = 0.1; P(1,2) = 0.0; 00026 P(2,1) = 0.0; P(2,2) = 0.1; 00027 00028 Matrix K(2,2); 00029 K(1,1) = 0.1; K(1,2) = 0.0; 00030 K(2,1) = 0.0; K(2,2) = 0.1; 00031 00032 KalmanFilter kf(P,K); 00033 00034 double deltaT = 1.0; 00035 Vector states = x; 00036 Vector controls = zeroVector; 00037 Vector parameters = zeroVector; 00038 Vector measurements = z; 00039 00040 kf.SetTimeOfEstimate(0.0); 00041 kf.SetTimeOfMeasurements(deltaT); 00042 kf.SetStateVector(states); 00043 kf.SetControlVector(controls); 00044 kf.SetMeasurementVector(measurements); 00045 kf.SetParameterVector(parameters); 00046 00047 kf.EstimateState(); 00048 00049 SequentialFilterHistory mySFHist; 00050 Matrix myHistMatrix; 00051 mySFHist.AppendHistory(1.7, states, controls, measurements, parameters); 00052 myHistMatrix = mySFHist.GetHistory(); 00053 00054 cout << myHistMatrix << endl; 00055 00056 00057 00058 00059 cout << "I made it all the way through!" << endl; 00060 00061 return 1; 00062 00063 }; 00064 00065 // Do not change the comments below - they will be added automatically by CVS 00066 /***************************************************************************** 00067 * $Log: LKFexample.cpp,v $ 00068 * Revision 1.1 2003/07/04 16:19:43 simpliciter 00069 * Moved. 00070 * 00071 * Revision 1.6 2003/07/01 20:28:19 mavandyk 00072 * Changed filter to use absolute time stamps. 00073 * 00074 * Revision 1.5 2003/06/24 15:47:23 simpliciter 00075 * Removed references to structs... 00076 * 00077 * Revision 1.4 2003/06/20 22:01:39 mavandyk 00078 * Changes made to reflect the altering of the kalmanFitlerData struct type and the KalmanFilter class, and initialization of the data used in the structs and classes was added. 00079 * 00080 * Revision 1.3 2003/06/18 17:42:20 mavandyk 00081 * Changed the appropriate function input types to reflect changes in KalmanFilter.h. 00082 * 00083 * Revision 1.2 2003/06/12 22:59:26 mavandyk 00084 * Added header and footer comments. 00085 * 00086 * Revision 1.1 2003/06/12 16:29:41 mavandyk 00087 * This file replaces IterativeFilter.h, and only differs by replacing iterative with sequential. 00088 * 00089 * Revision 1.1 2003/06/11 15:45:08 simpliciter 00090 * Initial submission, pulled out of KalmanFilter.h. 00091 * May require (desire) additional pure virtual functions. 00092 * 00093 * 00094 ******************************************************************************/