[关闭]
@taqikema 2018-07-02T09:42:24.000000Z 字数 31229 阅读 38014

RTKLIB源码解析(一)——单点定位(pntpos.c)

GNSS RTKLIB 单点定位


pntpos

  1. int pntpos (const obsd_t *obs, int n, const nav_t *nav, const prcopt_t *opt, sol_t *sol,
  2. double *azel, ssat_t *ssat, char *msg)
  1. 函数参数,8个:
  2. obsd_t *obs I observation data
  3. int n I number of observation data
  4. nav_t *nav I navigation data
  5. prcopt_t *opt I processing options
  6. sol_t *sol IO solution
  7. double *azel IO azimuth/elevation angle (rad) (NULL: no output)
  8. ssat_t *ssat IO satellite status (NULL: no output)
  9. char *msg O error message for error exit
  10. 返回类型:
  11. int O (1:ok,0:error)
Created with Raphaël 2.1.2pntpossatpossestposraim_fdeestvelend

pntpos satposs estpos raim_fde estvel



satposs

  1. void satposs(gtime_t teph, const obsd_t *obs, int n, const nav_t *nav,
  2. int ephopt, double *rs, double *dts, double *var, int *svh)
  1. 函数参数,9个:
  2. gtime_t teph I time to select ephemeris (gpst)
  3. obsd_t *obs I observation data
  4. int n I number of observation data
  5. nav_t *nav I navigation data
  6. int ephopt I ephemeris option (EPHOPT_???)
  7. double *rs O satellite positions and velocities,长度为6*n,{x,y,z,vx,vy,vz}(ecef)(m,m/s)
  8. double *dts O satellite clocks,长度为2*n {bias,drift} (s|s/s)
  9. double *var O sat position and clock error variances (m^2)
  10. int *svh O sat health flag (-1:correction not available)
  11. 返回类型:
  12. none
Created with Raphaël 2.1.2satpossephclksatpos钟差为0?ephclkendyesno

satposs ephclk satpos



estpos

  1. int estpos(const obsd_t *obs, int n, const double *rs, const double *dts,
  2. const double *vare, const int *svh, const nav_t *nav,
  3. const prcopt_t *opt, sol_t *sol, double *azel, int *vsat,
  4. double *resp, char *msg)
  1. 函数参数,13个:
  2. obsd_t *obs I observation data
  3. int n I number of observation data
  4. double *rs I satellite positions and velocities,长度为6*n,{x,y,z,vx,vy,vz}(ecef)(m,m/s)
  5. double *dts I satellite clocks,长度为2*n {bias,drift} (s|s/s)
  6. double *vare I sat position and clock error variances (m^2)
  7. int *svh I sat health flag (-1:correction not available)
  8. nav_t *nav I navigation data
  9. prcopt_t *opt I processing options
  10. sol_t *sol IO solution
  11. double *azel IO azimuth/elevation angle (rad)
  12. int *vsat IO 表征卫星在定位时是否有效
  13. double *resp IO 定位后伪距残差 (P-(r+c*dtr-c*dts+I+T))
  14. char *msg O error message for error exit
  15. 返回类型:
  16. int O (1:ok,0:error)
Created with Raphaël 2.1.2estposrescodelsqvalsolend

estpos rescode lsq valsol
- 处理过程

  1. sol->rr的前 3项赋值给 x数组。
  2. 开始迭代定位计算,首先调用 rescode函数,计算在当前接收机位置和钟差值的情况下,定位方程的右端部分 v(nv\*1)、几何矩阵 H(NX*nv)、此时所得的伪距残余的方差 var、所有观测卫星的 azel{方位角、仰角}、定位时有效性 vsat、定位后伪距残差 resp、参与定位的卫星个数 ns和方程个数 nv
  3. 确定方程组中方程的个数要大于未知数的个数。
  4. 以伪距残余的标准差的倒数作为权重,对 H和 v分别左乘权重对角阵,得到加权之后的 H和 v。
  5. 调用 lsq函数,根据 ,得到当前 x的修改量和定位误差协方差矩阵中的权系数阵。
  6. 将 5中求得的 x加入到当前 x值中,得到更新之后的 x值。
  7. 如果 5中求得的修改量小于截断因子(目前是1e-4),则将 6中得到的 x值作为最终的定位结果,对 sol的相应参数赋值,之后再调用 valsol函数确认当前解是否符合要求(伪距残余小于某个 值和 GDOP小于某个门限值)。否则,进行下一次循环。
  8. 如果超过了规定的循环次数,则输出发散信息后,返回 0。

