Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

SequentialFilterHistory.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file       SequentialFilterHistory.cpp
00003  *  \brief      An abstract class to store generic sequential filter data.
00004  *  \author $Author: rsharo $
00005  *  \version $Revision: 1.4 $
00006  *  \date    $Date: 2003/11/01 21:00:15 $
00007  *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /*  
00009  */
00010 //////////////////////////////////////////////////////////////////////////////////////////////////
00011 
00012 #include "SequentialFilterHistory.h"
00013     
00014 
00015 /*! @brief Protected initializer function.  A pseudo-constuctor for this abstract class, if you will.
00016  * Takes a pointer to the filter being logged; called from dervied class constructor. */
00017 void SequentialFilterHistory::InitializeSequentialFilterHistory(SequentialFilter* _ptr_filter)
00018 {
00019         // clean start
00020         ResetHistory();
00021         
00022         // store that protected data member!
00023         m_ptr_filter = _ptr_filter;
00024         
00025         // allocate space for the vector containers
00026         m_sfStateHistory.reserve(HISTORY_RESERVE_SIZE);
00027         m_sfControlHistory.reserve(HISTORY_RESERVE_SIZE);
00028         m_sfMeasurementHistory.reserve(HISTORY_RESERVE_SIZE);
00029         m_sfParameterHistory.reserve(HISTORY_RESERVE_SIZE);
00030 };
00031 
00032 
00033 
00034 /*! \brief Add the sequential 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  *
00041  */
00042 void SequentialFilterHistory::AppendHistory(const double& _appendTime)
00043 {
00044     AppendHistory(ssfTime(_appendTime));
00045 }    
00046     
00047 
00048 
00049 /*! \brief Add the sequential filters's data, which occured at a time in seconds, to the history.
00050  *
00051  *  Appends the state at t=_appendTime. if the new state 
00052  *      occured at a time that is earlier than any of the stored values
00053  *      then the time history will be erased from the overlap point 
00054  *      and the new state will be appended.
00055  * 
00056  */
00057 void SequentialFilterHistory::AppendHistory(const ssfTime& _appendTime)
00058 {
00059         // time stuff
00060         History::AppendHistory(_appendTime);
00061         
00062         // the four vectors
00063         m_sfStateHistory.push_back( m_ptr_filter->GetStateVector() );
00064         m_sfControlHistory.push_back( m_ptr_filter->GetControlVector() );
00065         m_sfMeasurementHistory.push_back( m_ptr_filter->GetMeasurementVector() );
00066         m_sfParameterHistory.push_back( m_ptr_filter->GetParameterVector() );
00067         
00068         return;
00069 }
00070 
00071 
00072 
00073 /*! \brief Erases the sequential filters's struct history */
00074 void SequentialFilterHistory::ResetHistory() { }
00075 
00076 
00077 
00078 /*! \brief Returns a matrix of the sequential filter's struct history
00079  * @return This function returns a matrix in the form [t_k, state(t_k), control(t_k), measurement(t_k), parameter(t_k)]
00080  */
00081 Matrix SequentialFilterHistory::GetHistory()
00082 {
00083         // initialize the output matrix based on the size of the desired output state, 
00084         // and an element for time. The number of rows is equal to the number of time elements.
00085         int StateVectorSize = m_ptr_filter->GetStateVector().getIndexBound();
00086         int ControlVectorSize = m_ptr_filter->GetControlVector().getIndexBound();
00087         int MeasurementVectorSize = m_ptr_filter->GetMeasurementVector().getIndexBound();
00088         int ParameterVectorSize = m_ptr_filter->GetParameterVector().getIndexBound();
00089         
00090         Matrix returnMatrix(m_TimeHistory.size(), 1 + StateVectorSize + ControlVectorSize + MeasurementVectorSize + ParameterVectorSize);
00091     
00092         // and stick it in the matrx!   
00093         for(unsigned int ii = 0; ii < m_TimeHistory.size(); ii++)
00094                 {
00095                 returnMatrix(MatrixIndexBase + ii, MatrixIndexBase) = m_TimeHistory[ii].GetSeconds();
00096                 returnMatrix(MatrixIndexBase + ii, _(MatrixIndexBase + 1, MatrixIndexBase + StateVectorSize)) = ~m_sfStateHistory[ii];
00097                 returnMatrix(MatrixIndexBase + ii, _(MatrixIndexBase + 1 + StateVectorSize, MatrixIndexBase + StateVectorSize + ControlVectorSize)) = ~m_sfControlHistory[ii];
00098                 returnMatrix(MatrixIndexBase + ii, _(MatrixIndexBase + 1 + StateVectorSize + ControlVectorSize, MatrixIndexBase + StateVectorSize + ControlVectorSize + MeasurementVectorSize)) = ~m_sfMeasurementHistory[ii];
00099                 returnMatrix(MatrixIndexBase + ii, _(MatrixIndexBase + 1 + StateVectorSize + ControlVectorSize + MeasurementVectorSize, MatrixIndexBase + StateVectorSize + ControlVectorSize + MeasurementVectorSize + ParameterVectorSize)) = ~m_sfParameterHistory[ii];
00100                 }
00101         
00102         return returnMatrix;
00103 }
00104 
00105 
00106 // Do not change the comments below - they will be added automatically by CVS
00107 /*****************************************************************************
00108 *       $Log: SequentialFilterHistory.cpp,v $
00109 *       Revision 1.4  2003/11/01 21:00:15  rsharo
00110 *       changed "Time.h" includes to "utils/Time.h" includes. Also eliminated excess compile warnings.
00111 *       
00112 *       Revision 1.3  2003/06/28 00:45:37  simpliciter
00113 *       Basic housekeeping.
00114 *       
00115 *       Revision 1.2  2003/06/27 01:53:56  simpliciter
00116 *       Fully commented and fully functional!
00117 *       GetState not implemented because it would require / desire
00118 *       iterpolations, which seems not in the spirit of logging the
00119 *       performance of a filter.
00120 *       
00121 *       Revision 1.1  2003/06/24 15:50:06  simpliciter
00122 *       Everything but the all important "GetHistory" command
00123 *       should work.  :)
00124 *       
00125 *       Revision 1.0  2003/06/06 18:44:15  simpliciter
00126 *       Initial submission.
00127 *       
00128 *
00129 ******************************************************************************/

Generated on Wed Sep 5 12:54:25 2007 for DSACSS Operational Code by  doxygen 1.3.9.1