satellite-sgp4-mobility-model.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 INESC TEC
4  * Copyright (c) 2021 CNES
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Code from https://gitlab.inesctec.pt/pmms/ns3-satellite
20  *
21  * Author: Pedro Silva <pmms@inesctec.pt>
22  * Author: Bastien Tauran <bastien.tauran@viveris.fr>
23  */
24 
25 #ifndef SAT_SGP4_MOBILITY_MODEL_H
26 #define SAT_SGP4_MOBILITY_MODEL_H
27 
28 #include "julian-date.h"
30 #include "satellite-sgp4io.h"
31 #include "satellite-sgp4unit.h"
32 
33 #include <ns3/nstime.h>
34 #include <ns3/vector.h>
35 
36 namespace ns3
37 {
38 
44 {
45  public:
47  static const gravconsttype WGeoSys;
49  static const uint32_t TleSatInfoWidth;
50 
55  static TypeId GetTypeId(void);
56  TypeId GetInstanceTypeId(void) const;
57 
62 
66  virtual ~SatSGP4MobilityModel();
67 
72  JulianDate GetStartTime() const;
73 
78  void SetStartTime(const JulianDate& t);
79 
84  void SetTleInfo(const std::string& tle);
85 
86  private:
88  struct Row
89  {
90  double r[3];
91 
92  double& operator[](uint32_t i)
93  {
94  return r[i];
95  }
96 
97  const double& operator[](uint32_t i) const
98  {
99  return r[i];
100  }
101  };
102 
105  struct Matrix
106  {
107  public:
108  Matrix(void)
109  {
110  }
111 
112  Matrix(double c00,
113  double c01,
114  double c02,
115  double c10,
116  double c11,
117  double c12,
118  double c20,
119  double c21,
120  double c22);
121 
122  Row& operator[](uint32_t i)
123  {
124  return m[i];
125  }
126 
127  const Row& operator[](uint32_t i) const
128  {
129  return m[i];
130  }
131 
132  Vector3D operator*(const Vector3D& v) const;
133 
134  Matrix Transpose(void) const;
135 
136  private:
137  Row m[3];
138  };
139 
140  std::string m_tle1, m_tle2;
142 
143  virtual Vector DoGetVelocity() const;
144 
145  virtual GeoCoordinate DoGetGeoPosition() const;
146  virtual void DoSetGeoPosition(const GeoCoordinate& position);
147  virtual Vector DoGetPosition() const;
148  virtual void DoSetPosition(const Vector& position);
149 
154  bool IsInitialized(void) const;
155 
161  JulianDate GetTleEpoch(void) const;
162 
168  static Vector3D rTemeTorItrf(const Vector3D& rteme, const JulianDate& t);
169 
175  static Matrix PefToItrf(const JulianDate& t);
176 
182  static Matrix TemeToPef(const JulianDate& t);
183 
189  static Vector3D rvTemeTovItrf(const Vector3D& rteme,
190  const Vector3D& vteme,
191  const JulianDate& t);
192 
197 
202 
206  std::string m_startStr;
207 
212 
217 
221  mutable Time m_timeLastUpdate;
222 };
223 
224 } // namespace ns3
225 
226 #endif /* SAT_SGP4_MOBILITY_MODEL_H */
GeoCoordinate class is used to store and operate with geodetic coordinates.
Class to handle Julian days and provide respective Earth Orientation Parameters (EOP).
Definition: julian-date.h:78
Keep track of the current position and velocity of an object in satellite network.
Keep track of the current position and velocity of satellite using SGP4 model.
std::string m_startStr
Simulation absolute start time in string format.
virtual void DoSetGeoPosition(const GeoCoordinate &position)
static const gravconsttype WGeoSys
World Geodetic System (WGS) constants to be used by SGP4/SDP4 models.
JulianDate GetStartTime() const
Get the time instant considered as the simulation start.
virtual void DoSetPosition(const Vector &position)
static const uint32_t TleSatInfoWidth
Satellite's information line size defined by TLE data format.
GeoCoordinate m_lastPosition
Last saved satellite position.
void SetStartTime(const JulianDate &t)
Set the time instant considered as the simulation start.
static Matrix PefToItrf(const JulianDate &t)
Retrieve the matrix for converting from PEF to ITRF at a given time.
Time m_updatePositionPeriod
Period of satellite position refresh, if UpdatePositionEachRequest is false.
JulianDate GetTleEpoch(void) const
Retrieve the TLE epoch time.
bool m_updatePositionEachRequest
Compute position each time a packet is transmitted.
elsetrec m_sgp4_record
SGP4/SDP4 record.
static Vector3D rvTemeTovItrf(const Vector3D &rteme, const Vector3D &vteme, const JulianDate &t)
Retrieve the satellite's velocity vector in ITRF coordinates.
static Matrix TemeToPef(const JulianDate &t)
Retrieve the matrix for converting from TEME to PEF at a given time.
Time m_timeLastUpdate
Last position update time.
std::string m_tle2
satellite's TLE data.
static TypeId GetTypeId(void)
Get the type ID.
static Vector3D rTemeTorItrf(const Vector3D &rteme, const JulianDate &t)
Retrieve the satellite's position vector in ITRF coordinates.
virtual GeoCoordinate DoGetGeoPosition() const
bool IsInitialized(void) const
Check if the satellite has already been initialized.
void SetTleInfo(const std::string &tle)
Set satellite's TLE information required for its initialization.
JulianDate m_start
Simulation absolute start time.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
gravconsttype
Matrix data structure to make coordinate conversion code clearer and less verbose.
Vector3D operator*(const Vector3D &v) const
const double & operator[](uint32_t i) const