raim_fde

  1. int raim_fde(const obsd_t *obs, int n, const double *rs,
  2. const double *dts, const double *vare, const int *svh,
  3. const nav_t *nav, const prcopt_t *opt, sol_t *sol,
  4. double *azel, int *vsat, double *resp, char *msg)
  1. 函数参数,13个:
  2. obsd_t *obs I observation data
  3. int n I number of observation data
  4. double *rs I satellite positions and velocities,长度为6*n,{x,y,z,vx,vy,vz}(ecef)(m,m/s)
  5. double *dts I satellite clocks,长度为2*n {bias,drift} (s|s/s)
  6. double *vare I sat position and clock error variances (m^2)
  7. int *svh I sat health flag (-1:correction not available)
  8. nav_t *nav I navigation data
  9. prcopt_t *opt I processing options
  10. sol_t *sol IO solution
  11. double *azel IO azimuth/elevation angle (rad)
  12. int *vsat IO 表征卫星在定位时是否有效
  13. double *resp IO 定位后伪距残差 (P-(r+c*dtr-c*dts+I+T))
  14. char *msg O error message for error exit
  15. 返回类型:
  16. int O (1:ok,0:error)
Created with Raphaël 2.1.2raim_fdeestposend

raim_fde estpos



estvel

  1. void estvel(const obsd_t *obs, int n, const double *rs, const double *dts,
  2. const nav_t *nav, const prcopt_t *opt, sol_t *sol,
  3. const double *azel, const int *vsat)
  1. 函数参数,9个:
  2. obsd_t *obs I observation data
  3. int n I number of observation data
  4. double *rs I satellite positions and velocities,长度为6*n,{x,y,z,vx,vy,vz}(ecef)(m,m/s)
  5. double *dts I satellite clocks,长度为2*n {bias,drift} (s|s/s)
  6. nav_t *nav I navigation data
  7. prcopt_t *opt I processing options
  8. sol_t *sol IO solution
  9. double *azel IO azimuth/elevation angle (rad)
  10. int *vsat IO 表征卫星在定位时是否有效
  11. 返回类型:
  12. int O (1:ok,0:error)
Created with Raphaël 2.1.2estvelresdoplsqend

estvel resdop lsq



ephclk

  1. int ephclk(gtime_t time, gtime_t teph, int sat, const nav_t *nav, double *dts)
  1. 函数参数,5个:
  2. gtime_t time I transmission time by satellite clock
  3. gtime_t teph I time to select ephemeris (gpst)
  4. int sat I satellite number (1-MAXSAT)
  5. nav_t *nav I navigation data
  6. double *dts O satellite clocks,长度为2*n {bias,drift} (s|s/s)
  7. 返回类型:
  8. int O (1:ok,0:error)
Created with Raphaël 2.1.2ephclksatsysselepheph2clkend

ephclk satsys seleph eph2clk



satpos

  1. int satpos(gtime_t time, gtime_t teph, int sat, int ephopt, const nav_t *nav,
  2. double *rs, double *dts, double *var, int *svh)
  1. 函数参数,9个:
  2. gtime_t time I time (gpst)
  3. gtime_t teph I time to select ephemeris (gpst)
  4. int sat I satellite number
  5. nav_t *nav I navigation data
  6. int ephopt I ephemeris option (EPHOPT_???)
  7. double *rs O sat position and velocity {x,y,z,vx,vy,vz} (ecef)(m|m/s)
  8. double *dts O sat clock {bias,drift} (s|s/s)
  9. double *var O sat position and clock error variance (m^2)
  10. int *svh O sat health flag (-1:correction not available)
  11. 返回类型:
  12. int O (1:ok,0:error)
Created with Raphaël 2.1.2satposephposend

satpos ephpos


satsys

  1. int satsys(int sat, int *prn)
  1. 函数参数,2个:
  2. int sat I satellite number (1-MAXSAT)
  3. int *prn IO satellite prn/slot number (NULL: no output)
  4. 返回类型:
  5. int satellite system (SYS_GPS,SYS_GLO,...)

