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 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 #include "simple_plane.h"
00073 #include <cmath>
00074 #include <iostream>
00075 
00076 using namespace std;
00077 
00078 cPlaneEKF_sp::cPlaneEKF_sp() 
00079 {
00080         setDim(4, 1, 2, 2, 2);
00081         Period = 0.2;
00082         Gravity = 9.8;
00083         Bfriction = 0.35;
00084         Portance = 3.92;
00085         Mass = 1000;
00086 }
00087 
00088 void cPlaneEKF_sp::makeA()
00089 {
00090         A(1,1) = 1.0;
00091         A(1,2) = Period - Period*Period*Bfriction/Mass*x(2);
00092         A(1,3) = 0.0;
00093         A(1,4) = 0.0;
00094 
00095         A(2,1) = 0.0;
00096         A(2,2) = 1 - 2*Period*Bfriction/Mass*x(2);
00097         A(2,3) = 0.0;
00098         A(2,4) = 0.0;
00099 
00100         A(3,1) = 0.0;
00101         A(3,2) = Period*Period*Portance/Mass*x(2);
00102         A(3,3) = 1.0;
00103         A(3,4) = Period;
00104 
00105         A(4,1) = 0.0;
00106         A(4,2) = 2*Period*Portance/Mass*x(2);
00107         A(4,3) = 0.0;
00108         A(4,4) = 1.0;
00109 }
00110 
00111 void cPlaneEKF_sp::makeW()
00112 {
00113         W(1,1) = 0.0;
00114         W(1,2) = 0.0;
00115         W(2,1) = 1.0;
00116         W(2,2) = 0.0;
00117         W(3,1) = 0.0;
00118         W(3,2) = 0.0;
00119         W(4,1) = 0.0;
00120         W(4,2) = 1.0;
00121 }
00122 
00123 void cPlaneEKF_sp::makeQ()
00124 {
00125         Q(1,1) = 0.01*0.01;
00126         Q(1,2) = 0.01*0.01/10.0;
00127         Q(2,1) = 0.01*0.01/10.0;
00128         Q(2,2) = 0.01*0.01;
00129 }
00130 
00131 void cPlaneEKF_sp::makeH()
00132 {
00133         H(1,1) = -x(3)/(x(1)*x(1)+x(3)*x(3));
00134         H(1,2) = 0.0;
00135         H(1,3) = x(1)/(x(1)*x(1)+x(3)*x(3));
00136         H(1,4) = 0.0;
00137 
00138         H(2,1) = x(1)/sqrt(x(1)*x(1)+x(3)*x(3));
00139         H(2,2) = 0.0;
00140         H(2,3) = x(3)/sqrt(x(1)*x(1)+x(3)*x(3));
00141         H(2,4) = 0.0;
00142 }
00143 
00144 void cPlaneEKF_sp::makeV()
00145 {
00146         V(1,1) = 1.0;
00147         V(1,2) = 0.0;
00148         V(2,1) = 0.0;
00149         V(2,2) = 1.0;
00150 }
00151 
00152 void cPlaneEKF_sp::makeR()
00153 {
00154         R(1,1) = 0.01*0.01;
00155         R(1,2) = 0.0;
00156         R(2,1) = 0.0;
00157         R(2,2) = 50*50;
00158 }
00159 
00160 void cPlaneEKF_sp::makeProcess()
00161 {
00162         Vector x_(x.size());
00163         x_(1) = x(1) + x(2)*Period + (Period*Period)/2*(u(1)/Mass - Bfriction/Mass*x(2)*x(2));
00164         x_(2) = x(2) + (u(1)/Mass - Bfriction/Mass*x(2)*x(2))*Period;
00165         x_(3) = x(3) + x(4)*Period + (Period*Period)/2*(Portance/Mass*x(2)*x(2)-Gravity);
00166         x_(4) = x(4) + (Portance/Mass*x(2)*x(2)-Gravity)*Period;
00167         x.swap(x_);
00168 }
00169 
00170 void cPlaneEKF_sp::makeMeasure()
00171 {
00172         z(1)=atan2(x(3), x(1));
00173         z(2)=sqrt(x(1)*x(1)+x(3)*x(3));
00174 }
00175