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/object.h"
12
#include "ns3/traced-callback.h"
13
#include "ns3/vector.h"
14
15
namespace
ns3
16
{
17
18
/**
19
* @ingroup mobility
20
* @brief Keep track of the current position and velocity of an object.
21
*
22
* All space coordinates in this class and its subclasses are
23
* understood to be meters or meters/s. i.e., they are all
24
* metric international units.
25
*
26
* This is a base class for all specific mobility models.
27
*/
28
class
MobilityModel
:
public
Object
29
{
30
public
:
31
/**
32
* Register this type with the TypeId system.
33
* @return the object TypeId
34
*/
35
static
TypeId
GetTypeId
();
36
MobilityModel
();
37
~MobilityModel
()
override
= 0;
38
39
/**
40
* @return the current position
41
*/
42
Vector
GetPosition
()
const
;
43
/**
44
* This method may be used if the position returned may depend on some
45
* reference position provided. For example, in a hierarchical mobility
46
* model that is buildings-aware, the child mobility model may not be able
47
* to determine if it is inside or outside of a building unless it knows
48
* the parent position.
49
*
50
* @param referencePosition reference position to consider
51
* @return the current position based on the provided referencePosition
52
* \sa ns3::MobilityModel::DoGetPositionWithReference
53
*/
54
Vector
GetPositionWithReference
(
const
Vector& referencePosition)
const
;
55
/**
56
* @param position the position to set.
57
*/
58
void
SetPosition
(
const
Vector& position);
59
/**
60
* @return the current velocity.
61
*/
62
Vector
GetVelocity
()
const
;
63
/**
64
* @param position a reference to another mobility model
65
* @return the distance between the two objects. Unit is meters.
66
*/
67
double
GetDistanceFrom
(
Ptr<const MobilityModel>
position)
const
;
68
/**
69
* @param other reference to another object's mobility model
70
* @return the relative speed between the two objects. Unit is meters/s.
71
*/
72
double
GetRelativeSpeed
(
Ptr<const MobilityModel>
other)
const
;
73
/**
74
* Assign a fixed random variable stream number to the random variables
75
* used by this model. Return the number of streams (possibly zero) that
76
* have been assigned.
77
*
78
* @param stream first stream index to use
79
* @return the number of stream indices assigned by this model
80
*/
81
int64_t
AssignStreams
(int64_t stream);
82
83
/**
84
* TracedCallback signature.
85
*
86
* @param [in] model Value of the MobilityModel.
87
*/
88
typedef
void (*
TracedCallback
)(
Ptr<const MobilityModel>
model);
89
90
protected
:
91
/**
92
* Must be invoked by subclasses when the course of the
93
* position changes to notify course change listeners.
94
*/
95
void
NotifyCourseChange
()
const
;
96
97
private
:
98
/**
99
* @return the current position.
100
*
101
* Concrete subclasses of this base class must
102
* implement this method.
103
*/
104
virtual
Vector
DoGetPosition
()
const
= 0;
105
/**
106
* @param referencePosition the reference position to consider
107
* @return the current position.
108
*
109
* Unless subclasses override, this method will disregard the reference
110
* position and return "DoGetPosition ()".
111
*/
112
virtual
Vector
DoGetPositionWithReference
(
const
Vector& referencePosition)
const
;
113
/**
114
* @param position the position to set.
115
*
116
* Concrete subclasses of this base class must
117
* implement this method.
118
*/
119
virtual
void
DoSetPosition
(
const
Vector& position) = 0;
120
/**
121
* @return the current velocity.
122
*
123
* Concrete subclasses of this base class must
124
* implement this method.
125
*/
126
virtual
Vector
DoGetVelocity
()
const
= 0;
127
/**
128
* The default implementation does nothing but return the passed-in
129
* parameter. Subclasses using random variables are expected to
130
* override this.
131
* @param start starting stream index
132
* @return the number of streams used
133
*/
134
virtual
int64_t
DoAssignStreams
(int64_t start);
135
136
/**
137
* Used to alert subscribers that a change in direction, velocity,
138
* or position has occurred.
139
*/
140
ns3::TracedCallback<Ptr<const MobilityModel>
>
m_courseChangeTrace
;
141
};
142
143
}
// namespace ns3
144
145
#endif
/* MOBILITY_MODEL_H */
ns3::MobilityModel
Keep track of the current position and velocity of an object.
Definition
mobility-model.h:29
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:140
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::~MobilityModel
~MobilityModel() override=0
Definition
mobility-model.cc:51
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::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
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:48
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
mobility
model
mobility-model.h
Generated on Fri Nov 8 2024 19:36:35 for ns-3 by
1.11.0