seleph

  1. eph_t *seleph(gtime_t time, int sat, int iode, const nav_t *nav)
  1. 函数参数,4个:
  2. gtime_t time I time to select ephemeris (gpst)
  3. int sat I satellite number (1-MAXSAT)
  4. int iode I 星历数据期号
  5. nav_t *nav I navigation data
  6. 返回类型:
  7. eph_t * 星历数据


eph2clk

  1. int eph2clk (gtime_t time, const eph_t *eph)
  1. 函数参数,2
  2. gtime_t time I time by satellite clock (gpst)
  3. eph_t *eph I broadcast ephemeris
  4. 返回类型:
  5. double satellite clock bias (s) without relativeity correction



ephpos

  1. int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav,
  2. int iode, double *rs, double *dts, double *var, int *svh)
  1. 函数参数,9
  2. gtime_t time I transmission time by satellite clock
  3. gtime_t teph I time to select ephemeris (gpst)
  4. int sat I satellite number (1-MAXSAT)
  5. nav_t *nav I navigation data
  6. int iode I 星历数据期号
  7. double *rs O satellite positions and velocities,长度为6*n,{x,y,z,vx,vy,vz}(ecef)(m,m/s)
  8. double *dts O satellite clocks,长度为2*n {bias,drift} (s|s/s)
  9. double *var O sat position and clock error variances (m^2)
  10. int *svh O sat health flag (-1:correction not available)
  11. 返回类型:
  12. int O (1:ok,0:error)
Created with Raphaël 2.1.2ephpossatsysselepheph2posend

ephpos satsys seleph eph2pos


eph2pos

  1. void eph2pos(gtime_t time, const eph_t *eph, double *rs, double *dts, double *var)
  1. 函数参数,5
  2. gtime_t time I transmission time by satellite clock
  3. eph_t *eph I broadcast ephemeris
  4. double *rs O satellite positions and velocities,长度为6*n,{x,y,z,vx,vy,vz}(ecef)(m,m/s)
  5. double *dts O satellite clocks,长度为2*n {bias,drift} (s|s/s)
  6. double *var O sat position and clock error variances (m^2)
  7. 返回类型:
  8. none

rescode

  1. int rescode(int iter, const obsd_t *obs, int n, const double *rs,
  2. const double *dts, const double *vare, const int *svh,
  3. const nav_t *nav, const double *x, const prcopt_t *opt,
  4. double *v, double *H, double *var, double *azel, int *vsat,
  5. double *resp, int *ns)
  1. 函数参数,17
  2. int iter I 迭代次数
  3. obsd_t *obs I observation data
  4. int n I number of observation data
  5. double *rs I satellite positions and velocities,长度为6*n,{x,y,z,vx,vy,vz}(ecef)(m,m/s)
  6. double *dts I satellite clocks,长度为2*n {bias,drift} (s|s/s)
  7. double *vare I sat position and clock error variances (m^2)
  8. int *svh I sat health flag (-1:correction not available)
  9. nav_t *nav I navigation data
  10. double *x I 本次迭代开始之前的定位值
  11. prcopt_t *opt I processing options
  12. double *v O 定位方程的右端部分,伪距残余
  13. double *H O 定位方程中的几何矩阵
  14. double *var O 参与定位的伪距残余方差
  15. double *azel O 对于当前定位值,每一颗观测卫星的 {方位角、高度角}
  16. int *vsat O 每一颗观测卫星在当前定位时是否有效
  17. double *resp O 每一颗观测卫星的伪距残余, (P-(r+c*dtr-c*dts+I+T))
  18. int *ns O 参与定位的卫星的个数
  19. 返回类型:
  20. int O 定位方程组的方程个数
Created with Raphaël 2.1.2rescodeecef2possatsysgeodistsatazelprangesatexcludeionocorrtropcorrvarerrend

rescode ecef2pos satsys geodist satazel prange satexclude ionocorr tropcorr varerr


lsq

  1. int lsq(const double *A, const double *y, int n, int m, double *x, double *Q)
  1. 函数参数,6
  2. double *A I transpose of (weighted) design matrix (n x m)
  3. double *y I (weighted) measurements (m x 1)
  4. int n,m I number of parameters and measurements (n<=m)
  5. double *x O estmated parameters (n x 1)
  6. double *Q O esimated parameters covariance matrix (n x n)
  7. 返回类型:
  8. int O (0:ok,0>:error)
