void magnetic_field_estimator(vector v_B_o) { float time_in_years = 2015 + (float)seconds_since_pivot / SECONDS_IN_YEAR; vector v_temp, v_r_lla, v_B_ned, v_B_eci; eci2ecef(v_r, v_temp); ecef2lla(v_temp, v_r_lla);// LLA is need ///* Save LLA vector for use in communications check routine copy_vector(v_r_lla, v_sat);// why is this required when ,lat long alt coming from GPS igrf(v_r_lla, time_in_years, 8, v_B_ned);// need to check at the end ned2ecef(v_B_ned, v_r_lla, v_temp); ecef2eci(v_temp, v_B_eci); eci2orbit(v_r, v_v, v_B_eci, v_B_o); scalar_into_vector(v_B_o, 1e-9); // igrf gives in nT int8_t sen,sen1; int16_t st; /*for (int i=0;i<3;i=i+1) { //sen = ((int8_t)((lambda))/2); st =(int16_t)(v_B_eci[i]/10); sen = (int8_t)st; sen1 = (int8_t)(st>>8); transmit_UART0(sen); transmit_UART0(sen1); }*/ }
void magnetic_field_estimator(vector v_B_o) { float time_in_years = 2010 + (float)seconds_since_pivot / SECONDS_IN_YEAR; vector v_temp, v_r_lla, v_B_ned, v_B_eci; eci2ecef(v_r, v_temp); ecef2lla(v_temp, v_r_lla); igrf(v_r_lla, time_in_years, 8, v_B_ned); ned2ecef(v_B_ned, v_r_lla, v_temp); ecef2eci(v_temp, v_B_eci); eci2orbit(v_r, v_v, v_B_eci, v_B_o); scalar_into_vector(v_B_o, 1e-9); }
void magnetic_field_estimator(vector v_B_o) { float time_in_years = 2010 + (float)seconds_since_pivot / SECONDS_IN_YEAR; vector v_temp, v_r_lla, v_B_ned, v_B_eci; eci2ecef(v_r, v_temp); ecef2lla(v_temp, v_r_lla); ///* Save LLA vector for use in communications check routine copy_vector(v_r_lla, v_sat); igrf(v_r_lla, time_in_years, 8, v_B_ned); ned2ecef(v_B_ned, v_r_lla, v_temp); ecef2eci(v_temp, v_B_eci); eci2orbit(v_r, v_v, v_B_eci, v_B_o); scalar_into_vector(v_B_o, 1e-9); }
void sgp_get_acceleration(vector v_g) { vector v_r_ecef, v_g_ecef; float R, R2, R3, R4; eci2ecef(v_r, v_r_ecef); R = vector_norm(v_r_ecef); R2 = pow(R, 2); R2 = (1.5 * J2 * R_E2) / R2; R3 = pow(R, 3); R4 = pow(R, 4); R4 = (7.5 * J2 * v_r_ecef[2] * R_E2) / R4; v_g_ecef[0] = (-1 * GM * v_r_ecef[0] * (1 + R2 + R4)) / R3; v_g_ecef[1] = (-1 * GM * v_r_ecef[1] * (1 + R2 + R4)) / R3; v_g_ecef[2] = (-1 * GM * v_r_ecef[2] * (1 + 3 * R2 + R4)) / R3; ecef2eci(v_g_ecef, v_g); }