diff --git a/src/ephemeris.c b/src/ephemeris.c index 5c37c3ec7f762a496c165cc9080636c720424040..75cdec52da4cb7ea7cc73c08895f3aacd91759d2 100644 --- a/src/ephemeris.c +++ b/src/ephemeris.c @@ -578,14 +578,16 @@ static int satpos_sbas(gtime_t time, gtime_t teph, int sat, const nav_t *nav, //DEBUG /*if (satsys(sat,NULL)!=SYS_GAL && satsys(sat,NULL)!=SYS_SBS) printf("no sbas correction (i>=nav->sbssat.nsat || sbs->lcorr.iode < 0)\n");//*/ - //ephpos(time,teph,sat,nav,-1,rs,dts,var,svh); - //*svh=-1; + ephpos(time,teph,sat,nav,-1,rs,dts,var,svh); + *svh=-1; return 0; } /* satellite postion and clock by broadcast ephemeris */ //printf("lcorr.iode=%3d ",sbs->lcorr.iode); if (!ephpos(time,teph,sat,nav,sbs->lcorr.iode,rs,dts,var,svh)){ //printf("not found\n"); + ephpos(time,teph,sat,nav,-1,rs,dts,var,svh); + *svh=-1; return 0; } @@ -729,6 +731,9 @@ extern int satpos(gtime_t time, gtime_t teph, int sat, int ephopt, if (!peph2pos(time,sat,nav,1,rs,dts,var)) break; else return 1; case EPHOPT_LEX : if (!lexeph2pos(time,sat,nav,rs,dts,var)) break; else return 1; + //JV{ + case EPHOPT_SBAS2 : return satpos_sbas(time,teph,sat,nav, rs,dts,var,svh); + //}JV } *svh=-1; return 0; @@ -795,10 +800,19 @@ extern void satposs(gtime_t teph, const obsd_t *obs, int n, const nav_t *nav, /* satellite position and clock at transmission time */ if (!satpos(time[i],teph,obs[i].sat,ephopt,nav,rs+i*6,dts+i*2,var+i, - svh+i)) { + svh+i)) { trace(3,"no ephemeris %s sat=%2d\n",time_str(time[i],3),obs[i].sat); - continue; + // JV{ + if (ephopt == EPHOPT_SBAS2 /*&& svh[i] == -1*/) // complement SBAS with BRDC eph + { + //printf("satposs: in EPHOPT_SBAS2 wrong satpos. svh: %d. rs=%f, %f, %f. Reseting svh to 0 (ok).\n",svh[i],rs[i*6],rs[i*6+1],rs[i*6+2]); + svh[i] = 0; + } + else + //}JV + continue; } + /* if no precise clock available, use broadcast clock instead */ if (dts[i*2]==0.0) { if (!ephclk(time[i],teph,obs[i].sat,nav,dts+i*2)) continue; diff --git a/src/pntpos.c b/src/pntpos.c index 2bb27bfeb2e9dbfbc9015c7945fc1eb6124091f0..3181d4465c7358204b8d790868f9a789a6038b3b 100644 --- a/src/pntpos.c +++ b/src/pntpos.c @@ -175,6 +175,17 @@ extern int ionocorr(gtime_t time, const nav_t *nav, int sat, const double *pos, if (ionoopt==IONOOPT_SBAS) { return sbsioncorr(time,nav,pos,azel,ion,var); } + //JV{ + /* sbas ionosphere model if available, otherwise broadcast model*/ + if (ionoopt==IONOOPT_SBAS2) { + if (!sbsioncorr(time,nav,pos,azel,ion,var)) + { + *ion=ionmodel(time,nav->ion_gps,pos,azel); + *var=SQR(*ion*ERR_BRDCI); + } + return 1; + } + //}JV /* ionex tec model */ if (ionoopt==IONOOPT_TEC) { return iontec(time,nav,pos,azel,1,ion,var); @@ -677,17 +688,71 @@ extern int pntpos(const obsd_t *obs, int n, const nav_t *nav, opt_.ionoopt=IONOOPT_BRDC; opt_.tropopt=TROPOPT_SAAS; } + + // JV{ + // EPHOPT_SBAS3: try EPHOPT_SBAS if not enough sats EPHOPT_SBAS2 (SBAS + BRDC) + // EPHOPT_SBAS4: try EPHOPT_SBAS if not enough sats EPHOPT_BRDC + if (opt->sateph == EPHOPT_SBAS3 || opt->sateph == EPHOPT_SBAS4) + opt_.sateph = EPHOPT_SBAS; + // IONOOPT_SBAS3: try IONOOPT_SBAS if not enough sats IONOOPT_SBAS2 (SBAS + BRDC) + // IONOOPT_SBAS4: try IONOOPT_SBAS if not enough sats IONOOPT_BRDC + if (opt->ionoopt == IONOOPT_SBAS3 || opt->ionoopt == IONOOPT_SBAS4) + opt_.ionoopt = IONOOPT_SBAS; + //}JV + /* satellite positons, velocities and clocks */ satposs(sol->time,obs,n,nav,opt_.sateph,rs,dts,var,svh); - + /* estimate receiver position with pseudorange */ - stat=estpos(obs,n,rs,dts,var,svh,nav,&opt_,ssat,sol,azel_,vsat,resp,msg,n>=6&&opt->posopt[4]);// check chi-square if afterwards RAIM can be called - + stat=estpos(obs,n,rs,dts,var,svh,nav,&opt_,ssat,sol,azel_,vsat,resp,msg,n>=6&&opt_.posopt[4]);// JV: check chi-square if afterwards RAIM can be called + /* raim fde */ - if (/*!stat&&*/n>=6&&opt->posopt[4]) { + if (/*!stat&&*/n>=6&&opt_.posopt[4]) { stat=raim_fde(obs,n,rs,dts,var,svh,nav,&opt_,ssat,sol,azel_,vsat,resp,msg); } + //JV{ + // unsuccessfull, try alternative (if EPHOPT_SBAS3, EPHOPT_SBAS4, IONOOPT_SBAS3, IONOOPT_SBAS4) + if (!stat && + (opt->sateph == EPHOPT_SBAS3 || opt->sateph == EPHOPT_SBAS4 || + opt->ionoopt == IONOOPT_SBAS3 || opt->ionoopt == IONOOPT_SBAS4) ) + { + //printf("pntpos unsuscessful\n"); + if (opt->sateph == EPHOPT_SBAS3) + { + //printf("\tEPHOPT_SBAS3 option trying now EPHOPT_SBAS2...\n"); + opt_.sateph = EPHOPT_SBAS2; + } + if (opt->sateph == EPHOPT_SBAS4) + { + //printf("\tEPHOPT_SBAS4 option trying now EPHOPT_BRDC...\n"); + opt_.sateph = EPHOPT_BRDC; + } + + if (opt->ionoopt == IONOOPT_SBAS3) + { + //printf("\tIONOOPT_SBAS3 option trying now IONOOPT_SBAS2...\n"); + opt_.ionoopt = IONOOPT_SBAS2; + } + if (opt->ionoopt == IONOOPT_SBAS4) + { + //printf("\tIONOOPT_SBAS4 option trying now IONOOPT_BRDC...\n"); + opt_.ionoopt = IONOOPT_BRDC; + } + + /* satellite positons, velocities and clocks */ + satposs(sol->time,obs,n,nav,opt_.sateph,rs,dts,var,svh); + + /* estimate receiver position with pseudorange */ + stat=estpos(obs,n,rs,dts,var,svh,nav,&opt_,ssat,sol,azel_,vsat,resp,msg,n>=6&&opt_.posopt[4]);// check chi-square if afterwards RAIM can be called + + /* raim fde */ + if (/*!stat&&*/n>=6&&opt_.posopt[4]) { + stat=raim_fde(obs,n,rs,dts,var,svh,nav,&opt_,ssat,sol,azel_,vsat,resp,msg); + } + } + //}JV + /* estimate receiver velocity with doppler */ if (stat) estvel(obs,n,rs,dts,nav,&opt_,sol,azel_,vsat); diff --git a/src/rtklib.h b/src/rtklib.h index e28fdac31028e939f79e108ae3b012d48964a63b..0a60b2b494bee90d86de5f6ef74a52ec56f52ab3 100644 --- a/src/rtklib.h +++ b/src/rtklib.h @@ -385,6 +385,11 @@ extern "C" { #define IONOOPT_QZS 6 /* ionosphere option: QZSS broadcast model */ #define IONOOPT_LEX 7 /* ionosphere option: QZSS LEX ionospehre */ #define IONOOPT_STEC 8 /* ionosphere option: SLANT TEC model */ +//JV{ +#define IONOOPT_SBAS2 9 /* ionosphere option: broadcast + SBAS (if no SBAS corr take BRDC correction)*/ +#define IONOOPT_SBAS3 10 /* ionosphere option: broadcast + SBAS (IONOOPT_SBAS if possible, otherwise IONOOPT_SBAS2)*/ +#define IONOOPT_SBAS4 11 /* ionosphere option: broadcast + SBAS (IONOOPT_SBAS if possible, otherwise IONOOPT_BRDC)*/ +//}JV #define TROPOPT_OFF 0 /* troposphere option: correction off */ #define TROPOPT_SAAS 1 /* troposphere option: Saastamoinen model */ @@ -399,6 +404,11 @@ extern "C" { #define EPHOPT_SSRAPC 3 /* ephemeris option: broadcast + SSR_APC */ #define EPHOPT_SSRCOM 4 /* ephemeris option: broadcast + SSR_COM */ #define EPHOPT_LEX 5 /* ephemeris option: QZSS LEX ephemeris */ +//JV{ +#define EPHOPT_SBAS2 6 /* ephemeris option: broadcast + SBAS (sats with SBAS corr and sats with BRDC eph)*/ +#define EPHOPT_SBAS3 7 /* ephemeris option: broadcast + SBAS (EPHOPT_SBAS if possible, otherwise EPHOPT_SBAS2)*/ +#define EPHOPT_SBAS4 8 /* ephemeris option: broadcast + SBAS (EPHOPT_SBAS if possible, otherwise EPHOPT_BRDC)*/ +//}JV #define WEIGHTOPT_ELEVATION 0 /* weighting option: elevation */ #define WEIGHTOPT_SNR 1 /* weighting option: snr */