28 #include "../model/satellite-mobility-model.h"
29 #include "../model/satellite-position-allocator.h"
30 #include "../utils/satellite-env-variables.h"
32 #include "ns3/boolean.h"
33 #include "ns3/config.h"
35 #include "ns3/mobility-helper.h"
36 #include "ns3/simulator.h"
37 #include "ns3/singleton.h"
38 #include "ns3/string.h"
53 std::cout << std::cout.precision(15) << std::cout.setf(std::ios::fixed, std::ios::floatfield)
54 << Simulator::Now() <<
", x=" << pos2.x <<
", y=" << pos2.y <<
", z=" << pos2.z
83 virtual void DoRun(
void);
87 : TestCase(
"Test satellite mobility (constant model) with random box allocator.")
99 Singleton<SatEnvVariables>::Get()->DoInitialize();
100 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-mobility",
"random",
true);
102 MobilityHelper mobility;
103 mobility.SetPositionAllocator(
"ns3::SatRandomBoxPositionAllocator",
105 StringValue(
"ns3::UniformRandomVariable[Min=-45.0|Max=80.0]"),
107 StringValue(
"ns3::UniformRandomVariable[Min=-10.0|Max=180.0]"),
109 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=100.0]"));
114 mobility.SetMobilityModel(
"ns3::SatConstantPositionMobilityModel");
117 for (uint32_t i = 0; i < c.GetN(); i++)
120 "SatCourseChangeTrace",
126 NS_TEST_ASSERT_MSG_LT(pos.GetLatitude(), 80.1,
"Latitude is too big.");
127 NS_TEST_ASSERT_MSG_LT(pos.GetLongitude(), 180.1,
"Longitude is too big.");
128 NS_TEST_ASSERT_MSG_LT(pos.GetAltitude(), 100.1,
"Altitude is too big.");
130 NS_TEST_ASSERT_MSG_GT(pos.GetLatitude(), -45.1,
"Latitude is too small.");
131 NS_TEST_ASSERT_MSG_GT(pos.GetLongitude(), -10.1,
"Longitude is too small.");
132 NS_TEST_ASSERT_MSG_GT(pos.GetAltitude(), -0.1,
"Altitude is too small.");
135 Simulator::Destroy();
137 Singleton<SatEnvVariables>::Get()->DoDispose();
170 virtual void DoRun(
void);
175 "Test satellite mobility (constant model, no conversion) with list position allocator.")
187 Singleton<SatEnvVariables>::Get()->DoInitialize();
188 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-mobility",
"list1",
true);
190 MobilityHelper mobility;
191 Ptr<SatListPositionAllocator> positionAlloc = CreateObject<SatListPositionAllocator>();
195 for (
int i = -180; i <= 180; i += 30)
206 mobility.SetPositionAllocator(positionAlloc);
207 mobility.SetMobilityModel(
"ns3::SatConstantPositionMobilityModel");
213 for (
int i = 0; i < j; i++)
218 double longitude = -180 + i * 30;
219 double latitude = longitude / 2;
220 double altitude = longitude * 30;
223 NS_TEST_ASSERT_MSG_EQ(pos.GetLatitude(), latitude,
"Latitude is different.");
224 NS_TEST_ASSERT_MSG_EQ(pos.GetLongitude(), longitude,
"Longitude is different.");
225 NS_TEST_ASSERT_MSG_EQ(pos.GetAltitude(), altitude,
"Altitude is different.");
228 Simulator::Destroy();
230 Singleton<SatEnvVariables>::Get()->DoDispose();
267 virtual void DoRun(
void);
271 : TestCase(
"Test satellite mobility (constant model, conversion) with list position allocator.")
283 Singleton<SatEnvVariables>::Get()->DoInitialize();
284 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-mobility",
"list2",
true);
288 Config::SetDefault(
"ns3::SatMobilityModel::AsGeoCoordinates", BooleanValue(
false));
289 Config::SetDefault(
"ns3::SatPositionAllocator::AsGeoCoordinates", BooleanValue(
false));
291 MobilityHelper mobility;
292 Ptr<SatListPositionAllocator> positionAlloc = CreateObject<SatListPositionAllocator>();
301 mobility.SetPositionAllocator(positionAlloc);
302 mobility.SetMobilityModel(
"ns3::SatConstantPositionMobilityModel");
314 NS_TEST_ASSERT_MSG_LT(std::abs(pos.GetLatitude() - 30),
316 "Latitude difference too big!");
317 NS_TEST_ASSERT_MSG_LT(std::abs(pos.GetLongitude() - 45),
319 "Longitude difference too big!");
320 NS_TEST_ASSERT_MSG_LT(std::abs(pos.GetAltitude() - 1000),
322 "Altitude difference too big!");
324 Simulator::Destroy();
326 Singleton<SatEnvVariables>::Get()->DoDispose();
340 : TestSuite(
"sat-mobility-test", Type::SYSTEM)
Test case to unit test satellite mobility's position setting from list position allocator.
virtual ~SatMobilityList1TestCase()
SatMobilityList1TestCase()
Test case to unit test satellite mobility's position setting from list position allocator.
virtual ~SatMobilityList2TestCase()
SatMobilityList2TestCase()
Test case to unit test satellite mobility's position setting from random box position allocator.
SatMobilityRandomTestCase()
virtual ~SatMobilityRandomTestCase()
Test suite for Satellite mobility unit test cases.
GeoCoordinate class is used to store and operate with geodetic coordinates.
double GetAltitude() const
Gets altitude value of coordinate.
double GetLatitude() const
Gets latitude value of coordinate.
double GetLongitude() const
Gets longitude value of coordinate.
Vector ToVector() const
Converts Geodetic coordinates to Cartesian coordinates.
Keep track of the current position and velocity of an object in satellite network.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatMobilityTestSuite satSatMobilityTestSuite
static void SatCourseChange(std::string context, Ptr< const SatMobilityModel > position)