diff --git a/examples/leo-circular-orbit-tracing-example.cc b/examples/leo-circular-orbit-tracing-example.cc index 28b092a..4ccb63e 100644 --- a/examples/leo-circular-orbit-tracing-example.cc +++ b/examples/leo-circular-orbit-tracing-example.cc @@ -32,11 +32,11 @@ public: int main(int argc, char *argv[]) { std::vector orbits = { - Orbit (1.150, 53.0, 32, 50), - Orbit (1.110, 53.8, 32, 50), - Orbit (1.130, 74.0, 8, 50), - Orbit (1.275, 81, 5, 75), - Orbit (1.325, 70, 6, 75), + Orbit (1150, 53.0, 32, 50), + Orbit (1110, 53.8, 32, 50), + Orbit (1130, 74.0, 8, 50), + Orbit (1275, 81, 5, 75), + Orbit (1325, 70, 6, 75), }; NodeContainer satellites; for (Orbit orb: orbits) @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) outfile << "Time,Satellite,x,y,z,Speed" << std::endl; - Simulator::Stop (Hours (2.0)); + Simulator::Stop (Hours (24)); Simulator::Run (); Simulator::Destroy (); } diff --git a/model/leo-circular-orbit-mobility-model.cc b/model/leo-circular-orbit-mobility-model.cc index 3fbb657..08cbad2 100644 --- a/model/leo-circular-orbit-mobility-model.cc +++ b/model/leo-circular-orbit-mobility-model.cc @@ -82,8 +82,9 @@ LeoCircularOrbitMobilityModel::GetSpeed () const Vector LeoCircularOrbitMobilityModel::DoGetVelocity () const { - Vector3D heading = CrossProduct (PlaneNorm (), DoGetPosition ()); - // TODO + Vector3D pos = DoGetPosition (); + pos = Vector3D (pos.x / pos.GetLength (), pos.y / pos.GetLength (), pos.z / pos.GetLength ()); + Vector3D heading = CrossProduct (PlaneNorm (), pos); return Product (GetSpeed (), heading); } @@ -106,7 +107,7 @@ LeoCircularOrbitMobilityModel::GetProgress (Time t) const { sign = -1; } - return sign * (2 * M_PI * ((GetSpeed () * t.GetSeconds ()) / LEO_EARTH_RAD_M)) + m_offset; + return sign * (2 * M_PI * ((GetSpeed () * t.GetSeconds ()) / LEO_EARTH_RAD_KM)) + m_offset; } Vector3D @@ -130,7 +131,7 @@ LeoCircularOrbitMobilityModel::CalcPosition (Time t) const { double lat = CalcLatitude (); // account for orbit latitude and earth rotation offset - Vector3D x = Product (m_orbitHeight, Vector3D (cos (m_inclination) * cos (lat), + Vector3D x = Product (m_orbitHeight*1000, Vector3D (cos (m_inclination) * cos (lat), cos (m_inclination) * sin (lat), sin (m_inclination))); @@ -175,12 +176,12 @@ LeoCircularOrbitMobilityModel::DoSetPosition (const Vector &position) double LeoCircularOrbitMobilityModel::GetAltitude () const { - return m_orbitHeight - LEO_EARTH_RAD_M; + return m_orbitHeight - LEO_EARTH_RAD_KM; } void LeoCircularOrbitMobilityModel::SetAltitude (double h) { - m_orbitHeight = LEO_EARTH_RAD_M + h; + m_orbitHeight = LEO_EARTH_RAD_KM + h; Update (); } diff --git a/model/leo-circular-orbit-mobility-model.h b/model/leo-circular-orbit-mobility-model.h index 767b18d..7589a17 100644 --- a/model/leo-circular-orbit-mobility-model.h +++ b/model/leo-circular-orbit-mobility-model.h @@ -9,7 +9,7 @@ #include "ns3/mobility-model.h" #include "ns3/nstime.h" -#define LEO_EARTH_RAD_M 6371009.0 +#define LEO_EARTH_RAD_KM 6371.0090 #define LEO_EARTH_GM_KM_E10 39.8600436 namespace ns3 { diff --git a/test/leo-orbit-test-suite.cc b/test/leo-orbit-test-suite.cc index a8c7359..0e92f80 100644 --- a/test/leo-orbit-test-suite.cc +++ b/test/leo-orbit-test-suite.cc @@ -38,7 +38,7 @@ private: mob->SetAttribute ("Altitude", DoubleValue (0.0)); mob->SetAttribute ("Inclination", DoubleValue (1.0)); - NS_TEST_ASSERT_MSG_EQ_TOL (mob->GetPosition ().GetLength(), LEO_EARTH_RAD_M, 0.1, "Unexpected position on earths surface for 1 deg inclination"); + NS_TEST_ASSERT_MSG_EQ_TOL (mob->GetPosition ().GetLength() / 1000, LEO_EARTH_RAD_KM, 0.1, "Unexpected position on earths surface for 1 deg inclination"); } }; @@ -51,7 +51,7 @@ private: void TestLengthPosition (double expl, double expx, Ptr mob) { Vector pos = mob->GetPosition (); - 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_EQ_TOL_INTERNAL (pos.GetLength () / 1000, 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__); } @@ -62,7 +62,7 @@ private: mob->SetAttribute ("Inclination", DoubleValue (20.0)); Vector pos = mob->GetPosition (); - Simulator::Schedule (Seconds (100.0), &LeoOrbitProgressTestCase::TestLengthPosition, this, LEO_EARTH_RAD_M, pos.x, mob); + Simulator::Schedule (Seconds (100.0), &LeoOrbitProgressTestCase::TestLengthPosition, this, LEO_EARTH_RAD_KM, pos.x, mob); Simulator::Stop (Seconds (101.0)); Simulator::Run (); Simulator::Destroy (); diff --git a/utils/plot-satellites.gnuplot b/utils/plot-satellites.gnuplot index 44d5c22..c36b468 100644 --- a/utils/plot-satellites.gnuplot +++ b/utils/plot-satellites.gnuplot @@ -11,8 +11,9 @@ set xrange [-8e6:8e6] set yrange [-8e6:8e6] set zrange [-8e6:8e6] set parametric -set isosamples 100,100 +set isosamples 20,20 unset key +unset title set hidden3d # number of nodes per time slot @@ -22,8 +23,7 @@ ground=ARG2 numsats=ARG3 numsamples=ARG4 -do for [j=0:numsamples] { - set title 'time '.j +do for [j=0:numsamples-1] { splot [-pi:pi][-pi/2:pi/2] EARTH*cos(u)*cos(v), EARTH*sin(u)*cos(v), EARTH*sin(v), \ ground using 1:2:3 lt rgb "green", \ sats using 3:4:5:2 every ::(j*numsats)::((j+1)*numsats) lt rgb "blue"