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 ();
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.
AttributeValue implementation for Box.
void Unpause(void)
Resume mobility from current position at current velocity.
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.
void SetPosition(const Vector &position)
Set position vector.
void SetVelocity(const Vector &vel)
Set new velocity vector.
void Update(void) const
Update position, if not paused, from last position and time of last update.
Vector GetCurrentPosition(void) const
Get current position vector.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void Cancel(void)
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
Ptr< NormalRandomVariable > m_normalPitch
Gaussian rv for next pitch.
void DoWalk(Time timeLeft)
Perform a walk operation.
double m_meanVelocity
current mean velocity
double m_meanDirection
current mean direction
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
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
virtual Vector DoGetPosition(void) const
Ptr< RandomVariableStream > m_rndMeanPitch
rv used to assign avg.
Ptr< RandomVariableStream > m_rndMeanVelocity
rv used to assign avg velocity
virtual void DoDispose(void)
Destructor implementation.
GaussMarkovMobilityModel()
void Start(void)
Initialize the model and calculate new velocity, direction, and pitch.
double m_meanPitch
current mean pitch
virtual void DoSetPosition(const Vector &position)
Ptr< RandomVariableStream > m_rndMeanDirection
rv used to assign avg direction
double m_alpha
tunable constant in the model
double m_Direction
current direction
static TypeId GetTypeId(void)
Register this type with the TypeId system.
Time m_timeStep
duraiton after which direction and speed should change
virtual Vector DoGetVelocity(void) const
Keep track of the current position and velocity of an object.
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
virtual void DoDispose(void)
Destructor implementation.
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &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(void) const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< const AttributeAccessor > MakeBoxAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeBoxChecker(void)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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 AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.