Changeset 6400 in ntrip


Ignore:
Timestamp:
Dec 22, 2014, 11:26:18 AM (9 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/ephemeris.cpp

    r6390 r6400  
    1414#include "satObs.h"
    1515#include "pppInclude.h"
     16#include "pppModel.h"
    1617
    1718using namespace std;
     
    12851286  return rnxStr;
    12861287}
     1288
     1289// Constructor
     1290//////////////////////////////////////////////////////////////////////////////
     1291t_ephCompass::t_ephCompass(float rnxVersion, const QStringList& lines) {
     1292
     1293  const int nLines = 8;
     1294
     1295  _ok = false;
     1296
     1297  if (lines.size() != nLines) {
     1298    return;
     1299  }
     1300
     1301  // RINEX Format
     1302  // ------------
     1303  int fieldLen = 19;
     1304
     1305  int pos[4];
     1306  pos[0] = (rnxVersion <= 2.12) ?  3 :  4;
     1307  pos[1] = pos[0] + fieldLen;
     1308  pos[2] = pos[1] + fieldLen;
     1309  pos[3] = pos[2] + fieldLen;
     1310
     1311  double TOTs;
     1312  double TOEs;
     1313  double TOEw;
     1314
     1315  // Read eight lines
     1316  // ----------------
     1317  for (int iLine = 0; iLine < nLines; iLine++) {
     1318    QString line = lines[iLine];
     1319
     1320    if      ( iLine == 0 ) {
     1321      QTextStream in(line.left(pos[1]).toAscii());
     1322
     1323      int    year, month, day, hour, min;
     1324      double sec;
     1325     
     1326      QString prnStr;
     1327      in >> prnStr >> year >> month >> day >> hour >> min >> sec;
     1328      if (prnStr.at(0) == 'C') {
     1329        _prn.set('C', prnStr.mid(1).toInt());
     1330      }
     1331      else {
     1332        _prn.set('C', prnStr.toInt());
     1333      }
     1334
     1335      if      (year <  80) {
     1336        year += 2000;
     1337      }
     1338      else if (year < 100) {
     1339        year += 1900;
     1340      }
     1341
     1342      _TOC_bdt.set(year, month, day, hour, min, sec);
     1343
     1344      if ( readDbl(line, pos[1], fieldLen, _clock_bias     ) ||
     1345           readDbl(line, pos[2], fieldLen, _clock_drift    ) ||
     1346           readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
     1347        return;
     1348      }
     1349    }
     1350
     1351    else if      ( iLine == 1 ) {
     1352      double aode;
     1353      if ( readDbl(line, pos[0], fieldLen, aode    ) ||
     1354           readDbl(line, pos[1], fieldLen, _Crs    ) ||
     1355           readDbl(line, pos[2], fieldLen, _Delta_n) ||
     1356           readDbl(line, pos[3], fieldLen, _M0     ) ) {
     1357        return;
     1358      }
     1359      _AODE = int(aode);
     1360    }
     1361
     1362    else if ( iLine == 2 ) {
     1363      if ( readDbl(line, pos[0], fieldLen, _Cuc   ) ||
     1364           readDbl(line, pos[1], fieldLen, _e     ) ||
     1365           readDbl(line, pos[2], fieldLen, _Cus   ) ||
     1366           readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
     1367        return;
     1368      }
     1369    }
     1370
     1371    else if ( iLine == 3 ) {
     1372      if ( readDbl(line, pos[0], fieldLen, TOEs   )  ||
     1373           readDbl(line, pos[1], fieldLen, _Cic   )  ||
     1374           readDbl(line, pos[2], fieldLen, _OMEGA0)  ||
     1375           readDbl(line, pos[3], fieldLen, _Cis   ) ) {
     1376        return;
     1377      }
     1378    }
     1379
     1380    else if ( iLine == 4 ) {
     1381      if ( readDbl(line, pos[0], fieldLen, _i0      ) ||
     1382           readDbl(line, pos[1], fieldLen, _Crc     ) ||
     1383           readDbl(line, pos[2], fieldLen, _omega   ) ||
     1384           readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
     1385        return;
     1386      }
     1387    }
     1388
     1389    else if ( iLine == 5 ) {
     1390      if ( readDbl(line, pos[0], fieldLen, _IDOT    ) ||
     1391           readDbl(line, pos[2], fieldLen, TOEw)    ) {
     1392        return;
     1393      }
     1394    }
     1395
     1396    else if ( iLine == 6 ) {
     1397      double SatH1;
     1398      if ( readDbl(line, pos[1], fieldLen, SatH1) ||
     1399           readDbl(line, pos[2], fieldLen, _TGD1) ||
     1400           readDbl(line, pos[3], fieldLen, _TGD2) ) {
     1401        return;
     1402      }
     1403      _SatH1 = int(SatH1);
     1404    }
     1405
     1406    else if ( iLine == 7 ) {
     1407      double aodc;
     1408      if ( readDbl(line, pos[0], fieldLen, TOTs) ||
     1409           readDbl(line, pos[1], fieldLen, aodc) ) {
     1410        return;
     1411      }
     1412      if (TOTs == 0.9999e9) {  // 0.9999e9 means not known (RINEX standard)
     1413        TOTs = TOEs;
     1414      }
     1415      _AODC = int(aodc);
     1416    }
     1417  }
     1418
     1419  TOEw += 1356;  // BDT -> GPS week number
     1420  _TOE_bdt.set(TOEw, TOEs);
     1421
     1422  // GPS->BDT
     1423  // --------
     1424  _TOC = _TOC_bdt + 14.0;
     1425  _TOE = _TOE_bdt + 14.0;
     1426
     1427  // remark: actually should be computed from second_tot
     1428  //         but it seems to be unreliable in RINEX files
     1429  _TOT = _TOC;
     1430
     1431  _ok = true;
     1432}
     1433
     1434// Constructor
     1435//////////////////////////////////////////////////////////////////////////////
     1436t_irc t_ephCompass::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
     1437
     1438  static const double gmCompass    = 398.6004418e12;
     1439  static const double omegaCompass = 7292115.0000e-11;
     1440
     1441  xc[0] = xc[1] = xc[2] = xc[3] = 0.0;
     1442  vv[0] = vv[1] = vv[2] = 0.0;
     1443
     1444  bncTime tt(GPSweek, GPSweeks);
     1445
     1446  if (_sqrt_A == 0) {
     1447    return failure;
     1448  }
     1449  double a0 = _sqrt_A * _sqrt_A;
     1450
     1451  double n0 = sqrt(gmCompass/(a0*a0*a0));
     1452  double tk = tt - _TOE;
     1453  double n  = n0 + _Delta_n;
     1454  double M  = _M0 + n*tk;
     1455  double E  = M;
     1456  double E_last;
     1457  int    nLoop = 0;
     1458  do {
     1459    E_last = E;
     1460    E = M + _e*sin(E);
     1461
     1462    if (++nLoop == 100) {
     1463      return failure;
     1464    }
     1465  } while ( fabs(E-E_last)*a0 > 0.001 );
     1466
     1467  double v      = atan2(sqrt(1-_e*_e) * sin(E), cos(E) - _e);
     1468  double u0     = v + _omega;
     1469  double sin2u0 = sin(2*u0);
     1470  double cos2u0 = cos(2*u0);
     1471  double r      = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
     1472  double i      = _i0 + _IDOT*tk     + _Cic*cos2u0 + _Cis*sin2u0;
     1473  double u      = u0                 + _Cuc*cos2u0 + _Cus*sin2u0;
     1474  double xp     = r*cos(u);
     1475  double yp     = r*sin(u);
     1476  double toesec = (_TOE.gpssec() - 14.0);
     1477
     1478  double sinom = 0;
     1479  double cosom = 0;
     1480  double sini  = 0;
     1481  double cosi  = 0;
     1482 
     1483  const double iMaxGEO = 10.0 / 180.0 * M_PI;
     1484
     1485  // MEO/IGSO satellite
     1486  // ------------------
     1487  if (_i0 > iMaxGEO) {
     1488    double OM = _OMEGA0 + (_OMEGADOT - omegaCompass)*tk - omegaCompass*toesec;
     1489
     1490    sinom = sin(OM);
     1491    cosom = cos(OM);
     1492    sini  = sin(i);
     1493    cosi  = cos(i);
     1494
     1495    xc[0] = xp*cosom - yp*cosi*sinom;
     1496    xc[1] = xp*sinom + yp*cosi*cosom;
     1497    xc[2] = yp*sini;                 
     1498  }
     1499
     1500  // GEO satellite
     1501  // -------------
     1502  else {
     1503    double OM    = _OMEGA0 + _OMEGADOT*tk - omegaCompass*toesec;
     1504    double ll    = omegaCompass*tk;
     1505
     1506    sinom = sin(OM);
     1507    cosom = cos(OM);
     1508    sini  = sin(i);
     1509    cosi  = cos(i);
     1510
     1511    double xx = xp*cosom - yp*cosi*sinom;
     1512    double yy = xp*sinom + yp*cosi*cosom;
     1513    double zz = yp*sini;                 
     1514
     1515    Matrix R1 = BNC_PPP::t_astro::rotX(-5.0 / 180.0 * M_PI);
     1516    Matrix R2 = BNC_PPP::t_astro::rotZ(ll);
     1517
     1518    ColumnVector X1(3); X1 << xx << yy << zz;
     1519    ColumnVector X2 = R2*R1*X1;
     1520
     1521    xc[0] = X2(1);
     1522    xc[1] = X2(2);
     1523    xc[2] = X2(3);
     1524  }
     1525 
     1526  double tc = tt - _TOC;
     1527  xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc
     1528          - 4.442807633e-10 * _e * sqrt(a0) *sin(E);
     1529
     1530  // Velocity
     1531  // --------
     1532  double tanv2 = tan(v/2);
     1533  double dEdM  = 1 / (1 - _e*cos(E));
     1534  double dotv  = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2)
     1535                 / (1 + tanv2*tanv2) * dEdM * n;
     1536  double dotu  = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
     1537  double dotom = _OMEGADOT - t_CST::omega;
     1538  double doti  = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
     1539  double dotr  = a0 * _e*sin(E) * dEdM * n
     1540                + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
     1541  double dotx  = dotr*cos(u) - r*sin(u)*dotu;
     1542  double doty  = dotr*sin(u) + r*cos(u)*dotu;
     1543
     1544  vv[0]  = cosom  *dotx  - cosi*sinom   *doty   // dX / dr
     1545        - xp*sinom*dotom - yp*cosi*cosom*dotom   // dX / dOMEGA
     1546                         + yp*sini*sinom*doti;   // dX / di
     1547 
     1548  vv[1]  = sinom  *dotx  + cosi*cosom   *doty
     1549        + xp*cosom*dotom - yp*cosi*sinom*dotom
     1550                         - yp*sini*cosom*doti;
     1551
     1552  vv[2]  = sini   *doty  + yp*cosi      *doti;
     1553
     1554  // dotC  = _clock_drift + _clock_driftrate*tc
     1555  //       - 4.442807633e-10*_e*sqrt(a0)*cos(E) * dEdM * n;
     1556
     1557  return success;
     1558}
     1559
     1560// RINEX Format String
     1561//////////////////////////////////////////////////////////////////////////////
     1562QString t_ephCompass::toString(double version) const {
     1563
     1564  QString rnxStr = rinexDateStr(_TOC_bdt, _prn, version);
     1565
     1566  QTextStream out(&rnxStr);
     1567
     1568  out << QString("%1%2%3\n")
     1569    .arg(_clock_bias,      19, 'e', 12)
     1570    .arg(_clock_drift,     19, 'e', 12)
     1571    .arg(_clock_driftrate, 19, 'e', 12);
     1572
     1573  QString fmt = version < 3.0 ? "   %1%2%3%4\n" : "    %1%2%3%4\n";
     1574
     1575  out << QString(fmt)
     1576    .arg(double(_AODE), 19, 'e', 12)
     1577    .arg(_Crs,          19, 'e', 12)
     1578    .arg(_Delta_n,      19, 'e', 12)
     1579    .arg(_M0,           19, 'e', 12);
     1580
     1581  out << QString(fmt)
     1582    .arg(_Cuc,    19, 'e', 12)
     1583    .arg(_e,      19, 'e', 12)
     1584    .arg(_Cus,    19, 'e', 12)
     1585    .arg(_sqrt_A, 19, 'e', 12);
     1586
     1587  out << QString(fmt)
     1588    .arg(_TOE_bdt.gpssec(), 19, 'e', 12)
     1589    .arg(_Cic,              19, 'e', 12)
     1590    .arg(_OMEGA0,           19, 'e', 12)
     1591    .arg(_Cis,              19, 'e', 12);
     1592
     1593  out << QString(fmt)
     1594    .arg(_i0,       19, 'e', 12)
     1595    .arg(_Crc,      19, 'e', 12)
     1596    .arg(_omega,    19, 'e', 12)
     1597    .arg(_OMEGADOT, 19, 'e', 12);
     1598
     1599  out << QString(fmt)
     1600    .arg(_IDOT,                   19, 'e', 12)
     1601    .arg(0.0,                     19, 'e', 12)
     1602    .arg(double(_TOE_bdt.gpsw()), 19, 'e', 12)
     1603    .arg(0.0,                     19, 'e', 12);
     1604
     1605  out << QString(fmt)
     1606    .arg(0.0,            19, 'e', 12)
     1607    .arg(double(_SatH1), 19, 'e', 12)
     1608    .arg(_TGD1,          19, 'e', 12)
     1609    .arg(_TGD2,          19, 'e', 12);
     1610
     1611  out << QString(fmt)
     1612    .arg(_TOE_bdt.gpssec(), 19, 'e', 12)
     1613    .arg(double(_AODC),     19, QChar(' '));
     1614
     1615  return rnxStr;
     1616}
     1617
  • trunk/BNC/src/ephemeris.h

    r6390 r6400  
    1919class t_eph {
    2020 public:
    21   enum e_type {unknown, GPS, QZSS, GLONASS, Galileo, SBAS};
     21  enum e_type {unknown, GPS, QZSS, GLONASS, Galileo, SBAS, Compass};
    2222
    2323  t_eph();
     
    237237};
    238238
     239class t_ephCompass : public t_eph {
     240 friend class t_ephEncoder;
     241 public:
     242  t_ephCompass() {}
     243  t_ephCompass(float rnxVersion, const QStringList& lines);
     244  virtual ~t_ephCompass() {}
     245
     246  // void set(const compassephemeris* ee);
     247  virtual e_type  type() const {return t_eph::Compass;}
     248  virtual int     IOD() const {return _AODC;}
     249  virtual QString toString(double version) const;
     250
     251 private:
     252  virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
     253
     254  bncTime _TOT;
     255  bncTime _TOE;
     256  bncTime _TOC_bdt;
     257  bncTime _TOE_bdt;
     258  int     _AODE;
     259  int     _AODC;
     260  double  _clock_bias;       //  [s]   
     261  double  _clock_drift;      //  [s/s] 
     262  double  _clock_driftrate;  //  [s/s^2]
     263  double  _Crs;              //  [m]   
     264  double  _Delta_n;          //  [rad/s]
     265  double  _M0;               //  [rad] 
     266  double  _Cuc;              //  [rad] 
     267  double  _e;                //         
     268  double  _Cus;              //  [rad] 
     269  double  _sqrt_A;           //  [m^0.5]
     270  double  _Cic;              //  [rad] 
     271  double  _OMEGA0;           //  [rad] 
     272  double  _Cis;              //  [rad] 
     273  double  _i0;               //  [rad] 
     274  double  _Crc;              //  [m]   
     275  double  _omega;            //  [rad] 
     276  double  _OMEGADOT;         //  [rad/s]
     277  double  _IDOT;             //  [rad/s]
     278  double  _TGD1;             //  [s]   
     279  double  _TGD2;             //  [s]   
     280  int     _SatH1;            //
     281};
     282
    239283#endif
  • trunk/BNC/src/pppModel.h

    r6268 r6400  
    1313  static ColumnVector Sun(double Mjd_TT);
    1414  static ColumnVector Moon(double Mjd_TT);
     15  static Matrix rotX(double Angle);
     16  static Matrix rotY(double Angle);
     17  static Matrix rotZ(double Angle);
    1518
    1619 private:
     
    1821  static const double RHO_SEC;
    1922  static const double MJD_J2000;
    20 
    21   static Matrix rotX(double Angle);
    22   static Matrix rotY(double Angle);
    23   static Matrix rotZ(double Angle);
    2423
    2524  static double GMST(double Mjd_UT1);
Note: See TracChangeset for help on using the changeset viewer.