A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
leo-circular-orbit-mobility-model.h
Go to the documentation of this file.
1// Copyright (c) Tim Schubert
2//
3// SPDX-License-Identifier: GPL-2.0-only
4//
5// Author: Tim Schubert <ns-3-leo@timschubert.net>
6// Porting: Thiago Miyazaki <miyathiago@gmail.com> <t.miyazaki@unesp.br>
7
8#ifndef LEO_CIRCULAR_ORBIT_MOBILITY_MODEL_H
9#define LEO_CIRCULAR_ORBIT_MOBILITY_MODEL_H
10
12#include "mobility-model.h"
13
14#include "ns3/nstime.h"
15#include "ns3/object.h"
16#include "ns3/vector.h"
17
18/**
19 * @file
20 * @ingroup leo
21 *
22 * Declaration of LeoCircularOrbitMobilityModel
23 */
24
25namespace ns3
26{
27
28/**
29 * @ingroup leo
30 * @brief Keep track of the orbital position and velocity of a satellite.
31 *
32 * This uses simple circular orbits based on the inclination of the orbital
33 * plane and the altitude of the satellite. Assumes earth is a perfect sphere.
34 *
35 * Note: Position in `DoSetPosition()` is in degrees, not the usual meters.
36 * Note: Altitude is stored in km, _not_ the usual ns-3 m.
37 *
38 * This model is distinct from `GeocentricEcefMobilityModel` in that it
39 * implements a dynamic circular orbital model, whereas `GeocentricEcefMobilityModel`
40 * is intended for ECEF coordinates that do not evolve according to orbital dynamics.
41 */
43{
44 public:
45 /**
46 * @brief Get the type ID.
47 * @return the object TypeId
48 */
49 static TypeId GetTypeId();
50 /// constructor
52 /// destructor
54
55 /**
56 * @brief Gets the speed of the node
57 * @return the speed in m/s
58 */
59 double GetSpeed() const;
60
61 /**
62 * @brief Get the orbital angular velocity.
63 *
64 * Computed from Keplerian mechanics: omega = sqrt(GM / r^3).
65 * Negated for retrograde orbits (inclination > 90 degrees).
66 *
67 * If the user set an orbital angular velocity >= 0,
68 * it will be used instead.
69 *
70 * @return angular velocity in rad/s
71 */
72 double GetAngularVelocity() const;
73
74 /**
75 * @brief Gets the altitude in m
76 *
77 * @return the altitude in m (above Earth surface)
78 */
79 double GetAltitude() const;
80 /**
81 * @brief Sets the altitude in m
82 *
83 * @param h the altitude in m (above Earth surface)
84 */
85 void SetAltitude(double h);
86
87 /**
88 * @brief Gets the altitude in km (not the usual meters used in ns-3)
89 *
90 * @return the altitude in km (above Earth surface)
91 */
92 double GetAltitudeKm() const;
93 /**
94 * @brief Sets the altitude in km (not the usual meters used in ns-3)
95 *
96 * @param h the altitude in km (above Earth surface)
97 */
98 void SetAltitudeKm(double h);
99
100 /**
101 * @brief Gets the inclination
102 * @return the inclination in degrees
103 */
104 double GetInclination() const;
105
106 /**
107 * @brief Sets the inclination
108 * @param incl the inclination in degrees
109 */
110 void SetInclination(double incl);
111
112 /**
113 * @brief Returns the Geocentric Position of the Node in ECEF (cartesian)
114 * @return ECEF position in meters
115 */
116 Vector DoGetGeocentricPosition() const override;
117
118 // Inherited from MobilityModel
119 Ptr<MobilityModel> Copy() const override
120 {
122 }
123
124 private:
125 void DoInitialize() override;
126 void DoDispose() override;
127
128 /// Orbit height in km
130
131 /// Inclination in rad
133
134 /// Longitudinal offset in rad
136
137 /// Argument of latitude in rad
139
140 /// Orbital speed in m/s; negative means compute from gravity
142
143 /// Time interval between CourseChange notifications; zero disables
144 /// periodic notifications
146
147 /// Event for course change notification
149
150 /**
151 * @brief Fire NotifyCourseChange and reschedule at m_resolutionTimeStep.
152 */
154
155 /**
156 * @brief Returns the node current position.
157 * @return ECEF position in meters
158 */
159 Vector DoGetPosition() const override;
160
161 /**
162 * @brief Sets the node position via argument.
163 *
164 * Note: This method deviates from the `MobilityModel` interface which typically
165 * expects position in meters. For this model, position is interpreted as angular
166 * coordinates (degrees) because specifying orbital parameters (longitude of
167 * ascending node and offset) is more intuitive in degrees than in meters
168 * relative to the earth's center.
169 *
170 * @param position position.x is the longitude of the ascending node
171 * in degrees; position.y is the argument of latitude on the orbital plane
172 * in degrees. Both are converted to radians internally.
173 */
174 void DoSetPosition(const Vector& position) override;
175
176 /**
177 * @brief Returns the current velocity of the node.
178 * @return velocity vector in m/s (ECEF)
179 */
180 Vector DoGetVelocity() const override;
181
182 /**
183 * @brief Get the normal vector of the orbital plane
184 * @param t the amount of time passed since the start of the simulation
185 * @return the normal vector.
186 */
187 Vector3D PlaneNorm(Time t) const;
188
189 /**
190 * @brief Rotates a position vector by angle 'a' around the orbital plane
191 * normal, using the Rodrigues rotation formula
192 * (see https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula ).
193 *
194 * @param theta angle by which to rotate, in radians
195 * @param v position vector to rotate, in meters (ECEF)
196 * @param t time passed since simulation start (used to compute the
197 * current orbital plane normal)
198 * @return rotated position vector in meters (ECEF)
199 */
200 Vector3D RotatePlane(double theta, const Vector3D& v, Time t) const;
201
202 /**
203 * @brief Calculate the position at time t
204 *
205 * The returned Vector contains Cartesian ECEF coordinates in meters.
206 * Note that this differs from DoSetPosition(), where the Vector
207 * encodes angular orbital parameters (longitude and offset in
208 * degrees); that discrepancy is a consequence of the MobilityModel
209 * base class interface, which uses a single Vector type for both
210 * input and output.
211 *
212 * @param t simulation time
213 * @return ECEF position in meters
214 */
215 Vector CalcPosition(Time t) const;
216
217 /**
218 * @brief Calculate the ECEF longitude of the ascending node at simulation time t
219 *
220 * The orbital plane drifts westward in the ECEF frame because the Earth
221 * rotates eastward, so this returns m_longitude minus the Earth-rotation
222 * angle accumulated over time t.
223 *
224 * @param t time
225 * @return longitude of the ascending node in radians (ECEF)
226 */
227 double CalcLongitude(Time t) const;
228};
229} // namespace ns3
230
231#endif
uint32_t v
An identifier for simulation events.
Definition event-id.h:45
GeocentricConstantPositionMobilityModel()=default
Create a position located at coordinates (0,0,0).
Vector3D RotatePlane(double theta, const Vector3D &v, Time t) const
Rotates a position vector by angle 'a' around the orbital plane normal, using the Rodrigues rotation ...
double GetInclination() const
Gets the inclination.
double GetAltitudeKm() const
Gets the altitude in km (not the usual meters used in ns-3).
double m_orbitalSpeed
Orbital speed in m/s; negative means compute from gravity.
Vector CalcPosition(Time t) const
Calculate the position at time t.
double GetAltitude() const
Gets the altitude in m.
double GetSpeed() const
Gets the speed of the node.
void SetAltitudeKm(double h)
Sets the altitude in km (not the usual meters used in ns-3).
void SetInclination(double incl)
Sets the inclination.
double m_argumentOfLatitude
Argument of latitude in rad.
Vector3D PlaneNorm(Time t) const
Get the normal vector of the orbital plane.
Time m_resolutionTimeStep
Time interval between CourseChange notifications; zero disables periodic notifications.
void SetAltitude(double h)
Sets the altitude in m.
void DoDispose() override
Destructor implementation.
Vector DoGetVelocity() const override
Returns the current velocity of the node.
void NotifyCourseChangeAndReschedule()
Fire NotifyCourseChange and reschedule at m_resolutionTimeStep.
Ptr< MobilityModel > Copy() const override
Copy function allows one to copy the underlying MobilityModel from a MobilityModel pointer,...
double CalcLongitude(Time t) const
Calculate the ECEF longitude of the ascending node at simulation time t.
void DoInitialize() override
Initialize() implementation.
Vector DoGetGeocentricPosition() const override
Returns the Geocentric Position of the Node in ECEF (cartesian).
EventId m_courseChangeEvent
Event for course change notification.
void DoSetPosition(const Vector &position) override
Sets the node position via argument.
Vector DoGetPosition() const override
Returns the node current position.
double GetAngularVelocity() const
Get the orbital angular velocity.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
a unique identifier for an interface.
Definition type-id.h:50
a 3d vector
Definition vector.h:35
Class GeocentricConstantPositionMobilityModel declaration.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:627
Every class exported by the ns3 library is enclosed in the ns3 namespace.