Created with Raphaël 2.1.2lsqmatmulmatinvend

lsq matmul


valsol

  1. int valsol(const double *azel, const int *vsat, int n,
  2. const prcopt_t *opt, const double *v, int nv, int nx, char *msg)
  1. 函数参数,8
  2. double *azel I azimuth/elevation angle (rad)
  3. int *vsat I 表征卫星在定位时是否有效
  4. int n I number of observation data
  5. prcopt_t *opt I processing options
  6. double *v I 定位后伪距残差 (P-(r+c*dtr-c*dts+I+T))
  7. int nv I 定位方程的方程个数
  8. int nx I 未知数的个数
  9. char *msg O error message for error exit
  10. 返回类型:
  11. int O (1:ok,0:error)
Created with Raphaël 2.1.2valsoldopsend

valsol dops


matmul

源码中定义了两个 matmul函数,一个是在包含了 LAPACK/BLAS/MKL库使用,调用其中的 degmn函数来完成矩阵相乘操作。这里主要说明在没有包含上述库时自定义的矩阵相乘函数。

  1. void matmul(const char *tr, int n, int k, int m, double alpha,
  2. const double *A, const double *B, double beta, double *C)
  1. 函数参数,6
  2. char *tr I transpose flags ("N":normal,"T":transpose)
  3. int n,k,m I size of (transposed) matrix A,B
  4. double alpha I alpha
  5. double *A,*B I (transposed) matrix A (n x m), B (m x k)
  6. double beta I beta
  7. double *C IO matrix C (n x k)
  8. 返回类型:
  9. none

dops

  1. void dops(int ns, const double *azel, double elmin, double *dop)
  1. 函数参数,4
  2. int ns I number of satellites
  3. double *azel I satellite azimuth/elevation angle (rad)
  4. double elmin I elevation cutoff angle (rad)
  5. double *dop O DOPs {GDOP,PDOP,HDOP,VDOP}
  6. 返回类型:
  7. none
Created with Raphaël 2.1.2dopsmatmulmatinvend

dops matmul matinv


ecef2enu

  1. void ecef2enu(const double *pos, const double *r, double *e)
  1. 函数参数,3
  2. double *pos I geodetic position {lat,lon} (rad)
  3. double *r I vector in ecef coordinate {x,y,z}
  4. double *e O vector in local tangental coordinate {e,n,u}
  5. 返回类型:
  6. none
Created with Raphaël 2.1.2ecef2enuxyz2enumatmulend

ecef2enu xyz2enu matmul



xyz2enu

  1. void xyz2enu(const double *pos, double *E)
  1. 函数参数,2
  2. double *pos I geodetic position {lat,lon} (rad)
  3. double *E O vector in local tangental coordinate {e,n,u}
  4. 返回类型:
  5. none


ecef2pos

  1. void ecef2pos(const double *r, double *pos)
  1. 函数参数,2
  2. double *r I ecef position {x,y,z} (m)
  3. double *pos O geodetic position {lat,lon,h} (rad,m)
  4. 返回类型:
  5. none


geodist

  1. double geodist(const double *rs, const double *rr, double *e)
  1. 函数参数,3
  2. double *rs I satellilte position (ecef at transmission) (m)
  3. double *rr I receiver position (ecef at reception) (m)
  4. double *e O line-of-sight unit vector (ecef)
  5. 返回类型:
  6. double O geometric distance (m) (0>:error/no satellite position)

satazel

  1. double satazel(const double *pos, const double *e, double *azel)
  1. 函数参数,3
  2. double *pos I geodetic position {lat,lon,h} (rad,)
  3. double *e I receiver-to-satellilte unit vevtor (ecef)
  4. double *azel IO azimuth/elevation {az,el} (rad) (NULL: no output) (0.0<=azel[0]<2*pi,-pi/2<=azel[1]<=pi/2)
  5. 返回类型:
  6. double O elevation angle (rad)
Created with Raphaël 2.1.2satazelecef2enuend

satazel ecef2enu


