24#include <ns3/mobility-module.h>
26#include <ns3/simulator.h>
34 << mobility->GetObject<
Node>()->GetId() <<
")!\n";
41 NS_ASSERT_MSG(mobilityModel,
"Node doesn't have a mobility model");
42 mobilityModel->SetPosition(pos);
44 Vector newPos = mobilityModel->GetPosition();
47 << newPos.x <<
"," << newPos.y <<
"," << newPos.z <<
")\n";
51main(
int argc,
char* argv[])
61 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
64 positionAllocator->Add(Vector(0, 0, 0));
66 mobility.SetPositionAllocator(positionAllocator);
76 n1->AggregateObject(mob1);
77 mob1->SetPosition(Vector(0, 0, 0));
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
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.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
void MoveNode(Ptr< Node > node, const Vector &pos)
void CourseChangeCallback(Ptr< const MobilityModel > mobility)
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.