RBModel.hpp
Go to the documentation of this file.
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright (c) 2010, LABUST, UNIZG-FER
00005 *  All rights reserved.
00006 *
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 *
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of the LABUST nor the names of its
00018 *     contributors may be used to endorse or promote products derived
00019 *     from this software without specific prior written permission.
00020 *
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 *
00034 *  Author: Dula Nad
00035 *  Created: 01.02.2010.
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         //Calculate and set the the neutral depth where W=B
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 /* RBMODEL_HPP_ */
00254 #endif


labust_sim
Author(s): Gyula Nagy
autogenerated on Fri Feb 7 2014 11:36:33