12#include "ns3/pointer.h"
13#include "ns3/random-variable-stream.h"
14#include "ns3/simulator.h"
15#include "ns3/string.h"
28 TypeId(
"ns3::RandomWaypointMobilityModel")
30 .SetGroupName(
"Mobility")
32 .AddAttribute(
"Speed",
33 "A random variable used to pick the speed of a random waypoint model.",
34 StringValue(
"ns3::UniformRandomVariable[Min=0.3|Max=0.7]"),
37 .AddAttribute(
"Pause",
38 "A random variable used to pick the pause of a random waypoint model.",
39 StringValue(
"ns3::ConstantRandomVariable[Constant=2.0]"),
42 .AddAttribute(
"PositionAllocator",
43 "The position model used to pick a destination point.",
63 Vector delta = destination - m_current;
64 double distance = delta.GetLength();
71 double k = distance ? speed / distance : 0;
123 int64_t positionStreamsAllocated;
127 positionStreamsAllocated =
m_position->AssignStreams(stream + 2);
128 return (2 + positionStreamsAllocated);
Vector GetCurrentPosition() const
Get current position vector.
Vector GetVelocity() const
Get velocity; if paused, will return a zero vector.
void Update() const
Update position, if not paused, from last position and time of last update.
void Unpause()
Resume mobility from current position at current velocity.
void SetPosition(const Vector &position)
Set position vector.
void SetVelocity(const Vector &vel)
Set new velocity vector.
void Pause()
Pause mobility at current position.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Keep track of the current position and velocity of an object.
void NotifyCourseChange() const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
virtual void DoInitialize()
Initialize() implementation.
AttributeValue implementation for Pointer.
virtual double GetValue()=0
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Random waypoint mobility model.
void BeginWalk()
Get next position, begin moving towards it, schedule future pause event.
ConstantVelocityHelper m_helper
helper for velocity computations
void DoInitializePrivate()
Begin current pause event, schedule future walk event.
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
Ptr< PositionAllocator > m_position
pointer to position allocator
Ptr< RandomVariableStream > m_speed
random variable to generate speeds
void DoInitialize() override
Initialize() implementation.
static TypeId GetTypeId()
Register this type with the TypeId system.
Vector DoGetPosition() const override
Ptr< RandomVariableStream > m_pause
random variable to generate pauses
EventId m_event
event ID of next scheduled event
Vector DoGetVelocity() const override
~RandomWaypointMobilityModel() override
void DoSetPosition(const Vector &position) override
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.