prange

  1. double prange(const obsd_t *obs, const nav_t *nav, const double *azel,
  2. int iter, const prcopt_t *opt, double *var)
  1. 函数参数,6
  2. obsd_t *obs I observation data
  3. nav_t *nav I navigation data
  4. double *azel I 对于当前定位值,每一颗观测卫星的 {方位角、高度角}
  5. int iter I 迭代次数
  6. prcopt_t *opt I processing options
  7. double *vare O 伪距测量的码偏移误差
  8. 返回类型:
  9. double O 最终能参与定位解算的伪距值
Created with Raphaël 2.1.2prangesatsystestsnrgettgdend

prange satsys testsnr gettgd


satexclude

  1. int satexclude(int sat, int svh, const prcopt_t *opt)
  1. 函数参数,3
  2. int sat I satellite number,从 1开始
  3. int svh I sv health flag(0:ok)
  4. prcopt_t *opt I processing options (NULL: not used)
  5. 返回类型:
  6. int O 1:excluded,0:not excluded


ionocorr

  1. int ionocorr(gtime_t time, const nav_t *nav, int sat, const double *pos,
  2. const double *azel, int ionoopt, double *ion, double *var)
  1. 函数参数,8
  2. gtime_t time I time
  3. nav_t *nav I navigation data
  4. int sat I satellite number
  5. double *pos I receiver position {lat,lon,h} (rad|m)
  6. double *azel I azimuth/elevation angle {az,el} (rad)
  7. int ionoopt I ionospheric correction option (IONOOPT_???)
  8. double *ion O ionospheric delay (L1) (m)
  9. double *var O ionospheric delay (L1) variance (m^2)
  10. 返回类型:
  11. int O (1:ok,0:error)
Created with Raphaël 2.1.2ionocorrIONOOPT_BRDC?ionmodelendIONOOPT_TEC?iontecyesnoyes

ionocorr ionmodel iontec


tropcorr

  1. int int tropcorr(gtime_t time, const nav_t *nav, const double *pos,
  2. const double *azel, int tropopt, double *trp, double *var)
  1. 函数参数,7
  2. gtime_t time I time
  3. nav_t *nav I navigation data
  4. double *pos I receiver position {lat,lon,h} (rad|m)
  5. double *azel I azimuth/elevation angle {az,el} (rad)
  6. int tropopt I tropospheric correction option (TROPOPT_???)
  7. double *trp O tropospheric delay (m)
  8. double *var O tropospheric delay variance (m^2)
  9. 返回类型:
  10. int O (1:ok,0:error)
Created with Raphaël 2.1.2tropcorrtropmodelend

dops tropmodel


varerr

  1. double varerr(const prcopt_t *opt, double el, int sys)
  1. 函数参数,3
  2. prcopt_t *opt I processing options
  3. double el I elevation angle (rad)
  4. int sys I 所属的导航系统
  5. 返回类型:
  6. double O 导航系统伪距测量值的误差

testsnr

  1. int testsnr(int base, int freq, double el, double snr,
  2. const snrmask_t *mask)
  1. 函数参数,5
  2. int base I rover or base-station (0:rover,1:base station)
  3. int freq I frequency (0:L1,1:L2,2:L3,...)
  4. double el I elevation angle (rad)
  5. double snr I C/N0 (dBHz)
  6. snrmask_t *mask I SNR mask
  7. 返回类型:
  8. int O (1:masked,0:unmasked)
Created with Raphaël 2.1.2dopsmatmulmatinvend

dops matmul matinv


gettgd

  1. double gettgd(int sat, const nav_t *nav)
  1. 函数参数,2
  2. int sat I satellite number,从 1开始
  3. nav_t *nav I navigation data
  4. 返回类型:
  5. double O tgd parameter (m)


ionmodel

  1. double ionmodel(gtime_t t, const double *ion, const double *pos,
  2. const double *azel)
  1. 函数参数,4
  2. gtime_t t I time (gpst)
  3. double *ion I iono model parameters {a0,a1,a2,a3,b0,b1,b2,b3}
  4. double *pos I receiver position {lat,lon,h} (rad,m)
  5. double *azel I azimuth/elevation angle {az,el} (rad)
  6. 返回类型:
  7. double O ionospheric delay (L1) (m)

