MotionModuleState.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00030 
00031 #ifndef __MOTION_MODULE_STATE_H_
00032 #define __MOTION_MODULE_STATE_H_
00033 
00034 #include <SE2.h>
00035 #include <LogTrace.h>
00036 #include <list>
00037 
00038 namespace MipBaselib{
00039 
00040 enum TimestampLocation{
00041  TSPOS_IS_INSIDE,
00042  TSPOS_IS_BEFORE,
00043  TSPOS_IS_AFTER,
00044  TSPOS_NUM
00045 };
00046 
00050 class MotionModuleState : public MIPObject{
00051  
00052  public:
00053   Pose  pose;  
00054   Decimal linVel; 
00055   Decimal angVel; 
00056   
00061   MotionModuleState(Pose p=Pose(),Decimal lv=0.0,Decimal av=0.0);
00062   
00064   MotionModuleState(const MotionModuleState &v);
00065   
00067   MotionModuleState& operator=(const MotionModuleState& v);
00068   
00070   MotionModuleState& operator+=(const MotionModuleState& a);
00071   
00073   MotionModuleState& operator-=(const MotionModuleState& a);
00074   
00076   const MotionModuleState operator+(const MotionModuleState &other) const {
00077    return MotionModuleState(*this) += other;
00078   }
00079   
00081   const MotionModuleState operator-(const MotionModuleState &other) const {
00082    return MotionModuleState(*this) -= other;
00083   }
00084 
00087   string getObjectName() const {
00088    return "MotionModuleState";
00089   }
00090   
00092   Position velVector(void);
00093 
00095   virtual string print();
00096 };
00097 
00102 class MotionModuleTState : public MotionModuleState{
00103  public:
00104   Time timeStamp; 
00105   
00110   MotionModuleTState(Pose p=Pose(),Decimal lv=0.0,Decimal av=0.0,Time ts=Time());
00111   
00113   MotionModuleTState(const MotionModuleTState &v);
00114   
00116   MotionModuleTState& operator=(const MotionModuleTState& v){
00117    if (this != &v){
00118     pose  = v.pose;
00119     linVel = v.linVel;
00120     angVel = v.angVel;
00121     timeStamp = v.timeStamp;
00122    }
00123    return *this;
00124   }
00126   string print();
00127 };
00128 
00132 class MotionModuleTStateLog : public list <MotionModuleTState>{
00133  private:
00137   MotionModuleTState _interpolation(list<MotionModuleTState>::reverse_iterator rit,list<MotionModuleTState>::reverse_iterator ritBefore,Time ts);
00138  public:
00139   
00140 //  /// \brief Gets the state in the log (pose, velocities and timestamp) which timestamp is the nearest to the give timestamp.
00141 //  /// \return A flag which is \b true if a state inside the given tollerance is found, \b false otherwise.
00142 //  /// \param[out].&nearestTState The state found, it makes sense only if return value is true.
00143 //  /// \param[in].ts The state to find in the log must have the nearest timestamp to this parameter.
00144 //  /// \param[in].tollerance If the last state in the log is less recent than ts more than tollerance a new getState() is performed.
00145 //  /// \todo to test
00146 //   bool getNearestTState(MotionModuleTState& nearestTState, Time ts,Time tollerance = Time(1,0));
00147   
00153   TimestampLocation getTState(MotionModuleTState& outputTState, Time timeStamp);
00154   
00162   TimestampLocation correctTState(MotionModuleTState& correctedTState);
00163   
00164   string print(){
00165    int thisSize = this->size();
00166    stringstream ss;
00167 //    for(int i = 0; i < thisSize; i++){
00168     ss << this->begin()->pose.print() << " " << this->begin()->timeStamp.dCast() << endl;
00169     ss << this->rbegin()->pose.print()<< " " << this->rbegin()->timeStamp.dCast() << endl;
00170 //    }
00171    return ss.str();
00172   }
00173 //   MotionModuleTStateLog::iterator getLastItemPointer();
00174 };
00175 
00176 } // End of namespace
00177 #endif

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6