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
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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 the RngStream.
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.
Ptr< const AttributeChecker > MakeBoxChecker(void)
Vector GetCurrentPosition(void) const
Get current position vector.
EventId m_event
event id of scheduled start
Ptr< RandomVariableStream > m_rndMeanDirection
rv used to assign avg direction
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void DoWalk(Time timeLeft)
Perform a walk operation.
virtual void DoDispose(void)
Destructor implementation.
double xMax
The x coordinate of the right bound of the box.
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
double yMax
The y coordinate of the top bound of the box.
Keep track of the current position and velocity of an object.
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...
void Update(void) const
Update position, if not paused, from last position and time of last update.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
AttributeValue implementation for Time.
double m_meanPitch
current mean pitch
double m_alpha
tunable constant in the model
AttributeValue implementation for Box.
double yMin
The y coordinate of the bottom bound of the box.
virtual void DoDispose(void)
Destructor implementation.
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.
Ptr< NormalRandomVariable > m_normalDirection
Gaussian rv for next direction value.
void UpdateWithBounds(const Rectangle &rectangle) const
Update position, if not paused, from last position and time of last update.
double m_meanVelocity
current mean velocity
virtual Vector DoGetPosition(void) const
void SetVelocity(const Vector &vel)
Set new velocity vector.
double zMax
The z coordinate of the up bound of the box.
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.
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual Vector DoGetVelocity(void) const
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.
Vector GetVelocity(void) const
Get velocity; if paused, will return a zero vector.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
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< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< NormalRandomVariable > m_normalPitch
Gaussian rv for next pitch.
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.
bool IsInside(const Vector &position) const
double m_Pitch
current pitch
TypeId SetParent(TypeId tid)
Set the parent TypeId.
double m_meanDirection
current mean direction
double xMin
The x coordinate of the left bound of the box.