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
* @return the current position
42
*/
43
Vector GetPosition()
const
;
44
/**
45
* This method may be used if the position returned may depend on some
46
* reference position provided. For example, in a hierarchical mobility
47
* model that is buildings-aware, the child mobility model may not be able
48
* to determine if it is inside or outside of a building unless it knows
49
* the parent position.
50
*
51
* @param referencePosition reference position to consider
52
* @return the current position based on the provided referencePosition
53
* \sa ns3::MobilityModel::DoGetPositionWithReference
54
*/
55
Vector GetPositionWithReference(
const
Vector& referencePosition)
const
;
56
/**
57
* @param position the position to set.
58
*/
59
void
SetPosition(
const
Vector& position);
60
/**
61
* @return the current velocity.
62
*/
63
Vector GetVelocity()
const
;
64
/**
65
* @param position a reference to another mobility model
66
* @return the distance between the two objects. Unit is meters.
67
*/
68
double
GetDistanceFrom(
Ptr<const MobilityModel>
position)
const
;
69
/**
70
* @param other reference to another object's mobility model
71
* @return the relative speed between the two objects. Unit is meters/s.
72
*/
73
double
GetRelativeSpeed(
Ptr<const MobilityModel>
other)
const
;
74
/**
75
* Assign a fixed random variable stream number to the random variables
76
* used by this model. Return the number of streams (possibly zero) that
77
* have been assigned.
78
*
79
* @param stream first stream index to use
80
* @return the number of stream indices assigned by this model
81
*/
82
int64_t AssignStreams(int64_t stream);
83
84
/**
85
* TracedCallback signature.
86
*
87
* @param [in] model Value of the MobilityModel.
88
*/
89
typedef
void (*
TracedCallback
)(
Ptr<const MobilityModel>
model);
90
91
protected
:
92
/**
93
* Must be invoked by subclasses when the course of the
94
* position changes to notify course change listeners.
95
*/
96
void
NotifyCourseChange()
const
;
97
98
private
:
99
/**
100
* @return the current position.
101
*
102
* Concrete subclasses of this base class must
103
* implement this method.
104
*/
105
virtual
Vector
DoGetPosition
()
const
= 0;
106
/**
107
* @param referencePosition the reference position to consider
108
* @return the current position.
109
*
110
* Unless subclasses override, this method will disregard the reference
111
* position and return "DoGetPosition ()".
112
*/
113
virtual
Vector DoGetPositionWithReference(
const
Vector& referencePosition)
const
;
114
/**
115
* @param position the position to set.
116
*
117
* Concrete subclasses of this base class must
118
* implement this method.
119
*/
120
virtual
void
DoSetPosition
(
const
Vector& position) = 0;
121
/**
122
* @return the current velocity.
123
*
124
* Concrete subclasses of this base class must
125
* implement this method.
126
*/
127
virtual
Vector
DoGetVelocity
()
const
= 0;
128
/**
129
* The default implementation does nothing but return the passed-in
130
* parameter. Subclasses using random variables are expected to
131
* override this.
132
* @param start starting stream index
133
* @return the number of streams used
134
*/
135
virtual
int64_t DoAssignStreams(int64_t start);
136
137
/**
138
* Used to alert subscribers that a change in direction, velocity,
139
* or position has occurred.
140
*/
141
ns3::TracedCallback<Ptr<const MobilityModel>
>
m_courseChangeTrace
;
142
};
143
144
}
// namespace ns3
145
146
#endif
/* MOBILITY_MODEL_H */
ns3::MobilityModel
Keep track of the current position and velocity of an object.
Definition
mobility-model.h:30
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:141
ns3::MobilityModel::DoGetPosition
virtual Vector DoGetPosition() const =0
ns3::MobilityModel::DoSetPosition
virtual void DoSetPosition(const Vector &position)=0
ns3::MobilityModel::DoGetVelocity
virtual Vector DoGetVelocity() const =0
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
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 Jul 9 2025 19:54:48 for ns-3 by
1.11.0