00001 ////////////////////////////////////////////////////////////////////////////////////////////////// 00002 /*! \file IteratedExtendedKalmanFilterHistory.cpp 00003 * \brief Provides functionality beyond ExtendedKalmanFilterHistory to store the number of iterations at each time-step. 00004 * \author $Author: rsharo $ 00005 * \version $Revision: 1.3 $ 00006 * \date $Date: 2003/11/01 21:00:14 $ 00007 *////////////////////////////////////////////////////////////////////////////////////////////////// 00008 /* 00009 */ 00010 ////////////////////////////////////////////////////////////////////////////////////////////////// 00011 00012 #include "IteratedExtendedKalmanFilterHistory.h" 00013 00014 /*! \brief Only one constructor. (No empty constructor.) 00015 * Builds an empty history for the filter instance passed in as a pointer. */ 00016 IteratedExtendedKalmanFilterHistory::IteratedExtendedKalmanFilterHistory(IteratedExtendedKalmanFilter* _ptr_filter) 00017 { 00018 // calls the initialization sequence in SequentialFilterHistory 00019 InitializeSequentialFilterHistory(_ptr_filter); 00020 00021 // new Kalman Filter data to be stored: the covariance and Kalman gain matrices. 00022 m_kfCovarianceHistory.reserve(HISTORY_RESERVE_SIZE); 00023 m_kfKalmanGainHistory.reserve(HISTORY_RESERVE_SIZE); 00024 00025 // new IEKF data to be stored: the number of iterations for each measurement update. 00026 m_iekfIterationHistory.reserve(HISTORY_RESERVE_SIZE); 00027 00028 // not doing interpolations at this time 00029 //m_kalmanFilterInterpolations.reserve(HISTORY_RESERVE_SIZE); 00030 } 00031 00032 00033 00034 /*! \brief Add the filters's data, which occured at a time in seconds, to the history. 00035 * 00036 * Appends the state at t=_appendTime. if the new state 00037 * occured at a time that is earlier than any of the stored values 00038 * then the time history will be erased from the overlap point 00039 * and the new state will be appended. 00040 * @param _appendTime time (in seconds) to be added, t. 00041 * 00042 */ 00043 void IteratedExtendedKalmanFilterHistory::AppendHistory(const double& _appendTime) 00044 { 00045 AppendHistory(ssfTime(_appendTime)); 00046 } 00047 00048 00049 00050 /*! \brief Add the filters's data, which occured at a time in ssfTime form, to the history. 00051 * 00052 * Appends the state at t=_appendTime. if the new state 00053 * occured at a time that is earlier than any of the stored values 00054 * then the time history will be erased from the overlap point 00055 * and the new state will be appended. 00056 * @param _appendTime the ssfTime object specifying when the state occured, t. 00057 * 00058 */ 00059 void IteratedExtendedKalmanFilterHistory::AppendHistory(const ssfTime& _appendTime) 00060 { 00061 // This guy logs the time, states, controls, measurements, parameters, P, and K. 00062 ExtendedKalmanFilterHistory::AppendHistory(_appendTime); 00063 00064 // And now the number of iterations. 00065 m_iekfIterationHistory.push_back( m_ptr_filter->GetNumIterations() ); 00066 00067 return; 00068 } 00069 00070 00071 00072 00073 /*! \brief Returns a matrix of the filter's iteration history. 00074 * @return This function returns a Vector of iteration counts. 00075 */ 00076 Vector IteratedExtendedKalmanFilterHistory::GetIterationHistory() 00077 { 00078 Vector returnVector; 00079 Vector rightSize(m_TimeHistory.size()); 00080 00081 returnVector.initialize(rightSize); 00082 00083 for(unsigned int ii = 1; ii < m_TimeHistory.size(); ii++ ) 00084 { 00085 returnVector(MatrixIndexBase + ii) = m_iekfIterationHistory[ii]; 00086 } 00087 00088 return returnVector; 00089 } 00090 00091 00092 00093 00094 00095 00096 00097 // Do not change the comments below - they will be added automatically by CVS 00098 /***************************************************************************** 00099 * $Log: IteratedExtendedKalmanFilterHistory.cpp,v $ 00100 * Revision 1.3 2003/11/01 21:00:14 rsharo 00101 * changed "Time.h" includes to "utils/Time.h" includes. Also eliminated excess compile warnings. 00102 * 00103 * Revision 1.2 2003/07/12 19:01:23 simpliciter 00104 * Fixed runtime error. 00105 * 00106 * Revision 1.1 2003/07/12 17:55:51 simpliciter 00107 * Initial submission. 00108 * 00109 * 00110 * 00111 ******************************************************************************/