EKF_3D_USBLModel.hpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * EKF_3D_USBLModel.cpp
00003  *
00004  *  Created on: Feb 25, 2013
00005  *      Author: Dula Nad
00006  *
00007  *  Modified on: Apr 1, 2015
00008  *      Author: Filip Mandic
00009  *
00010  ********************************************************************/
00011 
00012 /*********************************************************************
00013 * Software License Agreement (BSD License)
00014 *
00015 *  Copyright (c) 2015, LABUST, UNIZG-FER
00016 *  All rights reserved.
00017 *
00018 *  Redistribution and use in source and binary forms, with or without
00019 *  modification, are permitted provided that the following conditions
00020 *  are met:
00021 *
00022 *   * Redistributions of source code must retain the above copyright
00023 *     notice, this list of conditions and the following disclaimer.
00024 *   * Redistributions in binary form must reproduce the above
00025 *     copyright notice, this list of conditions and the following
00026 *     disclaimer in the documentation and/or other materials provided
00027 *     with the distribution.
00028 *   * Neither the name of the LABUST nor the names of its
00029 *     contributors may be used to endorse or promote products derived
00030 *     from this software without specific prior written permission.
00031 *
00032 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00033 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00034 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00035 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00036 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00037 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00038 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00039 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00040 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00041 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00042 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00043 *  POSSIBILITY OF SUCH DAMAGE.
00044 *********************************************************************/
00045 #ifndef EKF_3DMODEL_HPP_
00046 #define EKF_3DMODEL_HPP_
00047 #include <labust/navigation/SSModel.hpp>
00048 
00049 namespace labust
00050 {
00051   namespace navigation
00052   {
00056     class EKF_3D_USBLModel : public SSModel<double>
00057     {
00058         typedef SSModel<double> Base;
00059     public:
00060       typedef vector input_type;
00061       typedef vector output_type;
00062 
00063       struct ModelParams
00064       {
00065           ModelParams():
00066                   alpha(1),
00067                   beta(1),
00068                   betaa(0){};
00069 
00070           ModelParams(double alpha, double beta, double betaa):
00071                   alpha(alpha),
00072                   beta(beta),
00073                   betaa(betaa){}
00074 
00075           inline double Beta(double val)
00076           {
00077                   return beta + betaa*fabs(val);
00078           }
00079 
00080           double alpha, beta, betaa;
00081       };
00082 
00083       enum {u=0,v,w,p,q,r,xp,yp,zp,phi,theta,psi,xc,yc,b,buoyancy,roll_restore,pitch_restore,altitude,xb,yb,zb,stateNum};
00084       enum {X=0,Y,Z,Kroll,M,N,inputSize};
00085       enum {range=stateNum,bearing,elevation,measSize};
00086 
00087       //const char *VarNames[]  = {"u","v","w","p","q","r","xp","yp","zp","phi","theta","psi","xc","yc","b","buoyancy","roll_restore","pitch_restore","altitude","xb","yb","zb","range","bearing","elevation"};
00088 
00089 
00093       EKF_3D_USBLModel();
00097       ~EKF_3D_USBLModel();
00098 
00104       void step(const input_type& input);
00110       void estimate_y(output_type& y);
00114       void initModel();
00115 
00119       const output_type& update(vector& measurements, vector& newMeas);
00120 
00124       void setParameters(const ModelParams& surge,
00125                   const ModelParams& sway,
00126                   const ModelParams& heave,
00127                   const ModelParams& roll,
00128                   const ModelParams& pitch,
00129                   const ModelParams& yaw)
00130       {
00131           this->surge = surge;
00132           this->sway = sway;
00133           this->heave = heave;
00134           this->roll = roll;
00135           this->pitch = pitch;
00136           this->yaw = yaw;
00137       }
00138 
00139       void calculateXYInovationVariance(const matrix& P, double& xin,double &yin);
00140       void calculateUVInovationVariance(const matrix& P, double& uin,double &vin);
00141       double calculateAltInovationVariance(const matrix& P);
00142 
00146       inline void getNEDSpeed(double& xdot, double& ydot)
00147       {
00148         xdot = this->xdot;
00149         ydot = this->ydot;
00150       }
00151 
00152       inline void useDvlModel(int flag){this->dvlModel = flag;};
00153 
00154     protected:
00158       void derivativeAW();
00162        void derivativeHV(int num);
00166        void derivativeH();
00170       ModelParams surge,sway,heave,roll,pitch,yaw;
00174       output_type measurement;
00178       double xdot,ydot;
00182       int dvlModel;
00186       matrix Hnl;
00190       vector ynl,y;
00191     };
00192   }
00193 }
00194 
00195 /* EKF_3DMODEL_HPP_ */
00196 #endif


labust_navigation
Author(s): Gyula Nagy
autogenerated on Fri Aug 28 2015 11:23:33