📄 ogsstructs.h
字号:
/* ************************************************************************
* *
* GPS Simulation *
* *
* -------------------------------------------------------------------- *
* *
* Module: osgstrct.h *
* *
* Version: 0.1 *
* Date: 17.02.02 *
* *
* Author: G. Beyerle *
* *
* -------------------------------------------------------------------- *
* *
* Copyright (C) 2002-2006 Georg Beyerle *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
* -------------------------------------------------------------------- *
* *
* The files 'gpsfuncs.cpp', 'gpsrcvr.cpp' are modified versions of *
* the files with the same name from Clifford Kelley's OpenSourceGPS *
* distribution. The unmodified files can be obtained from *
* http://www.home.earthlink.net/~cwkelley *
* *
* -------------------------------------------------------------------- *
* *
* Structures *
* *
************************************************************************ */
/* ******************************* changes ********************************
dd.mm.yy -
************************************************************************ */
/* ------------------------------------------------------------------------ */
/* ------------------------------- structures ----------------------------- */
// --- broadcast ionospheric delay model ---
typedef struct ionodata
{
float b0, b1, b2, b3,
al0, al1, al2, al3;
} IONODATA;
// --- broadcast UTC data ---
typedef struct utcdata
{
float a0, a1, // first 2 polynomial coefficients
tot, // reference time for UTC data
WNt, // UTC refrence week number
dtls, // delta time due to leap seconds
WNlsf, // week number
DN, // day number
dtlsf; // delta time due to leap seconds
} UTCDATA;
// --- Approximate orbital parameters ---
typedef struct almanac
{
long how,
tow;
int sfid,
asflag,
alertflag;
int prn,
health,
week, // week number
sat_file;
float ety, // eccentricity
inc, // inclination angle at reference time relative to 0.3 semi-circles
omegadot, // (was rra) rate of right ascension
sqra, // square root of semi-major axis
omega0, // (was lan) longitude of ascending node of orbit plane at weekly epoch
w, // argument of perigee
ma, // mean anomaly at reference time
toa, // almanac reference time
af0, af1; // clock polynomial correction parameters
char text_message[23];
} ALMANAC;
// --- Precise orbital parameters ---
typedef struct ephemeris
{
long how,
tow;
int sfid,
asflag,
alertflag;
int iode, // issue of date, ephemeris
iodc, // issue of date, clock
ura, // user range accuracy
valid,
health, // satellite health
week;
double dn, // delta n: mean motion correction term
tgd, // satellite group delay differential correction term
toe, // reference time ephemeris
toc, // clock data reference time
omegadot, // rate of right ascension
idot, // rate of inclination angle
cuc, // amplitude of the cosine harmonic correction term to the argument of latitude
cus, // amplitude of the sine harmonic correction term to the argument of latitude
crc, // amplitude of the cosine harmonic correction term to the orbit radius
crs, // amplitude of the sine harmonic correction term to the orbit radius
cic, // amplitude of the cosine harmonic correction term to the angle of inclination
cis, // amplitude of the sine harmonic correction term to the angle of inclination
ma, // mean anomaly at reference time
sqra, // square root of semi-major axis
omega0, // (was w0) longitude of ascending node of orbit plane at weekly epoch
inc0, // inclination angle at reference time
w, // argument of perigee
wm, // mean motion [rad/sec]
ety, // eccentricity
af0, af1, af2; // clock polynomial correction parameters
} EPHEMERIS;
//
// put all in one struct
//
typedef struct navdata
{
long sf1how,
sf2how,
sf3how,
sf4how,
sf5how;
EPHEMERIS eph;
int sf4pageno, // subframe 4 page number (1,...,25)
sf5pageno, // subframe 5 page number (1,...,25)
sf4svid, // subframe 4 SV id (1,...,63)
sf5svid; // subframe 5 SV id (1,...,63)
ALMANAC alm; // sf5/p1-24;sf4/p2-5,7-10
IONODATA iono; // sf4/p18: ionospheric par & UTC
UTCDATA utc;
int SVh[NOFSAT+1], // sf5/p25: satellite vehicle health
ASV[NOFSAT+1]; // sf4/p25: anti-spoofing & satellite vehicle configuration
char text_msg[23]; // sf4/p17: 22 ASCII chars and '\0'
} NAVDATA;
#if 0
typedef struct
{
long how,
tow;
int sfid,
asflag,
alertflag;
EPHEMERIS gps_eph;
} SUBFRAME1TO3;
typedef struct
{
long how,
tow;
int sfid,
asflag,
alertflag;
ALMANAC gps_alm; // sf5/p1-24;sf4/p2-5,7-10
char text_msg[23]; // sf4/p17: 22 ASCII chars and '\0'
IONODATA iono; // sf4/p18: ionospheric par & UTC
UTCDATA utc;
int ASV[NOFSAT+1]; // sf4/p25: anti-spoofing & satellite vehicle configuration
} SUBFRAME4;
typedef struct
{
long how,
tow;
int sfid,
asflag,
alertflag;
ALMANAC gps_alm; // sf5/p1-24;sf4/p2-5,7-10
int SVh[NOFSAT+1]; // sf5/p25: satellite vehicle health
} SUBFRAME5;
// --- frame consists of 5 subframes
typedef struct navdata
{
SUBFRAME1TO3 sf123;
SUBFRAME4 sf4;
SUBFRAME5 sf5;
} NAVDATA;
#endif
// --- receiver channel info ---
typedef struct
{
int state;
long code_freq, // frq of code DCO in units of 42.6 mHz
carrier_freq, // frq of carrier DCO in units of 42.6 mHz
doppler, // same as chan[].carrier_freq
carrier_corr;
char message[1500], // navigation message
tow_sync,
prn,
bit,
frame_ready;
int offset,
codes, // index of C/A code start
n_freq, // index in carrier frq list, 1 step corresponds to frq shift 'd_freq'
del_freq;
int t_count, // range: 0,...,1499; increment every 20 msec (in total 30 sec)
ms_count, // range: 0,...,19; increment every 1 msec
i_confirm;
int ms_epoch,
n_frame, // frame counter, increases when 't_count' wraps
ch_time,
i_count;
int con_thresh,
n_thresh,
sfid,
missed,
page5;
int i_dith, // in-phase early/late arm
q_dith, // quad-phase early/late arm
i_prmt, // in-phase prompt arm
q_prmt; // quad-phase promt arm
unsigned long iq2_prmt, // squared in/quad-phase prompt arm
iq2_dith; //
long i_prmt_sum, // in-phase prompt arm, summed over N msec (N<=20)
q_prmt_sum, // quad-phase prompt arm, summed over N msec (N<=20)
i_dith_sum, // in-phase early/late arm, summed over N msec (N<=20)
q_dith_sum; // quad-phase early/late arm, summed over N msec (N<=20)
unsigned long iq2_prmt_sum; // squared in/quad-phase prompt arm, summed over N msec (N<=20)
int i_prmt_sav[NOFCOHINT], // save array for prompt sum 'i_prmt_sum' (tracking)
q_prmt_sav[NOFCOHINT],
i_dith_sav[NOFCOHINT], // save array for dither sum 'i_dith_sum' (tracking)
q_dith_sav[NOFCOHINT];
unsigned long iq2_prmt_sav[NOFCOHINT]; // save array for squared prompt sum
#if 0
long i_prmt_sum_evn, // in-phase prompt arm, summed over N msec (N<=20)
q_prmt_sum_evn, // quad-phase prompt arm, summed over N msec (N<=20)
i_dith_sum_evn, // in-phase early/late arm, summed over N msec (N<=20)
q_dith_sum_evn; // quad-phase early/late arm, summed over N msec (N<=20)
int i_prmt_sav_evn[NOFCOHINTPULLIN], // nav bit flip either in *_even or in *_odd, not in both!
q_prmt_sav_evn[NOFCOHINTPULLIN],
i_dith_sav_evn[NOFCOHINTPULLIN],
q_dith_sav_evn[NOFCOHINTPULLIN];
unsigned long iq2_prmt_sav_evn[NOFCOHINTPULLIN]; // save array for squared prompt sum
unsigned long iq2_prmt_sum_evn; // squared in/quad-phase prompt arm, summed over N msec (N<=20)
long i_prmt_sum_odd, // in-phase prompt arm, summed over N msec (N<=20)
q_prmt_sum_odd, // quad-phase prompt arm, summed over N msec (N<=20)
i_dith_sum_odd, // in-phase early/late arm, summed over N msec (N<=20)
q_dith_sum_odd; // quad-phase early/late arm, summed over N msec (N<=20)
int i_prmt_sav_odd[NOFCOHINTPULLIN],
q_prmt_sav_odd[NOFCOHINTPULLIN],
i_dith_sav_odd[NOFCOHINTPULLIN],
q_dith_sav_odd[NOFCOHINTPULLIN];
unsigned long iq2_prmt_sav_odd[NOFCOHINTPULLIN]; // save array for squared prompt sum
unsigned long iq2_prmt_sum_odd; // squared in/quad-phase prompt arm, summed over N msec (N<=20)
#endif
long sum,
avg,
old_theta,
old_i_sum,
old_q_sum,
th_rms; // phase angle 'theta' RMS
long dfreq, // discriminator code frq
old_dfreq, // previous value
dcarr, // discriminator carrier frq
old_dcarr; // previous value
int iq_sav_idx,
bitsign;
long prompt_mag,
dith_mag;
long tr_bit_time,
meas_bit_time,
TOW; // time of week
unsigned int carr_dco_phase,
carr_cycle_l,
carr_cycle_h;
unsigned int epoch,
code_phase,
code_dco_phase;
unsigned int databithist[NOFMSECPERDATABIT];
float CNo; // signal to noise ratio
double dsc_car_phs, // discriminator carrier frq
dsc_cod_phs, // discriminator code frq
car_lock_det, // carrier lock detector
cod_lock_det; // carrier lock detector
} CHANNEL;
// --- GPS satellite position ---
typedef struct satvis
{
float azimuth, elevation, doppler,
x, y, z;
} SATVIS;
typedef struct ecef
{
double x, y, z;
} ECEF;
typedef struct eceft
{
double x, y, z, tb;
float az, el;
} ECEFT;
typedef struct llh
{
double lat, lon, hae;
} LLH;
typedef struct pvt
{
double x, y, z,
dt,
xv, yv, zv,
df;
} PVT;
/* --------------------------------- enums -------------------------------- */
// --- tracking is in one the following 5 states ---
enum { off, acquisition, confirm, pull_in, track};
//enum {none,o_gdop,o_pdop,o_hdop,o_vdop};
enum { cold_start, warm_start, hot_start, tracking, navigating};
/* ------------------------------ end of file ----------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -