20 #include "ns3/boolean.h"
21 #include "ns3/config.h"
22 #include "ns3/simulator.h"
24 #include "ns3/waypoint-mobility-model.h"
42 :
TestCase(lazy ?
"Check Waypoint Mobility Model LAZY notification accuracy"
43 :
"Check Waypoint Mobility Model NON-LAZY notification accuracy"),
59 void DoRun()
override;
60 void DoTeardown()
override;
73 mobilityStack.clear();
84 mobilityFactory.
SetTypeId(
"ns3::WaypointMobilityModel");
88 for (uint32_t i = 0; i < mobilityCount; i++)
94 mobilityStack.push_back(model);
101 for (uint32_t iw = 0; iw < waypointCount; ++iw)
104 waypoints.push_back(wpt);
108 for (
auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i)
115 for (
auto w = waypoints.begin(); w != waypoints.end(); ++w)
122 for (
double updateTime = 0.5; updateTime <= ((double)waypointCount + 1.5); updateTime += 1.0)
137 for (
auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i)
157 sec - ((
double)((
int)sec)) + sec,
159 "Course didn't change on one second time boundary with NON-LAZY notifications");
166 "Course didn't change between waypoints with LAZY notifications");
179 :
TestCase(
"Check Waypoint Mobility Model waypoint add")
193 void DoRun()
override;
194 void DoTeardown()
override;
205 m_mobilityModel =
nullptr;
211 m_waypointCount = 10;
212 m_waypointCounter = 1;
215 mobilityFactory.
SetTypeId(
"ns3::WaypointMobilityModel");
228 Waypoint m_nextWaypoint(
Seconds(m_waypointCounter), Vector(0.0, 0.0, 0.0));
242 std::cout << now <<
" CourseChangeCallback" << std::endl;
246 if (now <
Seconds((
double)m_waypointCount))
249 m_nextWaypoint =
Waypoint(
Seconds(m_waypointCounter), Vector(0.0, 0.0, 0.0));
262 :
TestSuite(
"waypoint-mobility-model", UNIT)
Waypoint Mobility Model Add Waypoint Test.
~WaypointMobilityModelAddWaypointTest() override
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void CourseChangeCallback(Ptr< const MobilityModel > model)
Course change callback.
Ptr< MobilityModel > m_mobilityModel
mobility model
uint32_t m_waypointCount
waypoint count
WaypointMobilityModelAddWaypointTest()
uint32_t m_waypointCounter
waypoint counter
void DoRun() override
Implementation to actually run this TestCase.
Waypoint m_nextWaypoint
next waypoint
Waypoint Mobility Model Notify Test.
~WaypointMobilityModelNotifyTest() override
void CourseChangeCallback(Ptr< const MobilityModel > model)
Course change callback.
std::deque< Waypoint > waypoints
waypoints
uint32_t waypointCount
waypoint count
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
std::vector< Ptr< MobilityModel > > mobilityStack
mobilty model
WaypointMobilityModelNotifyTest(bool lazy)
Constructor.
uint32_t mobilityCount
mobility count
void ForceUpdates()
Force updates.
bool lazyNotify
lazy notify?
Keep track of the current position and velocity of an object.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void Initialize()
Invoke DoInitialize on all Objects aggregated to this one.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Time time
The waypoint time.
Waypoint-based mobility model.
virtual void Update() const
Update the underlying state corresponding to the stored waypoints.
void AddWaypoint(const Waypoint &waypoint)
WaypointMobilityModelTestSuite g_waypointMobilityModelTestSuite
the test suite
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void CourseChangeCallback(std::string path, Ptr< const MobilityModel > model)
This function will be used below as a trace sink, if the command-line argument or default value "useC...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Waypoint Mobility Model Test Suite.
WaypointMobilityModelTestSuite()