Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
robotCenteredConstantVelocity.hpp
Go to the documentation of this file.
00001 
00012 #ifndef ROBOTCENTEREDCONSTANTVELOCITY_HPP_
00013 #define ROBOTCENTEREDCONSTANTVELOCITY_HPP_
00014 
00015 #include "rtslam/robotAbstract.hpp"
00016 
00017 namespace jafar {
00018   namespace rtslam {
00019 
00020     class RobotCenteredConstantVelocity;
00021     typedef boost::shared_ptr<RobotCenteredConstantVelocity> robcenteredconstvel_ptr_t;
00022 
00023 
00035     class RobotCenteredConstantVelocity: public RobotAbstract {
00036       public:
00037 
00038 
00043         RobotCenteredConstantVelocity(const map_ptr_t & _mapPtr);
00044 
00045         ~RobotCenteredConstantVelocity(void) {
00046         }
00047 
00048         virtual std::string typeName() const {
00049           return "Centered-Constant-velocity";
00050         }
00051 
00052         void getFrameForReframing(vec7 & frame) ;
00053 
00067         void move_func(const vec & _x, const vec & _u, const vec & _n, const double _dt, vec & _xnew, mat & _XNEW_x,
00068             mat & _XNEW_pert, unsigned tempSet = 0) const;
00069 
00070         void computePertJacobian();
00071 
00089         static size_t size() {
00090           int size_x_Rk_Rkm1 = 13 ; // P,Q,V,W
00091           int size_x_B_Rkm1  = 7  ; // P,Q
00092           return size_x_Rk_Rkm1 + size_x_B_Rkm1  ;
00093         }
00094         static size_t size_control() {
00095           return 0;
00096         }
00097         static size_t size_perturbation() {
00098           return 6;
00099         }
00100 
00101         virtual size_t mySize() {return size();}
00102         virtual size_t mySize_control() {return size_control();}
00103         virtual size_t mySize_perturbation() {return size_perturbation();}
00104 
00111         void setVelocityStd(double velLinStd, double velAngStd){
00112           for (size_t i = pose.size(); i < pose.size() + 3; i++){
00113             state.P(i,i) = velLinStd*velLinStd;
00114           }
00115           for (size_t i = pose.size() + 3; i < pose.size() + 6; i++){
00116             state.P(i,i) = velAngStd*velAngStd;
00117           }
00118         }
00119 
00120       protected:
00121 //        /**
00122 //         * Split state vector.
00123 //         *
00124 //         * Extracts \a p, \a q, \a v and \a w from the state vector, \a x = [\a p, \a q, \a v, \a w].
00125 //         * \param x the state vector
00126 //         * \param p the position
00127 //         * \param q the quaternion
00128 //         * \param v the linear velocity
00129 //         * \param w the angular velocity
00130 //         */
00131 //        template<class Vx, class Vp, class Vq, class Vv, class Vw>
00132 //        inline void splitState(const Vx x, Vp & p, Vq & q, Vv & v, Vw & w) {
00133 //          p = ublas::subrange(x, 0, 3);
00134 //          q = ublas::subrange(x, 3, 7);
00135 //          v = ublas::subrange(x, 7, 10);
00136 //          w = ublas::subrange(x, 10, 13);
00137 //        }
00138 
00151         template<class Vx, class Vp, class Vq, class Vv, class Vw>
00152         inline void splitState(const Vx x, Vp & p, Vq & q, Vv & v, Vw & w, Vp & pBase, Vq & qBase) const {
00153           p     = ublas::subrange(x,  0,  3);
00154           q     = ublas::subrange(x,  3,  7);
00155           v     = ublas::subrange(x,  7, 10);
00156           w     = ublas::subrange(x, 10, 13);
00157           pBase = ublas::subrange(x, 13, 16);
00158           qBase = ublas::subrange(x, 16, 20);
00159         }
00160 
00161 
00162 //        /**
00163 //         * Compose state vector.
00164 //         *
00165 //         * Composes the state vector with \a p, \a q, \a v and \a w, \a x = [\a p, \a q, \a v, \a w].
00166 //         * \param p the position
00167 //         * \param q the quaternion
00168 //         * \param v the linear velocity
00169 //         * \param w the angular velocity
00170 //         * \param x the state vector
00171 //         */
00172 //        template<class Vp, class Vq, class Vv, class Vw, class Vx>
00173 //        inline void unsplitState(const Vp & p, const Vq & q, const Vv & v, const Vw & w, Vx & x) {
00174 //          ublas::subrange(x, 0, 3) = p;
00175 //          ublas::subrange(x, 3, 7) = q;
00176 //          ublas::subrange(x, 7, 10) = v;
00177 //          ublas::subrange(x, 10, 13) = w;
00178 //        }
00179 
00192         template<class Vp, class Vq, class Vv, class Vw, class Vx>
00193         inline void unsplitState(const Vp & p, const Vq & q, const Vv & v, const Vw & w, const Vp & pBase, const Vq & qBase, Vx & x) const {
00194           ublas::subrange(x, 0, 3)   = p    ;
00195           ublas::subrange(x, 3, 7)   = q    ;
00196           ublas::subrange(x, 7, 10)  = v    ;
00197           ublas::subrange(x, 10, 13) = w    ;
00198           ublas::subrange(x, 13, 16) = pBase;
00199           ublas::subrange(x, 16, 20) = qBase;
00200         }
00201 
00202 
00210         template<class Vu, class V>
00211         inline void splitControl(const Vu & u, V & vi, V & wi) const {
00212           vi = project(u, ublas::range(0, 3));
00213           wi = project(u, ublas::range(3, 6));
00214         }
00215 
00216       private:
00217         // temporary matrices to speed up Jacobian computation
00218         struct TempVariables
00219         {
00220           vec7 lastJump; // F contains [p,q]' of the last reframe prediction.
00221           mat33 PNEW_v; 
00222           mat43 QNEW_wdt; 
00223   //        mat43 PBASENEW_p; ///<    Temporary Jacobian matrix
00224   //        mat44 PBASENEW_q; ///<    Temporary Jacobian matrix
00225   //        mat43 QBASENEW_p; ///<    Temporary Jacobian matrix
00226   //        mat44 QBASENEW_q; ///<    Temporary Jacobian matrix
00227   //        mat44 QNEW_q; ///<      Temporary Jacobian matrix
00228         };
00229         mutable TempVariables tempvars0, tempvars1;
00230 
00231     };
00232   }
00233 }
00234 
00235 #endif /* ROBOTCENTEREDCONSTANTVELOCITY_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:27 for Jafar by doxygen 1.7.6.1
LAAS-CNRS