File: simulateSatelliteTracking.cpp

package info (click to toggle)
groops 0%2Bgit20250907%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 11,140 kB
  • sloc: cpp: 135,607; fortran: 1,603; makefile: 20
file content (121 lines) | stat: -rw-r--r-- 4,563 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/***********************************************/
/**
* @file simulateSatelliteTracking.cpp
*
* @brief Simulate tracking data (range, range-rate, range-accelerations) between 2 satellites.
*
* @author Torsten Mayer-Guerr
* @date 2005-01-21
*/
/***********************************************/

// Latex documentation
#define DOCSTRING docstring
static const char *docstring = R"(
This program simulates \file{tracking data}{instrument} (range, range-rate, range-accelerations)
between 2 satellites. The range is given by
\begin{equation}
\rho(t) = \left\lVert{\M r_B(t) - \M r_A(t)}\right\rVert = \M e_{AB}(t)\cdot\M r_{AB}(t),
\end{equation}
with $\M r_{AB} = \M r_B - \M r_A$ and the unit vector in line of sight (LOS) direction
\begin{equation}\label{sst.los}
\M e_{AB} = \frac{\M r_{AB}}{\left\lVert{\M r_{AB}}\right\rVert}=\frac{\M r_{AB}}{\rho}.
\end{equation}
Range-rates~$\dot{\rho}$ and range accelrations~$\ddot{\rho}$ are obtained by differentation
\begin{equation}\label{obsRangeRate}
\dot{\rho}  = \M e_{AB}\cdot\dot{\M r}_{AB} + \dot{\M e}_{AB}\cdot\M r_{AB}
            = \M e_{AB}\cdot\dot{\M r}_{AB},
\end{equation}
\begin{equation}\label{obsRangeAccl}
\begin{split}
\ddot{\rho} &= \M e_{AB}\cdot\ddot{\M r}_{AB} +\dot{\M e}_{AB}\cdot\dot{\M r}_{AB}
            = \M e_{AB}\cdot\ddot{\M r}_{AB} +
   \frac{1}{\rho}\left(\dot{\M r}_{AB}^2-\dot{\rho}^2\right). \\
\end{split}
\end{equation}
with the derivative of the unit vector
\begin{equation}
\dot{\M e}_{AB}=\frac{d}{dt}\left(\frac{\M r_{AB}}{\rho}\right)
=\frac{\dot{\M r}_{AB}}{\rho}-\frac{\dot{\rho}\cdot\M r_{AB}}{\rho^2}
=\frac{1}{\rho}\left({\dot{\M r}_{AB}-\dot{\rho}\cdot\M e_{AB}}\right).
\end{equation}
The \configFile{inputfileOrbit}{instrument}s must contain positions, velocities, and acceleration
(see \program{OrbitAddVelocityAndAcceleration}).
)";

/***********************************************/

#include "programs/program.h"
#include "files/fileInstrument.h"

/***** CLASS ***********************************/

/** @brief Simulate tracking data (range, range-rate, range-accelerations) between 2 satellites.
* @ingroup programsGroup */
class SimulateSatelliteTracking
{
public:
  void run(Config &config, Parallel::CommunicatorPtr comm);
};

GROOPS_REGISTER_PROGRAM(SimulateSatelliteTracking, PARALLEL, "simulate tracking data (range, range-rate, range-accelerations) between 2 satellites", Simulation, Instrument)

/***********************************************/

void SimulateSatelliteTracking::run(Config &config, Parallel::CommunicatorPtr comm)
{
  try
  {
    FileName outName, orbit1Name, orbit2Name;

    readConfig(config, "outputfileSatelliteTracking", outName,    Config::MUSTSET,  "", "");
    readConfig(config, "inputfileOrbit1",             orbit1Name, Config::MUSTSET,  "", "");
    readConfig(config, "inputfileOrbit2",             orbit2Name, Config::MUSTSET,  "", "");
    if(isCreateSchema(config)) return;

    // Tracking-Daten erzeugen
    // -----------------------
    logStatus<<"read orbits and generate tracking data"<<Log::endl;
    InstrumentFile orbit1File(orbit1Name);
    InstrumentFile orbit2File(orbit2Name);
    InstrumentFile::checkArcCount({orbit1File, orbit2File});
    std::vector<Arc> arcList(orbit1File.arcCount());

    Parallel::forEach(arcList, [&](UInt arcNo)
    {
      OrbitArc orbit1 = orbit1File.readArc(arcNo);
      OrbitArc orbit2 = orbit2File.readArc(arcNo);
      Arc::checkSynchronized({orbit1, orbit2});

      SatelliteTrackingArc arc;
      for(UInt i=0; i<orbit1.size(); i++)
      {
        Vector3d vrange         = orbit2.at(i).position     - orbit1.at(i).position;
        Vector3d vvelocity      = orbit2.at(i).velocity     - orbit1.at(i).velocity;
        Vector3d vacceleration  = orbit2.at(i).acceleration - orbit1.at(i).acceleration;

        SatelliteTrackingEpoch epoch;
        epoch.time              = orbit1.at(i).time;
        epoch.range             = vrange.norm();
        epoch.rangeRate         = inner(vrange,vvelocity)/epoch.range;
        epoch.rangeAcceleration = (vvelocity.quadsum()-pow(epoch.rangeRate,2))/epoch.range
                                + inner(vrange,vacceleration)/epoch.range;
        arc.push_back(epoch);
      }
      return arc;
    }, comm);

    if(Parallel::isMaster(comm))
    {
      logStatus<<"write tracking data to file <"<<outName<<">"<<Log::endl;
      InstrumentFile::write(outName, arcList);
      Arc::printStatistics(arcList);
    }
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

/***********************************************/