A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
mobility-model.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006,2007 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
#ifndef MOBILITY_MODEL_H
9
#define MOBILITY_MODEL_H
10
11
#include "ns3/mobility-export.h"
12
#include "ns3/object.h"
13
#include "ns3/traced-callback.h"
14
#include "ns3/vector.h"
15
16
namespace
ns3
17
{
18
19
/**
20
* @ingroup mobility
21
* @brief Keep track of the current position and velocity of an object.
22
*
23
* All space coordinates in this class and its subclasses are
24
* understood to be meters or meters/s. i.e., they are all
25
* metric international units.
26
*
27
* This is a base class for all specific mobility models.
28
*/
29
class
MOBILITY_EXPORT
MobilityModel
:
public
Object
30
{
31
public
:
32
/**
33
* Register this type with the TypeId system.
34
* @return the object TypeId
35
*/
36
static
TypeId
GetTypeId
();
37
MobilityModel
();
38
~MobilityModel
()
override
= 0;
39
40
/**
41
* Copy function allows one to copy the underlying MobilityModel
42
* from a MobilityModel pointer, by calling each children Copy implementation.
43
* This is primarily used by wraparound models for the spectrum channel.
44
*
45
* @return a copy of the current mobility model
46
*/
47
virtual
Ptr<MobilityModel>
Copy
()
const
= 0;
48
49
/**
50
* @return the current position
51
*/
52
Vector
GetPosition
()
const
;
53
/**
54
* This method may be used if the position returned may depend on some
55
* reference position provided. For example, in a hierarchical mobility
56
* model that is buildings-aware, the child mobility model may not be able
57
* to determine if it is inside or outside of a building unless it knows
58
* the parent position.
59
*
60
* @param referencePosition reference position to consider
61
* @return the current position based on the provided referencePosition
62
* \sa ns3::MobilityModel::DoGetPositionWithReference
63
*/
64
Vector
GetPositionWithReference
(
const
Vector& referencePosition)
const
;
65
/**
66
* @param position the position to set.
67
*/
68
void
SetPosition
(
const
Vector& position);
69
/**
70
* @return the current velocity.
71
*/
72
Vector
GetVelocity
()
const
;
73
/**
74
* @param position a reference to another mobility model
75
* @return the distance between the two objects. Unit is meters.
76
*/
77
double
GetDistanceFrom
(
Ptr<const MobilityModel>
position)
const
;
78
/**
79
* @param other reference to another object's mobility model
80
* @return the relative speed between the two objects. Unit is meters/s.
81
*/
82
double
GetRelativeSpeed
(
Ptr<const MobilityModel>
other)
const
;
83
/**
84
* Assign a fixed random variable stream number to the random variables
85
* used by this model. Return the number of streams (possibly zero) that
86
* have been assigned.
87
*
88
* @param stream first stream index to use
89
* @return the number of stream indices assigned by this model
90
*/
91
int64_t
AssignStreams
(int64_t stream);
92
93
/**
94
* TracedCallback signature.
95
*
96
* @param [in] model Value of the MobilityModel.
97
*/
98
typedef
void (*
TracedCallback
)(
Ptr<const MobilityModel>
model);
99
100
protected
:
101
/**
102
* Must be invoked by subclasses when the course of the
103
* position changes to notify course change listeners.
104
*/
105
void
NotifyCourseChange
()
const
;
106
107
private
:
108
/**
109
* @return the current position.
110
*
111
* Concrete subclasses of this base class must
112
* implement this method.
113
*/
114
virtual
Vector
DoGetPosition
()
const
= 0;
115
/**
116
* @param referencePosition the reference position to consider
117
* @return the current position.
118
*
119
* Unless subclasses override, this method will disregard the reference
120
* position and return "DoGetPosition ()".
121
*/
122
virtual
Vector
DoGetPositionWithReference
(
const
Vector& referencePosition)
const
;
123
/**
124
* @param position the position to set.
125
*
126
* Concrete subclasses of this base class must
127
* implement this method.
128
*/
129
virtual
void
DoSetPosition
(
const
Vector& position) = 0;
130
/**
131
* @return the current velocity.
132
*
133
* Concrete subclasses of this base class must
134
* implement this method.
135
*/
136
virtual
Vector
DoGetVelocity
()
const
= 0;
137
/**
138
* The default implementation does nothing but return the passed-in
139
* parameter. Subclasses using random variables are expected to
140
* override this.
141
* @param start starting stream index
142
* @return the number of streams used
143
*/
144
virtual
int64_t
DoAssignStreams
(int64_t start);
145
146
/**
147
* Used to alert subscribers that a change in direction, velocity,
148
* or position has occurred.
149
*/
150
ns3::TracedCallback<Ptr<const MobilityModel>
>
m_courseChangeTrace
;
151
};
152
153
}
// namespace ns3
154
155
#endif
/* MOBILITY_MODEL_H */
ns3::MobilityModel::m_courseChangeTrace
ns3::TracedCallback< Ptr< const MobilityModel > > m_courseChangeTrace
Used to alert subscribers that a change in direction, velocity, or position has occurred.
Definition
mobility-model.h:150
ns3::MobilityModel::GetPositionWithReference
Vector GetPositionWithReference(const Vector &referencePosition) const
This method may be used if the position returned may depend on some reference position provided.
Definition
mobility-model.cc:62
ns3::MobilityModel::GetTypeId
static TypeId GetTypeId()
Register this type with the TypeId system.
Definition
mobility-model.cc:21
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition
mobility-model.cc:87
ns3::MobilityModel::GetRelativeSpeed
double GetRelativeSpeed(Ptr< const MobilityModel > other) const
Definition
mobility-model.cc:95
ns3::MobilityModel::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition
mobility-model.cc:107
ns3::MobilityModel::Copy
virtual Ptr< MobilityModel > Copy() const =0
Copy function allows one to copy the underlying MobilityModel from a MobilityModel pointer,...
ns3::MobilityModel::TracedCallback
void(* TracedCallback)(Ptr< const MobilityModel > model)
TracedCallback signature.
Definition
mobility-model.h:98
ns3::MobilityModel::DoGetPosition
virtual Vector DoGetPosition() const =0
ns3::MobilityModel::DoGetPositionWithReference
virtual Vector DoGetPositionWithReference(const Vector &referencePosition) const
Definition
mobility-model.cc:69
ns3::MobilityModel::GetVelocity
Vector GetVelocity() const
Definition
mobility-model.cc:75
ns3::MobilityModel::DoSetPosition
virtual void DoSetPosition(const Vector &position)=0
ns3::MobilityModel::DoAssignStreams
virtual int64_t DoAssignStreams(int64_t start)
The default implementation does nothing but return the passed-in parameter.
Definition
mobility-model.cc:114
ns3::MobilityModel::GetPosition
Vector GetPosition() const
Definition
mobility-model.cc:56
ns3::MobilityModel::SetPosition
void SetPosition(const Vector &position)
Definition
mobility-model.cc:81
ns3::MobilityModel::NotifyCourseChange
void NotifyCourseChange() const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
Definition
mobility-model.cc:101
ns3::MobilityModel::DoGetVelocity
virtual Vector DoGetVelocity() const =0
ns3::MobilityModel::MobilityModel
MobilityModel()
Definition
mobility-model.cc:47
ns3::Object::Object
Object()
Constructor.
Definition
object.cc:96
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:67
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition
traced-callback.h:43
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
mobility
model
mobility-model.h
Generated on Wed Oct 1 2025 18:22:19 for ns-3 by
1.13.2