procpo
目录
inputobs:nobs=inputobs(obs,rtk.sol.stat,popt)
satsys:satsys(obs[i].sat,NULL)
/* process positioning -------------------------------------------------------*/
static void procpos(FILE *fp, const prcopt_t *popt, const solopt_t *sopt,
int mode)
rtkinit:rtkinit(&rtk,popt);
函数作用:初始化rtk_t rtk
rtk_t结构体如下:
typedef struct { /* RTK control/result type */
sol_t sol; /* RTK solution 定位解算内容*/
double rb[6]; /* base position/velocity (ecef) (m|m/s) 基站位置、速度*/
int nx,na; /* number of float states/fixed states 流动站或者固定站数量*/
double tt; /* time difference between current and previous (s) 当前历元和上一历元的时间之差*/
double *x, *P; /* float states and their covariance流动站和他们的变化量 */
double *xa,*Pa; /* fixed states and their covariance基准站和他们的变化量 */
int nfix; /* number of continuous fixes of ambiguity */
ambc_t ambc[MAXSAT]; /* ambibuity control 模糊度控制*/
ssat_t ssat[MAXSAT]; /* satellite status 卫星状态 */
int neb; /* bytes in error message buffer 错误信息缓冲区的字节*/
char errbuf[MAXERRMSG]; /* error message buffer错误信息缓冲区 */
prcopt_t opt; /* processing options 配置文件中setting选项*/
} rtk_t;
其中,sol_t结构体如下:
typedef struct { /* solution type */
gtime_t time; /* time (GPST)时间 */
double rr[6]; /* position/velocity (m|m/s)接收机位置/速度 */
/* {x,y,z,vx,vy,vz} or {e,n,u,ve,vn,vu} */
float qr[6]; /* position variance/covariance (m^2) 接收机位置变化量*/
/* {c_xx,c_yy,c_zz,c_xy,c_yz,c_zx} or */
/* {c_ee,c_nn,c_uu,c_en,c_nu,c_ue} */
float qv[6]; /* velocity variance/covariance (m^2/s^2) 速度变化量*/
double dtr[6]; /* receiver clock bias to time systems (s)对于时间系统的接收机钟差 */
uint8_t type; /* type (0:xyz-ecef,1:enu-baseline) 站心坐标系或者空间直角坐标系*/
uint8_t stat; /* solution status (SOLQ_???) */
uint8_t ns; /* number of valid satellites 有效卫星数*/
float age; /* age of differential (s) */
float ratio; /* AR ratio factor for valiation */
float thres; /* AR ratio threshold for valiation */
} sol_t;
stat为定位方法:
#define SOLQ_NONE 0 /* solution status: no solution */
#define SOLQ_FIX 1 /* solution status: fix */
#define SOLQ_FLOAT 2 /* solution status: float */
#define SOLQ_SBAS 3 /* solution status: SBAS */
#define SOLQ_DGPS 4 /* solution status: DGPS/DGNSS */
#define SOLQ_SINGLE 5 /* solution status: single */
#define SOLQ_PPP 6 /* solution status: PPP */
#define SOLQ_DR 7 /* solution status: dead reconing */
#define MAXSOLQ 7 /* max number of solution status */
inputobs:nobs=inputobs(obs,rtk.sol.stat,popt)
while ((nobs=inputobs(obs,rtk.sol.stat,popt))>=0) {
//对每个历元的观测数据进行处理
}
函数作用:获取当前历元观测的卫星数nobs以及当前历元各卫星的观测数据记录obs[MAXOBS*2]
函数设计的全局变量如下:
static int iobsu =0; /* current rover observation data index流动站当前历元索引 */
static int iobsr =0; /* current reference observation data index基准站当前历元索引 */
static int isbs =0; /* current sbas message index SBAS信息索引*/
static int revs =0; /* analysis direction (0:forward,1:backward) 前向/反向滤波*/
static int aborts=0; /* abort status */
satsys:satsys(obs[i].sat,NULL)
函数作用:排除不可用的卫星。
问题:n是什么?
for (i=n=0;i<nobs;i++) {
if ((satsys(obs[i].sat,NULL)&popt->navsys)&&
popt->exsats[obs[i].sat-1]!=1) obs[n++]=obs[i];
}
if (n<=0) continue;
corr_phase_bias_ssr: corr_phase_bias_ssr(obs,n,&navs);
函数作用:载波相位偏差纠正?
/* carrier-phase bias correction */
if (!strstr(popt->pppopt,"-ENA_FCB")) {//载波相位偏差纠正
corr_phase_bias_ssr(obs,n,&navs);
}
rtkpos:
if (!rtkpos(&rtk,obs,n,&navs)) continue;
outsol:
函数作用:将定位结果保存到.pos文件中
outsol——outsols——
if (!solstatic) {
outsol(fp,&rtk.sol,rtk.rb,sopt);//将定位结果保存到.pos文件中
}
* output solution body --------------------------------------------------------
* output solution body to file
* args : FILE *fp I output file pointer
* sol_t *sol I solution
* double *rb I base station position {x,y,z} (ecef) (m)
* solopt_t *opt I solution options
* return : none
*-----------------------------------------------------------------------------*/
extern void outsol(FILE *fp, const sol_t *sol, const double *rb,
const solopt_t *opt)
{
uint8_t buff[MAXSOLMSG+1];
int n;
trace(3,"outsol :\n");
if ((n=outsols(buff,sol,rb,opt))>0) {
fwrite(buff,n,1,fp);
}
}
/* output solution body --------------------------------------------------------
* output solution body to buffer
* args : uint8_t *buff IO output buffer
* sol_t *sol I solution
* double *rb I base station position {x,y,z} (ecef) (m)
* solopt_t *opt I solution options
* return : number of output bytes
*-----------------------------------------------------------------------------*/
extern int outsols(uint8_t *buff, const sol_t *sol, const double *rb,
const solopt_t *opt)
{
gtime_t time,ts={0};
double gpst;
int week,timeu;
const char *sep=opt2sep(opt);
char s[64];
uint8_t *p=buff;
trace(3,"outsols :\n");
/* suppress output if std is over opt->maxsolstd */
if (opt->maxsolstd>0.0&&sol_std(sol)>opt->maxsolstd) {
return 0;
}
if (opt->posf==SOLF_NMEA) {
if (opt->nmeaintv[0]<0.0) return 0;
if (!screent(sol->time,ts,ts,opt->nmeaintv[0])) return 0;
}
if (sol->stat<=SOLQ_NONE||(opt->posf==SOLF_ENU&&norm(rb,3)<=0.0)) {
return 0;
}
timeu=opt->timeu<0?0:(opt->timeu>20?20:opt->timeu);
time=sol->time;
if (opt->times>=TIMES_UTC) time=gpst2utc(time);
if (opt->times==TIMES_JST) time=timeadd(time,9*3600.0);
if (opt->timef) time2str(time,s,timeu);
else {
gpst=time2gpst(time,&week);
if (86400*7-gpst<0.5/pow(10.0,timeu)) {
week++;
gpst=0.0;
}
sprintf(s,"%4d%.16s%*.*f",week,sep,6+(timeu<=0?0:timeu+1),timeu,gpst);
}
switch (opt->posf) {
case SOLF_LLH: p+=outpos (p,s,sol,opt); break;
case SOLF_XYZ: p+=outecef(p,s,sol,opt); break;
case SOLF_ENU: p+=outenu(p,s,sol,rb,opt); break;
case SOLF_NMEA: p+=outnmea_rmc(p,sol);
p+=outnmea_gga(p,sol); break;
}
return p-buff;
}