|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/double.h"
23 #include "ns3/string.h"
24 #include "ns3/pointer.h"
25 #include "ns3/simulator.h"
38 static TypeId tid =
TypeId (
"ns3::RandomWalk2dMobilityModel")
40 .SetGroupName (
"Mobility")
42 .AddAttribute (
"Bounds",
43 "Bounds of the area to cruise.",
47 .AddAttribute (
"Time",
48 "Change current direction and speed after moving for this delay.",
52 .AddAttribute (
"Distance",
53 "Change current direction and speed after moving for this distance.",
56 MakeDoubleChecker<double> ())
57 .AddAttribute (
"Mode",
58 "The mode indicates the condition used to "
59 "change the current speed and direction",
64 .AddAttribute (
"Direction",
65 "A random variable used to pick the direction (radians).",
66 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=6.283184]"),
68 MakePointerChecker<RandomVariableStream> ())
69 .AddAttribute (
"Speed",
70 "A random variable used to pick the speed (m/s).",
71 StringValue (
"ns3::UniformRandomVariable[Min=2.0|Max=4.0]"),
73 MakePointerChecker<RandomVariableStream> ());
90 Vector vector (std::cos (direction) * speed,
91 std::sin (direction) * speed,
113 Vector nextPosition = position;
114 nextPosition.x += speed.x * delayLeft.
GetSeconds ();
115 nextPosition.y += speed.y * delayLeft.
GetSeconds ();
124 Time delay =
Seconds ((nextPosition.x - position.x) / speed.x);
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetVelocity(const Vector &vel)
Set new velocity vector.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
void Rebound(Time timeLeft)
Performs the rebound of the node if it reaches a boundary.
AttributeValue implementation for Rectangle.
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
Ptr< RandomVariableStream > m_speed
rv for picking speed
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.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
Ptr< const AttributeAccessor > MakeRectangleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Time m_modeTime
Change current direction and speed after this delay.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
EventId m_event
stored event ID
Vector GetCurrentPosition(void) const
Get current position vector.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
ConstantVelocityHelper m_helper
helper for this object
Vector CalculateIntersection(const Vector ¤t, const Vector &speed) const
Simulation virtual time values and global simulation resolution.
virtual void DoInitialize(void)
Initialize() implementation.
void Unpause(void)
Resume mobility from current position at current velocity.
virtual void DoInitialize(void)
Initialize() implementation.
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< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual Vector DoGetPosition(void) const
void DoWalk(Time timeLeft)
Walk according to position and velocity, until distance is reached, time is reached,...
virtual void DoSetPosition(const Vector &position)
void DoInitializePrivate(void)
Perform initialization of the object before MobilityModel::DoInitialize ()
virtual Vector DoGetVelocity(void) const
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
void UpdateWithBounds(const Rectangle &rectangle) const
Update position, if not paused, from last position and time of last update.
Ptr< const AttributeChecker > MakeRectangleChecker(void)
Time Seconds(double value)
Construct a Time in the indicated unit.
Rectangle m_bounds
Bounds of the area to cruise.
void Update(void) const
Update position, if not paused, from last position and time of last update.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Side GetClosestSide(const Vector &position) const
AttributeValue implementation for Time.
void SetPosition(const Vector &position)
Set position vector.
Ptr< RandomVariableStream > m_direction
rv for picking direction
Keep track of the current position and velocity of an object.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
double m_modeDistance
Change direction and speed after this distance.
bool IsInside(const Vector &position) const
virtual void DoDispose(void)
Destructor implementation.
virtual void DoDispose(void)
Destructor implementation.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
enum Mode m_mode
whether in time or distance mode
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Vector GetVelocity(void) const
Get velocity; if paused, will return a zero vector.
2D random walk mobility model.