dof_uncertainty.h
Go to the documentation of this file.
00001 
00059 /*
00060  * dof_uncertainty.h
00061  *
00062  *  Created on: 31.05.2012
00063  *      Author: josh
00064  */
00065 
00066 #ifndef DOF_UNCERTAINTY_H_
00067 #define DOF_UNCERTAINTY_H_
00068 
00069 #include "euler.h"
00070 
00071 
00073 namespace DOF6
00074 {
00075 
00079   template <typename ROBOTPARAMETERS, typename TYPE>
00080   class DOF6_Uncertainty
00081   {
00082     typedef Eigen::Matrix<TYPE,3,1> Vector;
00083     typedef Eigen::Matrix<TYPE,3,3> Matrix;
00084     typedef Eigen::Matrix<TYPE,4,4> Matrix4;
00085 
00086     TYPE translation_speed_, rotation_speed_; 
00087     double start_time_, end_time_;
00088 
00089     double timeDelta() const
00090     {
00091 #ifdef _DEBUG
00092       ROS_ASSERT(end_time_>start_time_);
00093 #endif
00094       return end_time_ - start_time_;
00095     }
00096 
00097     Vector tr_;
00098     TYPE var_rot_off_, var_tr_off_;
00099     EulerAngles<TYPE> rot_;
00100 
00101   public:
00102 
00103     DOF6_Uncertainty()
00104     :translation_speed_(ROBOTPARAMETERS::getMaxSpeedTranslationPerSecond()),
00105      rotation_speed_(ROBOTPARAMETERS::getMaxSpeedRotationPerSecond()),
00106      start_time_(std::numeric_limits<double>::max()),
00107      end_time_(std::numeric_limits<double>::min()),
00108      tr_(Vector::Zero()), var_rot_off_(0), var_tr_off_(0)
00109     {
00110     }
00111 
00112     void deepCopy(const DOF6_Uncertainty &o)
00113     {
00114       *this = o;
00115     }
00116 
00117     DOF6_Uncertainty transpose() const {
00118       DOF6_Uncertainty r = *this;
00119       Matrix4 M = getTF4().inverse();
00120       r.tr_ = M.col(3).head(3);
00121       r.rot_ = (EulerAngles<TYPE>)M.topLeftCorner(3,3);
00122       return r;
00123     }
00124 
00125     DOF6_Uncertainty operator+(const DOF6_Uncertainty &o) const    
00126     {
00127       DOF6_Uncertainty r = *this;
00128       r.var_rot_off_= var_rot_off_+ o.var_rot_off_;
00129       r.var_tr_off_ = var_tr_off_ + o.var_tr_off_;
00130       r.start_time_ = r.end_time_;
00131       Matrix4 M = getTF4()*o.getTF4();
00132       r.tr_ = M.col(3).head(3);
00133       r.rot_ = (EulerAngles<TYPE>)M.topLeftCorner(3,3);
00134       return r;
00135     }
00136 
00137     TYPE getRotationVariance() const
00138     {
00139       return timeDelta()*rotation_speed_+var_rot_off_;
00140     }
00141 
00142     TYPE getTranslationVariance() const
00143     {
00144       return timeDelta()*translation_speed_+var_tr_off_;
00145     }
00146 
00147     TYPE getRotationVariance2() const
00148     {
00149       return 10*getRotationVariance();
00150     }
00151 
00152     TYPE getTranslationVariance2() const
00153     {
00154       return 10*getTranslationVariance();
00155     }
00156 
00157     EulerAngles<TYPE> getRotation() const
00158     {
00159       return rot_;
00160     }
00161 
00162     Vector getTranslation() const
00163     {
00164       return tr_;
00165     }
00166 
00167     void reset()
00168     {
00169       tr_=Vector::Zero();
00170       rot_=Eigen::Matrix3f::Identity();
00171       var_rot_off_=var_tr_off_=0;
00172       start_time_ = std::numeric_limits<double>::max();
00173       end_time_ = std::numeric_limits<double>::min();
00174       std::cout<<"reset "<<start_time_<<"\n";
00175     }
00176 
00177     void setTime(const double time_in_sec)
00178     {
00179       std::cout<<"setTime "<<time_in_sec<<"\n";
00180       start_time_ = std::min(start_time_, time_in_sec);
00181       end_time_ = std::max(end_time_, time_in_sec);
00182     }
00183 
00184     void setVariance(const TYPE Tvar, const Vector &tr, const TYPE Rvar, const EulerAngles<TYPE> &rot)
00185     {
00186       var_tr_off_ = Tvar;
00187       var_rot_off_ = Rvar;
00188       rot_ = rot;
00189       tr_ = tr;
00190       start_time_ = end_time_;
00191     }
00192 
00193     Matrix4 getTF4() const {
00194       Matrix4 r=Matrix4::Identity();
00195       r.topLeftCorner(3,3) = (Eigen::Matrix3f)getRotation();
00196       r.col(3).head(3)     = getTranslation();
00197       return r;
00198     }
00199 
00200     inline bool isRealSource() const {return true;}
00201 
00202     inline double getStartTime() const {return start_time_;}
00203     inline double getEndTime() const {return end_time_;}
00204 
00205   };
00206 
00207   template <typename ROBOTPARAMETERS, typename TYPE>
00208   std::ostream &operator<<(std::ostream &os, const DOF6_Uncertainty<ROBOTPARAMETERS,TYPE> &s)
00209   {
00210 
00211     os<<"DOF6_Uncertainty\n\n";
00212 
00213     os<<"rot\n"<<s.getRotation()<<"\n";
00214     os<<"tr\n"<<s.getTranslation()<<"\n";
00215     os<<"var rot: "<<s.getRotationVariance()<<"\n";
00216     os<<"var tr:  "<<s.getTranslationVariance()<<"\n";
00217     os<<"start: "<<s.getStartTime()<<"\n";
00218     os<<"end:   "<<s.getEndTime()<<"\n";
00219 
00220     return os;
00221   }
00222 
00223 }
00224 
00225 
00226 #endif /* DOF_UNCERTAINTY_H_ */


cob_3d_mapping_slam
Author(s): Joshua Hampp
autogenerated on Wed Aug 26 2015 11:04:50