12#include "ns3/double.h"
13#include "ns3/pointer.h"
14#include "ns3/simulator.h"
15#include "ns3/string.h"
28 TypeId(
"ns3::GaussMarkovMobilityModel")
30 .SetGroupName(
"Mobility")
32 .AddAttribute(
"Bounds",
33 "Bounds of the area to cruise.",
34 BoxValue(
Box(-100.0, 100.0, -100.0, 100.0, 0.0, 100.0)),
37 .AddAttribute(
"TimeStep",
38 "Change current direction and speed after moving for this time.",
44 "A constant representing the tunable parameter in the Gauss-Markov model.",
48 .AddAttribute(
"MeanVelocity",
49 "A random variable used to assign the average velocity.",
50 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
53 .AddAttribute(
"MeanDirection",
54 "A random variable used to assign the average direction.",
55 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=6.283185307]"),
58 .AddAttribute(
"MeanPitch",
59 "A random variable used to assign the average pitch.",
60 StringValue(
"ns3::ConstantRandomVariable[Constant=0.0]"),
63 .AddAttribute(
"NormalVelocity",
64 "A gaussian random variable used to calculate the next velocity value.",
65 StringValue(
"ns3::NormalRandomVariable[Mean=0.0|Variance=1.0|Bound=10."
72 "A gaussian random variable used to calculate the next direction value.",
73 StringValue(
"ns3::NormalRandomVariable[Mean=0.0|Variance=1.0|Bound=10.0]"),
78 "A gaussian random variable used to calculate the next pitch value.",
79 StringValue(
"ns3::NormalRandomVariable[Mean=0.0|Variance=1.0|Bound=10.0]"),
131 double one_minus_alpha = 1 -
m_alpha;
139 double cosPit = std::cos(
m_Pitch);
141 double sinPit = std::sin(
m_Pitch);
145 m_helper.SetVelocity(Vector(vx, vy, vz));
156 Vector position =
m_helper.GetCurrentPosition();
157 Vector speed =
m_helper.GetVelocity();
158 Vector nextPosition = position;
159 nextPosition.x += speed.x * delayLeft.
GetSeconds();
160 nextPosition.y += speed.y * delayLeft.
GetSeconds();
161 nextPosition.z += speed.z * delayLeft.
GetSeconds();
170 if (
m_bounds.IsInside(nextPosition))
214 return m_helper.GetCurrentPosition();
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Gauss-Markov mobility model.
double m_Velocity
current velocity
Ptr< NormalRandomVariable > m_normalDirection
Gaussian rv for next direction value.
double m_Pitch
current pitch
void DoDispose() override
Destructor implementation.
Ptr< NormalRandomVariable > m_normalPitch
Gaussian rv for next pitch.
void Start()
Initialize the model and calculate new velocity, direction, and pitch.
void DoWalk(Time timeLeft)
Perform a walk operation.
double m_meanVelocity
current mean velocity
double m_meanDirection
current mean direction
static TypeId GetTypeId()
Register this type with the TypeId system.
Ptr< NormalRandomVariable > m_normalVelocity
Gaussian rv used to for next velocity.
EventId m_event
event id of scheduled start
ConstantVelocityHelper m_helper
constant velocity helper
Vector DoGetVelocity() const override
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
Ptr< RandomVariableStream > m_rndMeanPitch
rv used to assign avg.
Ptr< RandomVariableStream > m_rndMeanVelocity
rv used to assign avg velocity
~GaussMarkovMobilityModel() override
GaussMarkovMobilityModel()
double m_meanPitch
current mean pitch
void DoSetPosition(const Vector &position) override
Ptr< RandomVariableStream > m_rndMeanDirection
rv used to assign avg direction
Vector DoGetPosition() const override
double m_alpha
tunable constant in the model
double m_Direction
current direction
Time m_timeStep
duraiton after which direction and speed should change
void NotifyCourseChange() const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
virtual void DoDispose()
Destructor implementation.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeBoxAccessor(T1 a1)
Ptr< const AttributeChecker > MakeBoxChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.