Skip to content

Commit

Permalink
corrected user algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
aerokiwi committed Aug 9, 2018
1 parent 4acf59b commit 6d77a42
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 65 deletions.
11 changes: 11 additions & 0 deletions src/core/system_parameters/beidou_cnav2_almanac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ Beidou_Cnav2_Almanac::Beidou_Cnav2_Almanac()
Phi_0 = 0.0; //!< Argument of latitude at reference time
//Health = 0.0; //!< Satellite health information
}

double Beidou_Cnav2_Almanac::BDS_time_of_transmission(double t_sv)
{
double t;
double dt_sv;

dt_sv = a_f0 + a_f1 * (t-t_oa);

t = t_sv - dt_sv;
return t;
}
1 change: 1 addition & 0 deletions src/core/system_parameters/beidou_cnav2_almanac.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Beidou_Cnav2_Almanac
archive& make_nvp("Health", Health);
}

double BDS_time_of_transmission(double t_sv);
/*!
* Default constructor
*/
Expand Down
53 changes: 44 additions & 9 deletions src/core/system_parameters/beidou_cnav2_ephemeris.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,53 @@ Beidou_Cnav2_Ephemeris::Beidou_Cnav2_Ephemeris()
SISAI_oc2 = 0.0; //Satellite clock drift accuracy index

// Ionospheric Delay Correction Model Parameters
alpha_1 = 0.0;
alpha_2 = 0.0;
alpha_3 = 0.0;
alpha_4 = 0.0;
alpha_5 = 0.0;
alpha_6 = 0.0;
alpha_7 = 0.0;
alpha_8 = 0.0;
alpha_9 = 0.0;
alpha_1 = 0.0; //[TECu]
alpha_2 = 0.0; //[TECu]
alpha_3 = 0.0; //[TECu]
alpha_4 = 0.0; //[TECu]
alpha_5 = 0.0; //[TECu]
alpha_6 = 0.0; //[TECu]
alpha_7 = 0.0; //[TECu]
alpha_8 = 0.0; //[TECu]
alpha_9 = 0.0; //[TECu]

// Group Delay Differential Parameters
T_GDB1Cp = 0.0; //Group delay differential of the B1C pilot component [s]
T_GDB2ap = 0.0; //Group delay differential of the B2a pilot component [s]
ISC_B2ad = 0.0; //Group delay differential between the B2a data and pilot components [s]
}

double Beidou_Cnav2_Ephemeris::B2a_ranging_code_phase_correction_w_pilot(double dt_sv)
{
double dt_sv_B2ap;
dt_sv_B2ap = dt_sv - T_GDB2ap;
return dt_sv_B2ap;
}

double Beidou_Cnav2_Ephemeris::B2a_ranging_code_phase_correction_w_data(double dt_sv)
{
double dt_sv_B2ad;
dt_sv_B2ad = dt_sv - T_GDB2ap - ISC_B2ad;
return dt_sv_B2ad;
}

double Beidou_Cnav2_Ephemeris::B2a_UT1_UTC_difference(double t)
{
return dUT1 -dUT1_dot*(t-t_EOP);
}

double Beidou_Cnav2_Ephemeris::B2a_Polar_motion_x(double t)
{
double x_p;

x_p = PM_X + PM_X_dot * (t-t_EOP);
return x_p;
}

double Beidou_Cnav2_Ephemeris::B2a_Polar_motion_y(double t)
{
double y_p;

y_p = PM_Y + PM_Y_dot * (t-t_EOP);
return y_p;
}
32 changes: 23 additions & 9 deletions src/core/system_parameters/beidou_cnav2_ephemeris.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,36 @@ class Beidou_Cnav2_Ephemeris
archive& make_nvp("SISAI_oc2", SISAI_oc2); //Satellite clock drift accuracy index

// Ionospheric Delay Correction Model Parameters
archive& make_nvp("alpha_1", alpha_1);
archive& make_nvp("alpha_2", alpha_2);
archive& make_nvp("alpha_3", alpha_3);
archive& make_nvp("alpha_4", alpha_4);
archive& make_nvp("alpha_5", alpha_5);
archive& make_nvp("alpha_6", alpha_6);
archive& make_nvp("alpha_7", alpha_7);
archive& make_nvp("alpha_8", alpha_8);
archive& make_nvp("alpha_9", alpha_9);
archive& make_nvp("alpha_1", alpha_1); // Ionosphere a1
archive& make_nvp("alpha_2", alpha_2); // Ionosphere a2
archive& make_nvp("alpha_3", alpha_3); // Ionosphere a3
archive& make_nvp("alpha_4", alpha_4); // Ionosphere a4
archive& make_nvp("alpha_5", alpha_5); // Ionosphere a5
archive& make_nvp("alpha_6", alpha_6); // Ionosphere a6
archive& make_nvp("alpha_7", alpha_7); // Ionosphere a7
archive& make_nvp("alpha_8", alpha_8); // Ionosphere a8
archive& make_nvp("alpha_9", alpha_9); // Ionosphere a9

