Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 #ifndef RBMODEL_HPP_
00038 #define RBMODEL_HPP_
00039 #include <labust/simulation/matrixfwd.hpp>
00040 #include <labust/simulation/DynamicsParams.hpp>
00041 #include <labust/simulation/NoiseModel.hpp>
00042 #include <labust/math/NumberManipulation.hpp>
00043 #include <labust/vehicles/ThrustAllocation.hpp>
00044 
00045 namespace labust
00046 {
00047   namespace simulation
00048   {
00056     class RBModel : public labust::simulation::DynamicsParams
00057     {
00058     public:
00059       enum {x=0,y,z,phi,theta,psi};
00060       enum {u=0,v,w,p,q,r};
00061       enum {X=0,Y,Z,K,M,N};
00065       RBModel();
00069       ~RBModel();
00070 
00077       void step(const vector& tau);
00078 
00082       inline void alloc_step(const vector& tauIn, vector& tauAch)
00083       {
00084         this->allocator.allocate(tauIn,tauAch);
00085         this->step(tauAch);
00086       }
00087 
00094       inline const vector& Eta() const {return this->eta;};
00101       inline const vector& Nu() const {return this->nu;};
00108       inline const vector& NuAcc() const {return this->nuacc;};
00115       inline const vector& EtaNoisy() const {return this->etaN = this->eta + this->noise.calculateW();};
00122       inline const vector& NuNoisy() const {return this->nuN = this->nu + this->noise.calculateV();};
00123 
00130       inline void setNuAndEta(const vector& nu,const vector& eta)
00131       {
00132         this->nu = this->nu0 = nu;
00133         this->eta = this->eta0 = eta;
00134       }
00138       inline double getPressure(double h) const{return this->rho*this->g_acc*h;};
00139 
00143       inline void init()
00144       {
00145         this->reset();
00146         calculate_mrb();
00147         
00148         eta(z) = (m/(2*ae*be*ce*M_PI/3*rho)-1)*ce - waterLevel - rb(z);
00149       }
00153       void reset()
00154       {
00155         this->eta = this->eta0;
00156         this->nu = this->nu0;
00157         this->B=2*labust::math::coerce((eta(z)+waterLevel+rb(z)/2)/ce+1,0,2)*M_PI/3*ae*be*ce*rho*g_acc;
00158       };
00159 
00163       double dT;
00167       bool isCoupled;
00171       double ae,be,ce;
00175       double waterLevel;
00179       vector3 current;
00180 
00184       vector nu0, eta0;
00188       mutable labust::simulation::NoiseModel noise;
00189 
00193       labust::vehicles::ThrustAllocator allocator;
00194 
00195     protected:
00199       void coriolis();
00203       void restoring_force(const matrix3& J1);
00207       void calculate_mrb();
00208 
00212       double B;
00216       vector nu,nuacc;
00220       vector eta;
00224       mutable vector etaN, nuN;
00228       vector g;
00229     };
00230 
00241     template<class Derived>
00242     matrix3 skewSymm3(const Eigen::MatrixBase<Derived>& vec)
00243     {
00244       matrix3 mat;
00245       mat<<0,-vec(2),vec(1),
00246                 vec(2),0,-vec(0),
00247                 -vec(1),vec(0),0;
00248       return mat;
00249     };
00250   }
00251 }
00252 
00253 
00254 #endif