20 #include "ns3/simulator.h"
24 #include "ns3/string.h"
25 #include "ns3/pointer.h"
41 static TypeId tid =
TypeId (
"ns3::RandomDirection2dMobilityModel")
43 .SetGroupName (
"Mobility")
45 .AddAttribute (
"Bounds",
"The 2d bounding area",
48 MakeRectangleChecker ())
49 .AddAttribute (
"Speed",
"A random variable to control the speed (m/s).",
50 StringValue (
"ns3::UniformRandomVariable[Min=1.0|Max=2.0]"),
52 MakePointerChecker<RandomVariableStream> ())
53 .AddAttribute (
"Pause",
"A random variable to control the pause (s).",
54 StringValue (
"ns3::ConstantRandomVariable[Constant=2.0]"),
56 MakePointerChecker<RandomVariableStream> ())
63 m_direction = CreateObject <UniformRandomVariable> ();
104 const Vector vector (std::cos (direction) * speed,
105 std::sin (direction) * speed,
129 direction += -
PI / 2;
NS_LOG_COMPONENT_DEFINE("RandomDirection2dMobilityModel")
Ptr< UniformRandomVariable > m_direction
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.
Vector CalculateIntersection(const Vector ¤t, const Vector &speed) const
hold variables of type string
virtual Vector DoGetVelocity(void) const
Ptr< RandomVariableStream > m_speed
void ResetDirectionAndSpeed(void)
Vector GetCurrentPosition(void) const
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
ConstantVelocityHelper m_helper
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
void DoInitializePrivate(void)
virtual double GetValue(void)=0
Returns a random double from the underlying distribution.
hold objects of type ns3::Rectangle
Keep track of the current position and velocity of an object.
double CalculateDistance(const Vector3D &a, const Vector3D &b)
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
virtual void DoSetPosition(const Vector &position)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
static void Remove(const EventId &id)
Remove an event from the event list.
void SetVelocity(const Vector &vel)
RandomDirection2dMobilityModel()
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
static TypeId GetTypeId(void)
Vector GetVelocity(void) const
Side GetClosestSide(const Vector &position) const
void UpdateWithBounds(const Rectangle &rectangle) const
void SetDirectionAndSpeed(double direction)
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Ptr< RandomVariableStream > m_pause
void SetPosition(const Vector &position)
Random direction mobility model.
virtual Vector DoGetPosition(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.