// Group Delay Differential Parameters
archive& make_nvp("T_GDB1Cp", T_GDB1Cp); //Group delay differential of the B1C pilot component [s]
archive& make_nvp("T_GDB2ap", T_GDB2ap); //Group delay differential of the B2a pilot component [s]
archive& make_nvp("ISC_B2ad", ISC_B2ad); //Group delay differential between the B2a data and pilot components [s]
}

double B2a_ranging_code_phase_correction_w_pilot(double dt_sv);
// The single frequency user processing pseudorange from the B2a pilot component shall further correct the ranging code phase

double B2a_ranging_code_phase_correction_w_data(double dt_sv);
// The single frequency user processing pseudorange from the B2a data component shall further correct the ranging code phase

double B2a_UT1_UTC_difference(double t);
// UT1-UTC difference at time t

double B2a_Polar_motion_x(double t);
// Polar motion in the X-Axis at time t

double B2a_Polar_motion_y(double t);
// Polar motion in the Y-Axis at time t

Beidou_Cnav2_Ephemeris();
};
Expand Down
2 changes: 0 additions & 2 deletions src/core/system_parameters/beidou_cnav2_navigation_message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,5 @@ bool Beidou_Cnav2_Navigation_Message::have_new_almanac() //Check if we have a n
return true;
}
}

// todo fix
return false;
}
70 changes: 49 additions & 21 deletions src/core/system_parameters/beidou_cnav2_utc_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Beidou_Cnav2_Utc_Model::Beidou_Cnav2_Utc_Model()
WN_ot = 0.0; //Reference week number [week]
WN_LSF = 0.0; //Leap second reference week number [week]
DN = 0.0; //Leap second reference day number [day]
dt_LSF = 0.0; //Current of future leap second count [s]
dt_LSF = 0.0; //Current or future leap second count [s]

// BDT-GNSS Time Offset Parameters
GNSS_ID = 0.0; //GNSS type identification [dimensionless]
Expand All @@ -57,39 +57,67 @@ Beidou_Cnav2_Utc_Model::Beidou_Cnav2_Utc_Model()
A_2BGTO = 0.0; //Drift rate coefficient of BDT time scale relative to GNSS time scale [s/s^2]

// Clock Correction Parameters
t_oc = 0.0;
a_0 = 0.0;
a_1 = 0.0;
a_2 = 0.0;
t_oc = 0.0; //Clock correction parameters reference time [s] effective range 0~604500
a_0 = 0.0; //Satellite clock time bias correction coefficient [s]
a_1 = 0.0; //Satellite clock time drift correction coefficient [s/s]
a_2 = 0.0; //Satellite clock time drift rate correction coefficient [s/s^2]
}


double Beidou_Cnav2_Utc_Model::utc_time(double beidou_time)
double Beidou_Cnav2_Utc_Model::time_of_transmission(Beidou_Cnav2_Almanac const&alm, Beidou_Cnav2_Ephemeris const&eph, double t_sv)
{
double t_utc;
double t; // BDT time of signal transmission [s]
double dt_sv; // Satellite ranging code phase time offset [s]
double dt_r; // Relativistic correction term [s]

double mu;
double c;
double F;

double E_k;

c = 2.99792458e8; // Speed of light [m/s]
mu = 3.986004418e14; // Geocentric gravitational constant [m^3/s^2]
F = -2 *sqrt(mu) / (c * c);

t_utc = beidou_time + dt_LS; // Adds the leap seconds that is broadcasted
dt_r = F * eph.e * alm.sqrt_A * sin(E_k);

return t_utc;
dt_sv = a_0 + a_1*(t-t_oc) + a_2*(t-t_oc)*(t-t_oc) + dt_r;

t = t_sv - dt_sv;

return t;
}

double Beidou_Cnav2_Utc_Model::beidt_to_utc(Beidou_Cnav2_Ephemeris const&eph)

