23 #include "ns3/double.h"
24 #include "ns3/pointer.h"
25 #include "ns3/simulator.h"
26 #include "ns3/string.h"
39 TypeId(
"ns3::GaussMarkovMobilityModel")
41 .SetGroupName(
"Mobility")
43 .AddAttribute(
"Bounds",
44 "Bounds of the area to cruise.",
45 BoxValue(
Box(-100.0, 100.0, -100.0, 100.0, 0.0, 100.0)),
48 .AddAttribute(
"TimeStep",
49 "Change current direction and speed after moving for this time.",
55 "A constant representing the tunable parameter in the Gauss-Markov model.",
58 MakeDoubleChecker<double>())
59 .AddAttribute(
"MeanVelocity",
60 "A random variable used to assign the average velocity.",
61 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
63 MakePointerChecker<RandomVariableStream>())
64 .AddAttribute(
"MeanDirection",
65 "A random variable used to assign the average direction.",
66 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=6.283185307]"),
68 MakePointerChecker<RandomVariableStream>())
69 .AddAttribute(
"MeanPitch",
70 "A random variable used to assign the average pitch.",
71 StringValue(
"ns3::ConstantRandomVariable[Constant=0.0]"),
73 MakePointerChecker<RandomVariableStream>())
74 .AddAttribute(
"NormalVelocity",
75 "A gaussian random variable used to calculate the next velocity value.",
76 StringValue(
"ns3::NormalRandomVariable[Mean=0.0|Variance=1.0|Bound=10."
80 MakePointerChecker<NormalRandomVariable>())
83 "A gaussian random variable used to calculate the next direction value.",
84 StringValue(
"ns3::NormalRandomVariable[Mean=0.0|Variance=1.0|Bound=10.0]"),
86 MakePointerChecker<NormalRandomVariable>())
89 "A gaussian random variable used to calculate the next pitch value.",
90 StringValue(
"ns3::NormalRandomVariable[Mean=0.0|Variance=1.0|Bound=10.0]"),
92 MakePointerChecker<NormalRandomVariable>());
137 double one_minus_alpha = 1 -
m_alpha;
145 double cosPit = std::cos(
m_Pitch);
147 double sinPit = std::sin(
m_Pitch);
164 Vector nextPosition = position;
165 nextPosition.x += speed.x * delayLeft.
GetSeconds();
166 nextPosition.y += speed.y * delayLeft.
GetSeconds();
167 nextPosition.z += speed.z * delayLeft.
GetSeconds();
double yMax
The y coordinate of the top bound of the box.
bool IsInside(const Vector &position) const
double xMin
The x coordinate of the left bound of the box.
double yMin
The y coordinate of the bottom bound of the box.
double xMax
The x coordinate of the right bound of the box.
double zMin
The z coordinate of the down bound of the box.
double zMax
The z coordinate of the up bound of the box.
Vector GetCurrentPosition() const
Get current position vector.
Vector GetVelocity() const
Get velocity; if paused, will return a zero vector.
void Update() const
Update position, if not paused, from last position and time of last update.
void UpdateWithBounds(const Rectangle &rectangle) const
Update position, if not paused, from last position and time of last update.
void Unpause()
Resume mobility from current position at current velocity.
void SetPosition(const Vector &position)
Set position vector.
void SetVelocity(const Vector &vel)
Set new velocity vector.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
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()
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
Keep track of the current position and velocity of an object.
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.
virtual double GetValue()=0
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
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.
#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 AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)