|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #include "ns3/simulator.h"
22 #include "ns3/random-variable-stream.h"
23 #include "ns3/pointer.h"
24 #include "ns3/string.h"
35 static TypeId tid =
TypeId (
"ns3::RandomWaypointMobilityModel")
37 .SetGroupName (
"Mobility")
39 .AddAttribute (
"Speed",
40 "A random variable used to pick the speed of a random waypoint model.",
41 StringValue (
"ns3::UniformRandomVariable[Min=0.3|Max=0.7]"),
43 MakePointerChecker<RandomVariableStream> ())
44 .AddAttribute (
"Pause",
45 "A random variable used to pick the pause of a random waypoint model.",
46 StringValue (
"ns3::ConstantRandomVariable[Constant=2.0]"),
48 MakePointerChecker<RandomVariableStream> ())
49 .AddAttribute (
"PositionAllocator",
50 "The position model used to pick a destination point.",
53 MakePointerChecker<PositionAllocator> ());
66 double dx = (destination.x - m_current.x);
67 double dy = (destination.y - m_current.y);
68 double dz = (destination.z - m_current.z);
69 double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
118 int64_t positionStreamsAllocated;
122 positionStreamsAllocated =
m_position->AssignStreams (stream + 2);
123 return (2 + positionStreamsAllocated);
a unique identifier for an interface.
void SetVelocity(const Vector &vel)
Set new velocity vector.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoSetPosition(const Vector &position)
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
Hold objects of type Ptr<T>.
ConstantVelocityHelper m_helper
helper for velocity computations
Random waypoint mobility model.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void DoInitializePrivate(void)
Begin current pause event, schedule future walk event.
Vector GetCurrentPosition(void) const
Get current position vector.
Ptr< PositionAllocator > m_position
pointer to position allocator
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Simulation virtual time values and global simulation resolution.
void Unpause(void)
Resume mobility from current position at current velocity.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual void DoInitialize(void)
Initialize() implementation.
EventId m_event
event ID of next scheduled event
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Hold variables of type string.
Ptr< RandomVariableStream > m_pause
random variable to generate pauses
virtual void DoInitialize(void)
Initialize() implementation.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
Time Seconds(double value)
Construct a Time in the indicated unit.
void Update(void) const
Update position, if not paused, from last position and time of last update.
void SetPosition(const Vector &position)
Set position vector.
Keep track of the current position and velocity of an object.
void BeginWalk(void)
Get next position, begin moving towards it, schedule future pause event.
Ptr< RandomVariableStream > m_speed
random variable to generate speeds
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
virtual Vector DoGetPosition(void) const
void Pause(void)
Pause mobility at current position.
virtual Vector DoGetVelocity(void) const
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Vector GetVelocity(void) const
Get velocity; if paused, will return a zero vector.