21 #include "ns3/simulator.h"
22 #include "ns3/double.h"
23 #include "ns3/pointer.h"
24 #include "ns3/string.h"
35 static TypeId tid =
TypeId (
"ns3::GaussMarkovMobilityModel")
37 .SetGroupName (
"Mobility")
39 .AddAttribute (
"Bounds",
40 "Bounds of the area to cruise.",
41 BoxValue (
Box (-100.0, 100.0, -100.0, 100.0, 0.0, 100.0)),
44 .AddAttribute (
"TimeStep",
45 "Change current direction and speed after moving for this time.",
49 .AddAttribute (
"Alpha",
50 "A constant representing the tunable parameter in the Gauss-Markov model.",
53 MakeDoubleChecker<double> ())
54 .AddAttribute (
"MeanVelocity",
55 "A random variable used to assign the average velocity.",
56 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
58 MakePointerChecker<RandomVariableStream> ())
59 .AddAttribute (
"MeanDirection",
60 "A random variable used to assign the average direction.",
61 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=6.283185307]"),
63 MakePointerChecker<RandomVariableStream> ())
64 .AddAttribute (
"MeanPitch",
65 "A random variable used to assign the average pitch.",
66 StringValue (
"ns3::ConstantRandomVariable[Constant=0.0]"),
68 MakePointerChecker<RandomVariableStream> ())
69 .AddAttribute (
"NormalVelocity",
70 "A gaussian random variable used to calculate the next velocity value.",
71 StringValue (
"ns3::NormalRandomVariable[Mean=0.0|Variance=1.0|Bound=10.0]"),
73 MakePointerChecker<NormalRandomVariable> ())
74 .AddAttribute (
"NormalDirection",
75 "A gaussian random variable used to calculate the next direction value.",
76 StringValue (
"ns3::NormalRandomVariable[Mean=0.0|Variance=1.0|Bound=10.0]"),
78 MakePointerChecker<NormalRandomVariable> ())
79 .AddAttribute (
"NormalPitch",
80 "A gaussian random variable used to calculate the next pitch value.",
81 StringValue (
"ns3::NormalRandomVariable[Mean=0.0|Variance=1.0|Bound=10.0]"),
83 MakePointerChecker<NormalRandomVariable> ());
127 double one_minus_alpha = 1 -
m_alpha;
135 double cosPit = std::cos (
m_Pitch);
137 double sinPit = std::sin (
m_Pitch);
154 Vector nextPosition = position;
155 nextPosition.x += speed.x * delayLeft.
GetSeconds ();
156 nextPosition.y += speed.y * delayLeft.
GetSeconds ();
157 nextPosition.z += speed.z * delayLeft.
GetSeconds ();
ConstantVelocityHelper m_helper
constant velocity helper
Simulation virtual time values and global simulation resolution.
double zMin
The z coordinate of the down bound of the box.
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
Time m_timeStep
duraiton after which direction and speed should change
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
GaussMarkovMobilityModel()
Hold variables of type string.
EventId m_event
event id of scheduled start
Ptr< RandomVariableStream > m_rndMeanDirection
rv used to assign avg direction
Vector GetCurrentPosition(void) const
Get current position vector.
void DoWalk(Time timeLeft)
Perform a walk operation.
virtual void DoDispose(void)
Destructor implementation.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
double xMax
The x coordinate of the right bound of the box.
virtual double GetValue(void)=0
Returns a random double from the underlying distribution.
double yMax
The y coordinate of the top bound of the box.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Keep track of the current position and velocity of an object.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
Ptr< RandomVariableStream > m_rndMeanVelocity
rv used to assign avg velocity
virtual void DoSetPosition(const Vector &position)
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
AttributeValue implementation for Time.
virtual Vector DoGetVelocity(void) const
double m_meanPitch
current mean pitch
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
void Update(void) const
Update position, if not paused, from last position and time of last update.
double m_alpha
tunable constant in the model
Ptr< const AttributeChecker > MakeBoxChecker(void)
AttributeValue implementation for Box.
double yMin
The y coordinate of the bottom bound of the box.
virtual void DoDispose(void)
Destructor implementation.
static void Remove(const EventId &id)
Remove an event from the event list.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeBoxAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Ptr< RandomVariableStream > m_rndMeanPitch
rv used to assign avg.
virtual Vector DoGetPosition(void) const
Ptr< NormalRandomVariable > m_normalDirection
Gaussian rv for next direction value.
double m_meanVelocity
current mean velocity
void SetVelocity(const Vector &vel)
Set new velocity vector.
double zMax
The z coordinate of the up bound of the box.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void Start(void)
Initialize the model and calculate new velocity, direction, and pitch.
Ptr< const AttributeAccessor > MakeDoubleAccessor(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.
void UpdateWithBounds(const Rectangle &rectangle) const
Update position, if not paused, from last position and time of last update.
Gauss-Markov mobility model.
Time Seconds(double value)
Construct a Time in the indicated unit.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
void Unpause(void)
Resume mobility from current position at current velocity.
Ptr< NormalRandomVariable > m_normalVelocity
Gaussian rv used to for next velocity.
double m_Direction
current direction
Ptr< NormalRandomVariable > m_normalPitch
Gaussian rv for next pitch.
bool IsInside(const Vector &position) const
void SetPosition(const Vector &position)
Set position vector.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
double m_Velocity
current velocity
a unique identifier for an interface.
double m_Pitch
current pitch
TypeId SetParent(TypeId tid)
double m_meanDirection
current mean direction
double xMin
The x coordinate of the left bound of the box.