A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
gauss-markov-mobility-model.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 Dan Broyles
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Dan Broyles <dbroyl01@ku.edu>
7 * Thanks to Kevin Peters, faculty advisor James P.G. Sterbenz, and the ResiliNets
8 * initiative at The University of Kansas, https://resilinets.org
9 */
10#ifndef GAUSS_MARKOV_MOBILITY_MODEL_H
11#define GAUSS_MARKOV_MOBILITY_MODEL_H
12
13#include "box.h"
15#include "mobility-model.h"
16#include "position-allocator.h"
17
18#include "ns3/event-id.h"
19#include "ns3/nstime.h"
20#include "ns3/object.h"
21#include "ns3/ptr.h"
22#include "ns3/random-variable-stream.h"
23
24namespace ns3
25{
26
27/**
28 * @ingroup mobility
29 * @brief Gauss-Markov mobility model
30 *
31 * This is a 3D version of the Gauss-Markov mobility model described in [1].
32 * Unlike the other mobility models in ns-3, which are memoryless, the Gauss
33 * Markov model has both memory and variability. The tunable alpha parameter
34 * determines the how much memory and randomness you want to model.
35 * Each object starts with a specific velocity, direction (radians), and pitch
36 * angle (radians) equivalent to the mean velocity, direction, and pitch.
37 * At each timestep, a new velocity, direction, and pitch angle are generated
38 * based upon the previous value, the mean value, and a gaussian random variable.
39 * This version is suited for simple airplane flight, where direction, velocity,
40 * and pitch are the key variables.
41 * The motion field is limited by a 3D bounding box (called "box") which is a 3D
42 * version of the "rectangle" field that is used in 2-dimensional ns-3 mobility models.
43 *
44 * Here is an example of how to implement the model and set the initial node positions:
45 * @code
46 MobilityHelper mobility;
47
48 mobility.SetMobilityModel ("ns3::GaussMarkovMobilityModel",
49 "Bounds", BoxValue (Box (0, 150000, 0, 150000, 0, 10000)),
50 "TimeStep", TimeValue (Seconds (0.5)),
51 "Alpha", DoubleValue (0.85),
52 "MeanVelocity", StringValue ("ns3::UniformRandomVariable[Min=800|Max=1200]"),
53 "MeanDirection", StringValue ("ns3::UniformRandomVariable[Min=0|Max=6.283185307]"),
54 "MeanPitch", StringValue ("ns3::UniformRandomVariable[Min=0.05|Max=0.05]"),
55 "NormalVelocity", StringValue ("ns3::NormalRandomVariable[Mean=0.0|Variance=0.0|Bound=0.0]"),
56 "NormalDirection", StringValue ("ns3::NormalRandomVariable[Mean=0.0|Variance=0.2|Bound=0.4]"),
57 "NormalPitch", StringValue ("ns3::NormalRandomVariable[Mean=0.0|Variance=0.02|Bound=0.04]"));
58
59 mobility.SetPositionAllocator ("ns3::RandomBoxPositionAllocator",
60 "X", StringValue ("ns3::UniformRandomVariable[Min=0|Max=150000]"),
61 "Y", StringValue ("ns3::UniformRandomVariable[Min=0|Max=150000]"),
62 "Z", StringValue ("ns3::UniformRandomVariable[Min=0|Max=10000]"));
63
64 mobility.Install (wifiStaNodes);
65 * @endcode
66 * [1] Tracy Camp, Jeff Boleng, Vanessa Davies, "A Survey of Mobility Models
67 * for Ad Hoc Network Research", Wireless Communications and Mobile Computing,
68 * Wiley, vol.2 iss.5, September 2002, pp.483-502
69 */
71{
72 public:
73 /**
74 * Register this type with the TypeId system.
75 * @return the object TypeId
76 */
77 static TypeId GetTypeId();
80
81 // Inherited from MobilityModel
82 Ptr<MobilityModel> Copy() const override
83 {
85 }
86
87 private:
88 /**
89 * Initialize the model and calculate new velocity, direction, and pitch
90 */
91 void Start();
92 /**
93 * Perform a walk operation
94 * @param timeLeft time until Start method is called again
95 */
96 void DoWalk(Time timeLeft);
97 void DoDispose() override;
98 Vector DoGetPosition() const override;
99 void DoSetPosition(const Vector& position) override;
100 Vector DoGetVelocity() const override;
101 int64_t DoAssignStreams(int64_t) override;
102 ConstantVelocityHelper m_helper; //!< constant velocity helper
103 Time m_timeStep; //!< duraiton after which direction and speed should change
104 double m_alpha; //!< tunable constant in the model
105 double m_meanVelocity; //!< current mean velocity
106 double m_meanDirection; //!< current mean direction
107 double m_meanPitch; //!< current mean pitch
108 double m_Velocity; //!< current velocity
109 double m_Direction; //!< current direction
110 double m_Pitch; //!< current pitch
111 Ptr<RandomVariableStream> m_rndMeanVelocity; //!< rv used to assign avg velocity
112 Ptr<NormalRandomVariable> m_normalVelocity; //!< Gaussian rv used to for next velocity
113 Ptr<RandomVariableStream> m_rndMeanDirection; //!< rv used to assign avg direction
114 Ptr<NormalRandomVariable> m_normalDirection; //!< Gaussian rv for next direction value
115 Ptr<RandomVariableStream> m_rndMeanPitch; //!< rv used to assign avg. pitch
116 Ptr<NormalRandomVariable> m_normalPitch; //!< Gaussian rv for next pitch
117 EventId m_event; //!< event id of scheduled start
118 Box m_bounds; //!< bounding box
119};
120
121} // namespace ns3
122
123#endif /* GAUSS_MARKOV_MOBILITY_MODEL_H */
a 3d box
Definition box.h:24
Utility class used to move node with constant velocity.
An identifier for simulation events.
Definition event-id.h:44
Ptr< MobilityModel > Copy() const override
Copy function allows one to copy the underlying MobilityModel from a MobilityModel pointer,...
Ptr< NormalRandomVariable > m_normalDirection
Gaussian rv for next direction value.
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
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
void DoSetPosition(const Vector &position) override
Ptr< RandomVariableStream > m_rndMeanDirection
rv used to assign avg direction
double m_alpha
tunable constant in the model
Time m_timeStep
duraiton after which direction and speed should change
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
Simulation virtual time values and global simulation resolution.
Definition nstime.h:96
a unique identifier for an interface.
Definition type-id.h:49
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Every class exported by the ns3 library is enclosed in the ns3 namespace.