iontec

  1. int iontec(gtime_t time, const nav_t *nav, const double *pos,
  2. const double *azel, int opt, double *delay, double *var)
  1. 函数参数,3
  2. gtime_t time I time (gpst)
  3. nav_t *nav I navigation data
  4. double *pos I receiver position {lat,lon,h} (rad,m)
  5. double *azel I azimuth/elevation angle {az,el} (rad)
  6. int opt I model option
  7. bit0: 0:earth-fixed,1:sun-fixed
  8. bit1: 0:single-layer,1:modified single-layer
  9. double *delay O ionospheric delay (L1) (m)
  10. double *var O ionospheric dealy (L1) variance (m^2)
  11. 返回类型:
  12. int O (1:ok,0:error)
Created with Raphaël 2.1.2ionteciondelayend

iontec iondelay


iondelay

  1. int iondelay(gtime_t time, const tec_t *tec, const double *pos,
  2. const double *azel, int opt, double *delay, double *var)
  1. 函数参数,3
  2. gtime_t time I time (gpst)
  3. tec_t *tec I tec grid data
  4. double *pos I receiver position {lat,lon,h} (rad,m)
  5. double *azel I azimuth/elevation angle {az,el} (rad)
  6. int opt I model option
  7. bit0: 0:earth-fixed,1:sun-fixed
  8. bit1: 0:single-layer,1:modified single-layer
  9. double *delay O ionospheric delay (L1) (m)
  10. double *var O ionospheric dealy (L1) variance (m^2)
  11. 返回类型:
  12. int O (1:ok,0:error)
Created with Raphaël 2.1.2iondelayionpppinterptecend

iondelay ionppp interptec


ionppp

  1. double ionppp(const double *pos, const double *azel, double re,
  2. double hion, double *posp)
  1. 函数参数,5
  2. double *pos I receiver position {lat,lon,h} (rad,m)
  3. double *azel I azimuth/elevation angle {az,el} (rad)
  4. double re I earth radius (km)
  5. double hion I altitude of ionosphere (km)
  6. double *posp O pierce point position {lat,lon,h} (rad,m)
  7. 返回类型:
  8. double O 倾斜率

interptec

  1. int interptec(const tec_t *tec, int k, const double *posp, double *value,
  2. double *rms)
  1. 函数参数,5
  2. tec_t *tec I tec grid data
  3. int k I 高度方向上的序号,可以理解为电离层序号
  4. double *posp I pierce point position {lat,lon,h} (rad,m)
  5. double *value O 计算得到的刺穿点处的电子数总量(tecu)
  6. double *rms O 所计算的电子数总量的误差的标准差(tecu)
  7. 返回类型:
  8. int O (1:ok,0:error)

tropmodel

  1. double tropmodel(gtime_t time, const double *pos, const double *azel,
  2. double humi)
  1. 函数参数,4
  2. gtime_t time I time
  3. double *pos I receiver position {lat,lon,h} (rad,m)
  4. double *azel I azimuth/elevation angle {az,el} (rad)
  5. double humi I relative humidity
  6. 返回类型:
  7. double O tropospheric delay (m)

resdop

  1. int resdop(const obsd_t *obs, int n, const double *rs, const double *dts,
  2. const nav_t *nav, const double *rr, const double *x,
  3. const double *azel, const int *vsat, double *v, double *H)
  1. 函数参数,11个:
  2. obsd_t *obs I observation data
  3. int n I number of observation data
  4. double *rs I satellite positions and velocities,长度为6*n,{x,y,z,vx,vy,vz}(ecef)(m,m/s)
  5. double *dts I satellite clocks,长度为2*n {bias,drift} (s|s/s)
  6. nav_t *nav I navigation data
  7. double *rr I receiver positions and velocities,长度为6,{x,y,z,vx,vy,vz}(ecef)(m,m/s)
  8. double *x I 本次迭代开始之前的定速值
  9. double *azel I azimuth/elevation angle (rad)
  10. int *vsat I 表征卫星在定速时是否有效
  11. double *v O 定速方程的右端部分,速度残余
  12. double *H O 定速方程中的几何矩阵
  13. 返回类型:
  14. int O 定速时所使用的卫星数目
Created with Raphaël 2.1.2resdopecef2posxyz2enumatmulend

resdop ecef2pos xyz2enu matmul


添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注