| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
#include "ls_types.h" |
| 107 |
#include "ls_generic.h" |
| 108 |
#include "ls_constants.h" |
| 109 |
#include "ls_accel.h" |
| 110 |
#include <math.h> |
| 111 |
|
| 112 |
void ls_accel( void ) { |
| 113 |
|
| 114 |
SCALAR inv_Mass, inv_Radius; |
| 115 |
SCALAR ixz2, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10; |
| 116 |
SCALAR dx_pilot_from_cg, dy_pilot_from_cg, dz_pilot_from_cg; |
| 117 |
SCALAR tan_Lat_geocentric; |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
F_X = F_X_aero + F_X_engine + F_X_gear; |
| 124 |
F_Y = F_Y_aero + F_Y_engine + F_Y_gear; |
| 125 |
F_Z = F_Z_aero + F_Z_engine + F_Z_gear; |
| 126 |
|
| 127 |
M_l_rp = M_l_aero + M_l_engine + M_l_gear; |
| 128 |
M_m_rp = M_m_aero + M_m_engine + M_m_gear; |
| 129 |
M_n_rp = M_n_aero + M_n_engine + M_n_gear; |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
M_l_cg = M_l_rp + F_Y*Dz_cg - F_Z*Dy_cg; |
| 134 |
M_m_cg = M_m_rp + F_Z*Dx_cg - F_X*Dz_cg; |
| 135 |
M_n_cg = M_n_rp + F_X*Dy_cg - F_Y*Dx_cg; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
F_north = T_local_to_body_11*F_X + T_local_to_body_21*F_Y |
| 140 |
+ T_local_to_body_31*F_Z; |
| 141 |
F_east = T_local_to_body_12*F_X + T_local_to_body_22*F_Y |
| 142 |
+ T_local_to_body_32*F_Z; |
| 143 |
F_down = T_local_to_body_13*F_X + T_local_to_body_23*F_Y |
| 144 |
+ T_local_to_body_33*F_Z; |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
tan_Lat_geocentric = tan(Lat_geocentric); |
| 149 |
inv_Mass = 1/Mass; |
| 150 |
inv_Radius = 1/Radius_to_vehicle; |
| 151 |
V_dot_north = inv_Mass*F_north + |
| 152 |
inv_Radius*(V_north*V_down - V_east*V_east*tan_Lat_geocentric); |
| 153 |
V_dot_east = inv_Mass*F_east + |
| 154 |
inv_Radius*(V_east*V_down + V_north*V_east*tan_Lat_geocentric); |
| 155 |
V_dot_down = inv_Mass*(F_down) + Gravity - |
| 156 |
inv_Radius*(V_north*V_north + V_east*V_east); |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
ixz2 = I_xz*I_xz; |
| 161 |
c0 = 1/(I_xx*I_zz - ixz2); |
| 162 |
c1 = c0*((I_yy-I_zz)*I_zz - ixz2); |
| 163 |
c4 = c0*I_xz; |
| 164 |
|
| 165 |
c2 = c4*(I_xx - I_yy + I_zz); |
| 166 |
c3 = c0*I_zz; |
| 167 |
c7 = 1/I_yy; |
| 168 |
c5 = c7*(I_zz - I_xx); |
| 169 |
c6 = c7*I_xz; |
| 170 |
c8 = c0*((I_xx - I_yy)*I_xx + ixz2); |
| 171 |
|
| 172 |
c9 = c4*(I_yy - I_zz - I_xx); |
| 173 |
c10 = c0*I_xx; |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
P_dot_body = (c1*R_body + c2*P_body)*Q_body + c3*M_l_cg + c4*M_n_cg; |
| 178 |
Q_dot_body = c5*R_body*P_body + c6*(R_body*R_body - P_body*P_body) + c7*M_m_cg; |
| 179 |
R_dot_body = (c8*P_body + c9*R_body)*Q_body + c4*M_l_cg + c10*M_n_cg; |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
inv_Mass = 1/Mass; |
| 184 |
|
| 185 |
A_X_cg = F_X * inv_Mass; |
| 186 |
A_Y_cg = F_Y * inv_Mass; |
| 187 |
A_Z_cg = F_Z * inv_Mass; |
| 188 |
|
| 189 |
dx_pilot_from_cg = Dx_pilot - Dx_cg; |
| 190 |
dy_pilot_from_cg = Dy_pilot - Dy_cg; |
| 191 |
dz_pilot_from_cg = Dz_pilot - Dz_cg; |
| 192 |
|
| 193 |
A_X_pilot = A_X_cg + (-R_body*R_body - Q_body*Q_body)*dx_pilot_from_cg |
| 194 |
+ ( P_body*Q_body - R_dot_body )*dy_pilot_from_cg |
| 195 |
+ ( P_body*R_body + Q_dot_body )*dz_pilot_from_cg; |
| 196 |
A_Y_pilot = A_Y_cg + ( P_body*Q_body + R_dot_body )*dx_pilot_from_cg |
| 197 |
+ (-P_body*P_body - R_body*R_body)*dy_pilot_from_cg |
| 198 |
+ ( Q_body*R_body - P_dot_body )*dz_pilot_from_cg; |
| 199 |
A_Z_pilot = A_Z_cg + ( P_body*R_body - Q_dot_body )*dx_pilot_from_cg |
| 200 |
+ ( Q_body*R_body + P_dot_body )*dy_pilot_from_cg |
| 201 |
+ (-Q_body*Q_body - P_body*P_body)*dz_pilot_from_cg; |
| 202 |
|
| 203 |
N_X_cg = INVG*A_X_cg; |
| 204 |
N_Y_cg = INVG*A_Y_cg; |
| 205 |
N_Z_cg = INVG*A_Z_cg; |
| 206 |
|
| 207 |
N_X_pilot = INVG*A_X_pilot; |
| 208 |
N_Y_pilot = INVG*A_Y_pilot; |
| 209 |
N_Z_pilot = INVG*A_Z_pilot; |
| 210 |
|
| 211 |
|
| 212 |
U_dot_body = T_local_to_body_11*V_dot_north + T_local_to_body_12*V_dot_east |
| 213 |
+ T_local_to_body_13*V_dot_down - Q_total*W_body + R_total*V_body; |
| 214 |
V_dot_body = T_local_to_body_21*V_dot_north + T_local_to_body_22*V_dot_east |
| 215 |
+ T_local_to_body_23*V_dot_down - R_total*U_body + P_total*W_body; |
| 216 |
W_dot_body = T_local_to_body_31*V_dot_north + T_local_to_body_32*V_dot_east |
| 217 |
+ T_local_to_body_33*V_dot_down - P_total*V_body + Q_total*U_body; |
| 218 |
|
| 219 |
|
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|