Changeset 2221 in ntrip


Ignore:
Timestamp:
Jan 12, 2010, 8:36:29 AM (14 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
5 edited

Legend:

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

    r1239 r2221  
    55
    66#include "ephemeris.h"
     7#include "bncutils.h"
    78#include "timeutils.h"
    89
     
    270271  out << endl;
    271272}
     273
     274// Derivative of the state vector using a simple force model (static)
     275////////////////////////////////////////////////////////////////////////////
     276ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector& xv) {
     277
     278  // State vector components
     279  // -----------------------
     280  ColumnVector rr = xv.rows(1,3);
     281  ColumnVector vv = xv.rows(4,6);
     282
     283  // Acceleration
     284  // ------------
     285  static const double GM    = 398.60044e12;
     286  static const double AE    = 6378136.0;
     287  static const double OMEGA = 7292115.e-11;
     288  static const double C20   = -1082.63e-6;
     289
     290  double rho = rr.norm_Frobenius();
     291  double t1  = -GM/(rho*rho*rho);
     292  double t2  = 3.0/2.0 * C20 * (GM*AE*AE) / (rho*rho*rho*rho*rho);
     293  double t3  = OMEGA * OMEGA;
     294  double t4  = 2.0 * OMEGA;
     295  double z2  = rr(3) * rr(3);
     296
     297  // Vector of derivatives
     298  // ---------------------
     299  ColumnVector va(6);
     300  va(1) = vv(1);
     301  va(2) = vv(2);
     302  va(3) = vv(3);
     303  va(4) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(1) + t4*vv(2);
     304  va(5) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(2) - t4*vv(1);
     305  va(6) = (t1 + t2*(3.0-5.0*z2/(rho*rho))     ) * rr(3);
     306
     307  return va;
     308}
     309
     310// Compute Glonass Satellite Position (virtual)
     311////////////////////////////////////////////////////////////////////////////
     312void t_ephGlo::position(int GPSweek, double GPSweeks,
     313                        double* xc, double* vv) const {
     314
     315  static const double secPerWeek  = 7 * 86400.0;
     316  static const double nominalStep = 10.0;
     317
     318  memset(xc, 0, 4*sizeof(double));
     319  memset(vv, 0, 3*sizeof(double));
     320
     321  double dtPos = GPSweeks - _tt;
     322  if (GPSweek != _GPSweek) { 
     323    dtPos += (GPSweek - _GPSweek) * secPerWeek;
     324  }
     325
     326  int nSteps  = int(fabs(dtPos) / nominalStep) + 1;
     327  double step = dtPos / nSteps;
     328
     329  for (int ii = 1; ii <= nSteps; ii++) {
     330    _xv = rungeKutta4(_tt, _xv, step, glo_deriv);
     331    _tt += step;
     332  }
     333
     334  // Position and Velocity
     335  // ---------------------
     336  xc[0] = _xv(1);
     337  xc[1] = _xv(2);
     338  xc[2] = _xv(3);
     339
     340  vv[0] = _xv(4);
     341  vv[1] = _xv(5);
     342  vv[2] = _xv(6);
     343
     344  // Clock Correction
     345  // ----------------
     346  double dtClk = GPSweeks - _GPSweeks;
     347  if (GPSweek != _GPSweek) { 
     348    dtClk += (GPSweek - _GPSweek) * secPerWeek;
     349  }
     350  xc[3] = -_tau + _gamma * dtClk;
     351}
     352
     353// IOD of Glonass Ephemeris (virtual)
     354////////////////////////////////////////////////////////////////////////////
     355int t_ephGlo::IOD() const {
     356
     357  bool old = false;
     358
     359  if (old) { // 5 LSBs of iod are equal to 5 LSBs of tb
     360    unsigned int tb  = int(fmod(_GPSweeks,86400.0)); //sec of day
     361    const int shift = sizeof(tb) * 8 - 5;
     362    unsigned int iod = tb << shift;
     363    return (iod >> shift);
     364  }
     365  else     { 
     366    return int(fmod(_tki, 3600)) / 30;
     367  }
     368}
     369
     370// Print Glonass Ephemeris (virtual)
     371////////////////////////////////////////////////////////////////////////////
     372void t_ephGlo::print(std::ostream& out) const {
     373
     374}
     375
     376// Set Glonass Ephemeris
     377////////////////////////////////////////////////////////////////////////////
     378void t_ephGlo::set(const glonassephemeris* ee) {
     379
     380}
  • trunk/BNC/RTCM3/ephemeris.h

    r2040 r2221  
    11#ifndef EPHEMERIS_H
    22#define EPHEMERIS_H
     3
     4#include <newmat.h>
    35
    46#include <stdio.h>
     
    1921
    2022  virtual void position(int GPSweek, double GPSweeks,
    21                         double* xc,
    22                         double* vv) const = 0;
     23                        double* xc,
     24                        double* vv) const = 0;
    2325
    2426  void position(int GPSweek, double GPSweeks,
    25                 double& xx, double& yy, double& zz, double& cc) const {
     27                double& xx, double& yy, double& zz, double& cc) const {
    2628    double tmp_xx[4];
    2729    double tmp_vv[4];
     
    4951 public:
    5052  t_ephGPS() { }
    51   ~t_ephGPS() {}
     53  virtual ~t_ephGPS() {}
    5254  double TOC() const {return _TOC;}
    5355
     
    5557
    5658  void set(int    prn,
    57            int    GPSWeek,
    58            double toc, double toe, double tot,
    59            double IODE, double IODC,
    60            double clock_bias, double clock_drift, double clock_driftrate,
    61            double OMEGA0, double OMEGADOT,
    62            double i0,     double IDOT,
    63            double omega,
    64            double M0, double Delta_n,
    65            double sqrt_A,
    66            double e,
    67            double Crc, double Crs,
    68            double Cic, double Cis,
    69            double Cuc, double Cus,
    70            double TGD,
    71            int    health);
     59           int    GPSWeek,
     60           double toc, double toe, double tot,
     61           double IODE, double IODC,
     62           double clock_bias, double clock_drift, double clock_driftrate,
     63           double OMEGA0, double OMEGADOT,
     64           double i0,     double IDOT,
     65           double omega,
     66           double M0, double Delta_n,
     67           double sqrt_A,
     68           double e,
     69           double Crc, double Crs,
     70           double Cic, double Cis,
     71           double Cuc, double Cus,
     72           double TGD,
     73           int    health);
    7274
    73   void position(int GPSweek, double GPSweeks,
    74                         double* xc,
    75                         double* vv) const;
     75  virtual void position(int GPSweek, double GPSweeks,
     76                        double* xc,
     77                        double* vv) const;
    7678
    77   int  IOD() const { return static_cast<int>(_IODC); }
     79  virtual int  IOD() const { return static_cast<int>(_IODC); }
    7880
    79   void print(std::ostream& out) const;
     81  virtual void print(std::ostream& out) const;
    8082
    8183 private:
     
    109111};
    110112
     113class t_ephGlo : public t_eph {
     114 public:
     115  t_ephGlo() { _gps_utc = 0.0; _xv.ReSize(6); }
     116
     117  virtual ~t_ephGlo() {}
     118
     119  virtual void position(int GPSweek, double GPSweeks,
     120                        double* xc,
     121                        double* vv) const;
     122
     123  virtual int  IOD() const;
     124
     125  virtual void print(std::ostream& out) const;
     126
     127  void set(const glonassephemeris* ee);
     128
     129 private:
     130  static ColumnVector glo_deriv(double /* tt */, const ColumnVector& xv);
     131
     132  mutable double       _tt;  // time in seconds of GPSweek
     133  mutable ColumnVector _xv;  // status vector (position, velocity) at time _tt
     134
     135  double  _gps_utc;          // GPS - UTC in seconds     
     136  double  _E;                // [days]   
     137  double  _tau;              // [s]     
     138  double  _gamma;            //         
     139  double  _x_pos;            // [km]     
     140  double  _x_velocity;       // [km/s]   
     141  double  _x_acceleration;   // [km/s^2]
     142  double  _y_pos;            // [km]     
     143  double  _y_velocity;       // [km/s]   
     144  double  _y_acceleration;   // [km/s^2]
     145  double  _z_pos;            // [km]     
     146  double  _z_velocity;       // [km/s]   
     147  double  _z_acceleration;   // [km/s^2]
     148  double  _health;           // 0 = O.K.
     149  double  _frequency_number; // ICD-GLONASS data position
     150  double  _tki;              // message frame time
     151};
     152
    111153#endif
  • trunk/BNC/bncpppclient.cpp

    r2208 r2221  
    158158  QString prn =
    159159        QString("%1%2").arg(obs->satSys).arg(obs->satNum, 2, 10, QChar('0'));
     160
     161  cout << prn.toAscii().data() << "  "  << obs->slot << endl;
    160162
    161163  _epoData->satData[prn] = satData;
  • trunk/BNC/bncutils.cpp

    r2065 r2221  
    243243           + sinPhi        * xyz[2];
    244244}
     245
     246// Fourth order Runge-Kutta numerical integrator for ODEs
     247////////////////////////////////////////////////////////////////////////////
     248ColumnVector rungeKutta4(
     249  double xi,              // the initial x-value
     250  const ColumnVector& yi, // vector of the initial y-values
     251  double dx,              // the step size for the integration
     252  ColumnVector (*der)(double x, const ColumnVector& y)
     253                          // A pointer to a function that computes the
     254                          // derivative of a function at a point (x,y)
     255                         ) {
     256
     257  ColumnVector k1 = der(xi       , yi       ) * dx;
     258  ColumnVector k2 = der(xi+dx/2.0, yi+k1/2.0) * dx;
     259  ColumnVector k3 = der(xi+dx/2.0, yi+k2/2.0) * dx;
     260  ColumnVector k4 = der(xi+dx    , yi+k3    ) * dx;
     261
     262  ColumnVector yf = yi + k1/6.0 + k2/3.0 + k3/3.0 + k4/6.0;
     263 
     264  return yf;
     265}
     266
  • trunk/BNC/bncutils.h

    r2065 r2221  
    5151void xyz2neu(const double* Ell, const double* xyz, double* neu);
    5252
     53ColumnVector rungeKutta4(double xi, const ColumnVector& yi, double dx,
     54                         ColumnVector (*der)(double x, const ColumnVector& y));
    5355#endif
Note: See TracChangeset for help on using the changeset viewer.