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 #include <stdint.h>
37 #include <string>
38 
39 namespace ns3
40 {
41 
47 {
48  public:
50  static const gravconsttype WGeoSys;
52  static const uint32_t TleSatInfoWidth;
53 
58  static TypeId GetTypeId(void);
59  TypeId GetInstanceTypeId(void) const;
60 
65 
69  virtual ~SatSGP4MobilityModel();
70 
76  void SetStartDate(std::string startStr);
77 
82  JulianDate GetStartTime() const;
83 
88  void SetStartTime(const JulianDate& t);
89 
94  void SetTleInfo(const std::string& tle);
95 
96  private:
98  struct Row
99  {
100  double r[3];
101 
102  double& operator[](uint32_t i)
103  {
104  return r[i];
105  }
106 
107  const double& operator[](uint32_t i) const
108  {
109  return r[i];
110  }
111  };
112 
115  struct Matrix
116  {
117  public:
118  Matrix(void)
119  {
120  }
121 
122  Matrix(double c00,
123  double c01,
124  double c02,
125  double c10,
126  double c11,
127  double c12,
128  double c20,
129  double c21,
130  double c22);
131 
132  Row& operator[](uint32_t i)
133  {
134  return m[i];
135  }
136 
137  const Row& operator[](uint32_t i) const
138  {
139  return m[i];
140  }
141 
142  Vector3D operator*(const Vector3D& v) const;
143 
144  Matrix Transpose(void) const;
145 
146  private:
147  Row m[3];
148  };
149 
150  std::string m_tle1, m_tle2;
152 
153  virtual Vector DoGetVelocity() const;
154 
155  virtual GeoCoordinate DoGetGeoPosition() const;
156  virtual void DoSetGeoPosition(const GeoCoordinate& position);
157  virtual Vector DoGetPosition() const;
158  virtual void DoSetPosition(const Vector& position);
159 
164  bool IsInitialized(void) const;
165 
171  JulianDate GetTleEpoch(void) const;
172 
178  static Vector3D rTemeTorItrf(const Vector3D& rteme, const JulianDate& t);
179 
185  static Matrix PefToItrf(const JulianDate& t);
186 
192  static Matrix TemeToPef(const JulianDate& t);
193 
199  static Vector3D rvTemeTovItrf(const Vector3D& rteme,
200  const Vector3D& vteme,
201  const JulianDate& t);
202 
207 
212 
216  std::string m_startStr;
217 
222 
227 
231  mutable Time m_timeLastUpdate;
232 };
233 
234 } // namespace ns3
235 
236 #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:79
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.
void SetStartDate(std::string startStr)
Set the simulation absolute start time in string format.
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