21 #include "ns3/simulator.h"
22 #include "ns3/random-variable-stream.h"
23 #include "ns3/pointer.h"
24 #include "ns3/string.h"
36 static TypeId tid =
TypeId (
"ns3::RandomWaypointMobilityModel")
38 .SetGroupName (
"Mobility")
40 .AddAttribute (
"Speed",
41 "A random variable used to pick the speed of a random waypoint model.",
42 StringValue (
"ns3::UniformRandomVariable[Min=0.3|Max=0.7]"),
44 MakePointerChecker<RandomVariableStream> ())
45 .AddAttribute (
"Pause",
46 "A random variable used to pick the pause of a random waypoint model.",
47 StringValue (
"ns3::ConstantRandomVariable[Constant=2.0]"),
49 MakePointerChecker<RandomVariableStream> ())
50 .AddAttribute (
"PositionAllocator",
51 "The position model used to pick a destination point.",
54 MakePointerChecker<PositionAllocator> ());
67 double dx = (destination.
x - m_current.
x);
68 double dy = (destination.
y - m_current.
y);
69 double dz = (destination.
z - m_current.
z);
70 double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
119 int64_t positionStreamsAllocated;
123 positionStreamsAllocated =
m_position->AssignStreams (stream + 2);
124 return (2 + positionStreamsAllocated);
double x
x coordinate of vector
keep track of time values and allow control of global simulation resolution
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
hold variables of type string
Random waypoint mobility model.
Vector GetCurrentPosition(void) const
static TypeId GetTypeId(void)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Ptr< PositionAllocator > m_position
Ptr< RandomVariableStream > m_speed
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
virtual double GetValue(void)=0
Returns a random double from the underlying distribution.
Keep track of the current position and velocity of an object.
void DoInitializePrivate(void)
double CalculateDistance(const Vector3D &a, const Vector3D &b)
virtual Vector DoGetVelocity(void) const
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
ConstantVelocityHelper m_helper
static void Remove(const EventId &id)
Remove an event from the event list.
void SetVelocity(const Vector &vel)
double y
y coordinate of vector
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
virtual void DoSetPosition(const Vector &position)
#define NS_ASSERT_MSG(condition, message)
Ptr< RandomVariableStream > m_pause
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
Vector GetVelocity(void) const
virtual Vector DoGetPosition(void) const
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
void SetPosition(const Vector &position)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
double z
z coordinate of vector