00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "AhrsErrorDynamics.h"
00020 #include "uvsim/utilities/utilities.h"
00021 #include "uvsim/utilities/constants.h"
00022
00023 using namespace boost::numeric::ublas;
00024
00025 namespace uvsim
00026 {
00027
00028 AhrsErrorDynamics::AhrsErrorDynamics(vector<double> *x, vector<double> *u, Ins *ins) :
00029 LinearModel(x,u), ins(ins)
00030 {
00031 }
00032
00033 AhrsErrorDynamics::~AhrsErrorDynamics()
00034 {
00035 }
00036
00037 void AhrsErrorDynamics::initialize()
00038 {
00039 size(9,3,1);
00040 update();
00041
00042
00043 Ec = identity_matrix<double>(n)*1;
00044
00045
00046 L = identity_matrix<double>(m)*1;
00047
00048 }
00049
00050
00051 void AhrsErrorDynamics::update()
00052 {
00053 matrix<double> C_bl(3,3), C_lb(3,3);
00054 double th, phi, gam;
00055 vector<double> w_il(3);
00056 w_il(0) = ins->velocity(1)/(R0+ins->altitude) + omega*cos(ins->latitude);
00057 w_il(1) = -ins->velocity(0)/(R0+ins->altitude);
00058 w_il(2) = -ins->velocity(1)*tan(ins->latitude)/(R0+ins->altitude) - omega*sin(ins->latitude);
00059
00060
00061 phi = ins->euler(2);
00062 th = ins->euler(1);
00063 gam = ins->euler(0);
00064
00065
00066 C_bl(0,0) = cos(th)*cos(phi);
00067 C_bl(1,0) = -cos(gam)*sin(phi) + sin(gam)*sin(th)*cos(phi);
00068 C_bl(2,0) = sin(gam)*sin(phi) + cos(gam)*sin(th)*cos(phi);
00069 C_bl(0,1) = cos(th)*sin(phi);
00070 C_bl(1,1) = cos(gam)*cos(phi) + sin(gam)*sin(th)*sin(phi);
00071 C_bl(2,1) = -sin(gam)*cos(phi) + cos(gam)*sin(th)*sin(phi);
00072 C_bl(0,2) = -sin(th);
00073 C_bl(1,2) = sin(gam)*cos(th);
00074 C_bl(2,2) = cos(gam)*cos(th);
00075
00076 C_lb = trans(C_bl);
00077
00078
00079
00080 subrange(Ac,0,3,0,3) = skew(w_il);
00081 subrange(Ac,0,3,3,6) = -C_lb;
00082 subrange(Ac,0,3,6,7) = subrange(C_lb,0,3,0,1)*ins->gyro(0);
00083 subrange(Ac,0,3,7,8) = subrange(C_lb,0,3,1,2)*ins->gyro(1);
00084 subrange(Ac,0,3,8,9) = subrange(C_lb,0,3,2,3)*ins->gyro(2);
00085
00086
00087
00088
00089
00090 C(0,0) = -tan(th)*cos(phi);
00091 C(0,1) = -tan(th)*sin(phi);
00092 C(0,2) = -1;
00093 C(1,0) = sin(th);
00094 C(1,1) = -cos(th);
00095 C(2,0) = -cos(phi)/cos(th);
00096 C(2,1) = -sin(phi)/cos(th);
00097 }
00098
00099 }
00100
00101
00102