double Beidou_Cnav2_Utc_Model::beidt_to_utc(Beidou_Cnav2_Ephemeris const&eph, double t_E, double WN_E, double DN_E)
{
double t_UTC;
double dt_UTC;
double W;

// 1) DN is not in the past
dt_UTC = dt_LS + A_0UTC + A_1UTC * (eph.t_oe - t_ot + 604800 * (eph.WN - WN_ot)) + A_2UTC * (eph.t_oe - t_ot + 604800 * (eph.WN - WN_ot)) * (eph.t_oe - t_ot + 604800 * (eph.WN - WN_ot));
t_UTC = fmod((eph.t_oe - dt_UTC),86400);

// 2) user's present time falls within the time span which starts six hours prior to the leap second time and ends six hours after the leap second time
W = fmod((eph.t_oe - dt_UTC - 43200),86400) + 43200;
t_UTC = fmod(W,(86400 + dt_LSF - dt_LS));

// 3) DN is in the past
dt_UTC = dt_LSF + A_0UTC + A_1UTC * (eph.t_oe - t_ot + 604800 * (eph.WN - WN_ot)) + A_2UTC * (eph.t_oe - t_ot + 604800 * (eph.WN - WN_ot)) * (eph.t_oe - t_ot + 604800 * (eph.WN - WN_ot));
t_UTC = fmod((eph.t_oe - dt_UTC),86400);
// DN is not in the past
if ((WN_LSF - WN_E)*7 + (DN - DN_E) > 0)
{
if (abs(dt_LSF) > 6*3600)
{
// 1) user's present time does not fall within the time span which starts six hours prior to the leap second time and ends six hours after the leap second time
dt_UTC = dt_LS + A_0UTC + A_1UTC * (t_E - t_ot + 604800 * (WN_E - WN_ot)) + A_2UTC * (t_E - t_ot + 604800 * (WN_E - WN_ot)) * (t_E - t_ot + 604800 * (WN_E - WN_ot));
t_UTC = fmod((t_E - dt_UTC),86400);
}
else
{
// 2) user's present time falls within the time span which starts six hours prior to the leap second time and ends six hours after the leap second time
W = fmod((t_E - dt_UTC - 43200),86400) + 43200;
t_UTC = fmod(W,(86400 + dt_LSF - dt_LS));
}
}
else
{
// 3) DN is in the past
dt_UTC = dt_LSF + A_0UTC + A_1UTC * (t_E - t_ot + 604800 * (WN_E - WN_ot)) + A_2UTC * (t_E - t_ot + 604800 * (WN_E - WN_ot)) * (t_E - t_ot + 604800 * (WN_E - WN_ot));
t_UTC = fmod((t_E - dt_UTC),86400);
}

return t_UTC;
}
Expand Down
35 changes: 11 additions & 24 deletions src/core/system_parameters/beidou_cnav2_utc_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <boost/assign.hpp>
#include <boost/serialization/nvp.hpp>
#include "beidou_cnav2_ephemeris.h"
#include "beidou_cnav2_almanac.h"

//!!! Check
/*!
Expand Down Expand Up @@ -70,10 +71,10 @@ class Beidou_Cnav2_Utc_Model
double A_2BGTO; //Drift rate coefficient of BDT time scale relative to GNSS time scale [s/s^2]

// Clock Correction Parameters
double t_oc;
double a_0;
double a_1;
double a_2;
double t_oc; //Clock correction parameters reference time [s] effective range 0~604500
double a_0; //Satellite clock time bias correction coefficient [s]
double a_1; //Satellite clock time drift correction coefficient [s/s]
double a_2; //Satellite clock time drift rate correction coefficient [s/s^2]

template <class Archive>
/*!
Expand Down Expand Up @@ -113,34 +114,20 @@ class Beidou_Cnav2_Utc_Model
archive& make_nvp("a_2", a_2);
}

double beidt_to_gpst(const double offset_time, const double glot2utc_corr);

/*!
* \brief Converts from BEIDOUT to GPST
* \details Converts from BEIDOUT to GPST in time of week (TOW) and week number (WN) format
* \param[in] tod_offset Is the start of day offset
* \param[in] beidt2utc_corr Correction from BEIDOUT to UTC
* \param[in] beidt2gpst_corr Correction from BEIDOUT to GPST
* \param[out] WN Week Number, not in mod(1024) format
* \param[out] TOW Time of Week in seconds of week
*/
double beidt_to_utc(Beidou_Cnav2_Ephemeris const&eph);
double time_of_transmission(Beidou_Cnav2_Almanac const&alm, Beidou_Cnav2_Ephemeris const&eph, double t_sv);

double beidt_to_gpst(Beidou_Cnav2_Ephemeris const&eph, double beidou_time);

/*!
* \brief Converts from BEIDOUT to GPST
* \details Converts from BEIDOUT to GPST in time of week (TOW) and week number (WN) format
* \param[in] tod_offset Is the start of day offset
* \param[in] beidt2utc_corr Correction from BEIDOUT to UTC
* \param[in] beidt2gpst_corr Correction from BEIDOUT to GPST
* \param[out] WN Week Number, not in mod(1024) format
* \param[out] TOW Time of Week in seconds of week
*/
double beidt_to_utc(Beidou_Cnav2_Ephemeris const&eph, double t_E, double WN_E, double DN_E);

double beidt_to_gpst(const Beidou_Cnav2_Ephemeris &eph, double beid_time);

/*!
* Default constructor
* \brief Converts from BEIDOUT to UTC
* The t_E, WN_E, DN_E are the BDT estimated by the user
*/

double utc_time(double beidou_time);
Expand Down

0 comments on commit 6d77a42

Please sign in to comment.