mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 01:53:58 +02:00
Add test for latitude change
This commit is contained in:
parent
7df91546da
commit
cc2a8ae5e9
4 changed files with 42 additions and 52 deletions
|
@ -32,23 +32,11 @@ LeoCircularOrbitMobilityModel::GetTypeId ()
|
|||
MakeDoubleAccessor (&LeoCircularOrbitMobilityModel::SetInclination,
|
||||
&LeoCircularOrbitMobilityModel::GetInclination),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("Latitude",
|
||||
"The latitude at which the orital plane intersects the equatorial plane in degrees",
|
||||
DoubleValue (0.0),
|
||||
MakeDoubleAccessor (&LeoCircularOrbitMobilityModel::SetLatitude,
|
||||
&LeoCircularOrbitMobilityModel::GetLatitude),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("Offset",
|
||||
"The relative offset of the satellite along the orbital plane from the equatorial plane in degrees",
|
||||
DoubleValue (0.0),
|
||||
MakeDoubleAccessor (&LeoCircularOrbitMobilityModel::SetOffset,
|
||||
&LeoCircularOrbitMobilityModel::GetOffset),
|
||||
MakeDoubleChecker<double> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
LeoCircularOrbitMobilityModel::LeoCircularOrbitMobilityModel() : MobilityModel ()
|
||||
LeoCircularOrbitMobilityModel::LeoCircularOrbitMobilityModel() : MobilityModel (), m_latitude (0.0), m_offset (0.0)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
@ -105,15 +93,14 @@ double
|
|||
LeoCircularOrbitMobilityModel::GetProgress (Time t) const
|
||||
{
|
||||
// TODO use nanos or ms instead? does it give higher precision?
|
||||
return 2 * M_PI * ((GetSpeed () * t.GetSeconds ()) / LEO_EARTH_RAD_M) + m_offset;
|
||||
return (2 * M_PI * ((GetSpeed () * t.GetSeconds ()) / LEO_EARTH_RAD_M)) + m_offset;
|
||||
}
|
||||
|
||||
Vector3D
|
||||
LeoCircularOrbitMobilityModel::RotatePlane (double a, const Vector3D &x) const
|
||||
{
|
||||
Vector3D n = PlaneNorm ();
|
||||
Vector3D n = m_plane;
|
||||
|
||||
// TODO optimize?
|
||||
return Product (DotProduct (n, x), n)
|
||||
+ Product (cos (a), CrossProduct (CrossProduct (n, x), n))
|
||||
+ Product (sin (a), CrossProduct (n, x));
|
||||
|
@ -132,7 +119,13 @@ LeoCircularOrbitMobilityModel::DoGetPosition (void) const
|
|||
void
|
||||
LeoCircularOrbitMobilityModel::DoSetPosition (const Vector &position)
|
||||
{
|
||||
NS_ASSERT_MSG (false, "Can not set position of satellite on circular orbit");
|
||||
// use first element of position vector as latitude, second for longitude
|
||||
// this works nicely with MobilityHelper and GetPostion will still get the
|
||||
// correct position, but be aware that it will not be the same as supplied to
|
||||
// SetPostion
|
||||
m_latitude = position.x;
|
||||
m_offset = position.y;
|
||||
m_plane = PlaneNorm ();
|
||||
}
|
||||
|
||||
double LeoCircularOrbitMobilityModel::GetAltitude () const
|
||||
|
@ -146,27 +139,6 @@ void LeoCircularOrbitMobilityModel::SetAltitude (double h)
|
|||
m_plane = PlaneNorm ();
|
||||
}
|
||||
|
||||
double LeoCircularOrbitMobilityModel::GetLatitude () const
|
||||
{
|
||||
return m_latitude / M_PI * 180.0;
|
||||
}
|
||||
|
||||
void LeoCircularOrbitMobilityModel::SetLatitude (double lat)
|
||||
{
|
||||
m_latitude = lat / 180 * M_PI;
|
||||
m_plane = PlaneNorm ();
|
||||
}
|
||||
|
||||
double LeoCircularOrbitMobilityModel::GetOffset () const
|
||||
{
|
||||
return (m_offset / M_PI) * 180;
|
||||
}
|
||||
|
||||
void LeoCircularOrbitMobilityModel::SetOffset (double off)
|
||||
{
|
||||
m_offset = (off / 180) * M_PI;
|
||||
}
|
||||
|
||||
double LeoCircularOrbitMobilityModel::GetInclination () const
|
||||
{
|
||||
return (m_inclination / M_PI) * 180.0;
|
||||
|
|
|
@ -40,12 +40,6 @@ public:
|
|||
double GetAltitude () const;
|
||||
void SetAltitude (double h);
|
||||
|
||||
double GetLatitude () const;
|
||||
void SetLatitude (double lat);
|
||||
|
||||
double GetOffset () const;
|
||||
void SetOffset (double off);
|
||||
|
||||
double GetInclination () const;
|
||||
void SetInclination (double incl);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ private:
|
|||
class LeoOrbitPositionTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
LeoOrbitPositionTestCase () : TestCase ("Test position for 0 altitude and 0 inclination") {}
|
||||
LeoOrbitPositionTestCase () : TestCase ("Test position for 0 altitude and 1.0 inclination") {}
|
||||
virtual ~LeoOrbitPositionTestCase () {}
|
||||
private:
|
||||
virtual void DoRun (void)
|
||||
|
@ -35,36 +35,57 @@ private:
|
|||
mob->SetAttribute ("Altitude", DoubleValue (0.0));
|
||||
mob->SetAttribute ("Inclination", DoubleValue (1.0));
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (mob->GetPosition ().GetLength(), LEO_EARTH_RAD_M, "Unexpected position on earths surface for 1 deg inclination");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (mob->GetPosition ().GetLength(), LEO_EARTH_RAD_M, 0.1, "Unexpected position on earths surface for 1 deg inclination");
|
||||
}
|
||||
};
|
||||
|
||||
class LeoOrbitProgressTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
LeoOrbitProgressTestCase () : TestCase ("Test position for 0 altitude and 1.0 inclination after 360 seconds") {}
|
||||
LeoOrbitProgressTestCase () : TestCase ("Test position shoudl not be the same after some time") {}
|
||||
virtual ~LeoOrbitProgressTestCase () {}
|
||||
private:
|
||||
void TestLengthPosition (double expl, double expx, Ptr<LeoCircularOrbitMobilityModel> mob)
|
||||
{
|
||||
Vector pos = mob->GetPosition ();
|
||||
NS_TEST_EXPECT_MSG_NE_INTERNAL (pos.x, expx, "Position not equal", __FILE__, __LINE__);
|
||||
NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (pos.GetLength (), expl, 0.001, "Position must be different", __FILE__, __LINE__);
|
||||
NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (pos.GetLength (), expl, 0.001, "Distance to earth should be the same", __FILE__, __LINE__);
|
||||
NS_TEST_EXPECT_MSG_NE_INTERNAL (pos.x, expx, "Position should not be equal", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
virtual void DoRun (void)
|
||||
{
|
||||
Ptr<LeoCircularOrbitMobilityModel> mob = CreateObject<LeoCircularOrbitMobilityModel> ();
|
||||
mob->SetAttribute ("Altitude", DoubleValue (0.0));
|
||||
mob->SetAttribute ("Inclination", DoubleValue (1.0));
|
||||
mob->SetAttribute ("Inclination", DoubleValue (20.0));
|
||||
|
||||
Vector pos = mob->GetPosition ();
|
||||
Simulator::Schedule (Seconds (360.0), &LeoOrbitProgressTestCase::TestLengthPosition, this, LEO_EARTH_RAD_M, pos.x, mob);
|
||||
Simulator::Schedule (Seconds (100.0), &LeoOrbitProgressTestCase::TestLengthPosition, this, LEO_EARTH_RAD_M, pos.x, mob);
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
}
|
||||
};
|
||||
|
||||
class LeoOrbitLatitudeTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
LeoOrbitLatitudeTestCase () : TestCase ("Test offset between neighboring satellites planes") {}
|
||||
virtual ~LeoOrbitLatitudeTestCase () {}
|
||||
private:
|
||||
virtual void DoRun (void)
|
||||
{
|
||||
Ptr<LeoCircularOrbitMobilityModel> mob = CreateObject<LeoCircularOrbitMobilityModel> ();
|
||||
mob->SetAttribute ("Altitude", DoubleValue (1000.0));
|
||||
mob->SetAttribute ("Inclination", DoubleValue (20.0));
|
||||
|
||||
Vector pos1 = mob->GetPosition ();
|
||||
|
||||
mob->SetPosition (Vector3D (20.0, 0, 0));
|
||||
Vector pos2 = mob->GetPosition ();
|
||||
|
||||
NS_TEST_ASSERT_MSG_NE (pos1.x, pos2.x, "Neighboring satellite should have different position");
|
||||
}
|
||||
};
|
||||
|
||||
class LeoOrbitOffsetTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
|
@ -79,7 +100,7 @@ private:
|
|||
|
||||
Vector pos1 = mob->GetPosition ();
|
||||
|
||||
mob->SetAttribute ("Offset", DoubleValue (20.0));
|
||||
mob->SetPosition (Vector3D (0, 20.0, 0));
|
||||
Vector pos2 = mob->GetPosition ();
|
||||
|
||||
NS_TEST_ASSERT_MSG_NE (pos1.x, pos2.x, "Neighboring satellite should have different position");
|
||||
|
@ -93,6 +114,7 @@ public:
|
|||
AddTestCase (new LeoOrbitSpeedTestCase, TestCase::QUICK);
|
||||
AddTestCase (new LeoOrbitPositionTestCase, TestCase::QUICK);
|
||||
AddTestCase (new LeoOrbitProgressTestCase, TestCase::QUICK);
|
||||
AddTestCase (new LeoOrbitLatitudeTestCase, TestCase::QUICK);
|
||||
AddTestCase (new LeoOrbitOffsetTestCase, TestCase::QUICK);
|
||||
}
|
||||
};
|
||||
|
|
2
wscript
2
wscript
|
@ -17,6 +17,7 @@ def build(bld):
|
|||
'helper/satellite-node-helper.cc',
|
||||
'model/leo.cc',
|
||||
'model/leo-circular-orbit-mobility-model.cc',
|
||||
'model/leo-circular-orbit-position-allocator.cc',
|
||||
'model/leo-mock-channel.cc',
|
||||
'model/leo-mock-net-device.cc',
|
||||
'model/leo-propagation-loss-model.cc',
|
||||
|
@ -55,6 +56,7 @@ def build(bld):
|
|||
'helper/satellite-node-helper.h',
|
||||
'model/leo.h',
|
||||
'model/leo-circular-orbit-mobility-model.h',
|
||||
'model/leo-circular-orbit-position-allocator.h',
|
||||
'model/leo-mock-channel.h',
|
||||
'model/leo-mock-net-device.h',
|
||||
'model/leo-oneweb-constants.h',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue