21 #include "ns3/simulator.h"
22 #include "ns3/double.h"
34 static TypeId tid =
TypeId (
"ns3::SteadyStateRandomWaypointMobilityModel")
36 .SetGroupName (
"Mobility")
38 .AddAttribute (
"MinSpeed",
39 "Minimum speed value, [m/s]",
42 MakeDoubleChecker<double> ())
43 .AddAttribute (
"MaxSpeed",
44 "Maximum speed value, [m/s]",
47 MakeDoubleChecker<double> ())
48 .AddAttribute (
"MinPause",
49 "Minimum pause value, [s]",
52 MakeDoubleChecker<double> ())
53 .AddAttribute (
"MaxPause",
54 "Maximum pause value, [s]",
57 MakeDoubleChecker<double> ())
58 .AddAttribute (
"MinX",
59 "Minimum X value of traveling region, [m]",
62 MakeDoubleChecker<double> ())
63 .AddAttribute (
"MaxX",
64 "Maximum X value of traveling region, [m]",
67 MakeDoubleChecker<double> ())
68 .AddAttribute (
"MinY",
69 "Minimum Y value of traveling region, [m]",
72 MakeDoubleChecker<double> ())
73 .AddAttribute (
"MaxY",
74 "Maximum Y value of traveling region, [m]",
77 MakeDoubleChecker<double> ())
79 "Z value of traveling region (fixed), [m]",
82 MakeDoubleChecker<double> ());
88 alreadyStarted (false)
90 m_speed = CreateObject<UniformRandomVariable> ();
91 m_pause = CreateObject<UniformRandomVariable> ();
92 m_x1_r = CreateObject<UniformRandomVariable> ();
93 m_y1_r = CreateObject<UniformRandomVariable> ();
94 m_x2_r = CreateObject<UniformRandomVariable> ();
95 m_y2_r = CreateObject<UniformRandomVariable> ();
96 m_u_r = CreateObject<UniformRandomVariable> ();
97 m_x = CreateObject<UniformRandomVariable> ();
98 m_y = CreateObject<UniformRandomVariable> ();
119 m_position = CreateObject<RandomRectanglePositionAllocator> ();
139 double log1 = b*b / a*std::log (std::sqrt ((a*a)/(b*b) + 1) + a/b);
140 double log2 = a*a / b*std::log (std::sqrt ((b*b)/(a*a) + 1) + b/a);
141 double expectedTravelTime = 1.0/6.0*(log1 + log2);
142 expectedTravelTime += 1.0/15.0*((a*a*a)/(b*b) + (b*b*b)/(a*a)) -
143 1.0/15.0*std::sqrt (a*a + b*b)*((a*a)/(b*b) + (b*b)/(a*a) - 3);
146 expectedTravelTime /= v0;
150 expectedTravelTime *= std::log (v1/v0)/(v1 - v0);
152 double probabilityPaused = expectedPauseTime/(expectedPauseTime + expectedTravelTime);
153 NS_ASSERT (probabilityPaused >= 0 && probabilityPaused <= 1);
156 if (u < probabilityPaused)
176 pause = Seconds (u*expectedPauseTime);
183 double x1, x2, y1, y2;
193 r = std::sqrt (((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))/(a*a + b*b));
216 double dx = (destination.
x - m_current.
x);
217 double dy = (destination.
y - m_current.
y);
218 double dz = (destination.
z - m_current.
z);
219 double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
238 double dx = (destination.
x - m_current.
x);
239 double dy = (destination.
y - m_current.
y);
240 double dz = (destination.
z - m_current.
z);
241 double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
285 int64_t positionStreamsAllocated = 0;
295 positionStreamsAllocated =
m_position->AssignStreams (stream + 9);
296 return (9 + positionStreamsAllocated);
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
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< UniformRandomVariable > m_speed
Ptr< UniformRandomVariable > m_pause
Vector GetCurrentPosition(void) const
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Ptr< UniformRandomVariable > m_x1_r
SteadyStateRandomWaypointMobilityModel()
bool IsRunning(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
Ptr< UniformRandomVariable > m_u_r
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Ptr< UniformRandomVariable > m_x2_r
ConstantVelocityHelper m_helper
void SteadyStateBeginWalk(const Vector &destination)
Keep track of the current position and velocity of an object.
Ptr< UniformRandomVariable > m_y2_r
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)
Ptr< RandomRectanglePositionAllocator > m_position
Steady-state random waypoint mobility model.
static void Remove(const EventId &id)
Remove an event from the event list.
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.
Vector GetVelocity(void) const
virtual Vector DoGetPosition(void) const
virtual Vector DoGetVelocity(void) const
Ptr< UniformRandomVariable > m_y1_r
Ptr< UniformRandomVariable > m_y
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
static TypeId GetTypeId(void)
void SetPosition(const Vector &position)
Hold a floating point type.
void SetAttribute(std::string name, const AttributeValue &value)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Ptr< UniformRandomVariable > m_x
void DoInitializePrivate(void)
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
double z
z coordinate of vector