22 #include "ns3/double.h"
23 #include "ns3/string.h"
24 #include "ns3/pointer.h"
25 #include "ns3/simulator.h"
39 static TypeId tid =
TypeId (
"ns3::RandomWalk2dMobilityModel")
41 .SetGroupName (
"Mobility")
43 .AddAttribute (
"Bounds",
44 "Bounds of the area to cruise.",
47 MakeRectangleChecker ())
48 .AddAttribute (
"Time",
49 "Change current direction and speed after moving for this delay.",
53 .AddAttribute (
"Distance",
54 "Change current direction and speed after moving for this distance.",
57 MakeDoubleChecker<double> ())
58 .AddAttribute (
"Mode",
59 "The mode indicates the condition used to "
60 "change the current speed and direction",
65 .AddAttribute (
"Direction",
66 "A random variable used to pick the direction (gradients).",
67 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=6.283184]"),
69 MakePointerChecker<RandomVariableStream> ())
70 .AddAttribute (
"Speed",
71 "A random variable used to pick the speed (m/s).",
72 StringValue (
"ns3::UniformRandomVariable[Min=2.0|Max=4.0]"),
74 MakePointerChecker<RandomVariableStream> ());
91 Vector vector (std::cos (direction) * speed,
92 std::sin (direction) * speed,
114 Vector nextPosition = position;
125 Time delay = Seconds ((nextPosition.
x - position.
x) / speed.
x);
NS_LOG_COMPONENT_DEFINE("RandomWalk2d")
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.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
virtual Vector DoGetPosition(void) const
Vector CalculateIntersection(const Vector ¤t, const Vector &speed) const
hold variables of type string
Vector GetCurrentPosition(void) const
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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.
hold objects of type ns3::Rectangle
virtual Vector DoGetVelocity(void) const
Keep track of the current position and velocity of an object.
2D random walk mobility model.
double GetSeconds(void) const
ConstantVelocityHelper m_helper
hold variables of type 'enum'
virtual void DoSetPosition(const Vector &position)
hold objects of type ns3::Time
bool IsInside(const Vector &position) const
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
void Rebound(Time timeLeft)
static TypeId GetTypeId(void)
static void Remove(const EventId &id)
Remove an event from the event list.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Ptr< RandomVariableStream > m_speed
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.
void DoWalk(Time timeLeft)
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Vector GetVelocity(void) const
Side GetClosestSide(const Vector &position) const
void UpdateWithBounds(const Rectangle &rectangle) const
Ptr< RandomVariableStream > m_direction
void DoInitializePrivate(void)
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void SetPosition(const Vector &position)
Hold a floating point type.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
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.