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
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
#ifndef MOBILITY_MODEL_H
20
#define MOBILITY_MODEL_H
21
22
#include "ns3/object.h"
23
#include "ns3/traced-callback.h"
24
#include "ns3/vector.h"
25
26
namespace
ns3
27
{
28
29
/**
30
* \ingroup mobility
31
* \brief Keep track of the current position and velocity of an object.
32
*
33
* All space coordinates in this class and its subclasses are
34
* understood to be meters or meters/s. i.e., they are all
35
* metric international units.
36
*
37
* This is a base class for all specific mobility models.
38
*/
39
class
MobilityModel
:
public
Object
40
{
41
public
:
42
/**
43
* Register this type with the TypeId system.
44
* \return the object TypeId
45
*/
46
static
TypeId
GetTypeId
();
47
MobilityModel
();
48
~MobilityModel
()
override
= 0;
49
50
/**
51
* \return the current position
52
*/
53
Vector
GetPosition
()
const
;
54
/**
55
* This method may be used if the position returned may depend on some
56
* reference position provided. For example, in a hierarchical mobility
57
* model that is buildings-aware, the child mobility model may not be able
58
* to determine if it is inside or outside of a building unless it knows
59
* the parent position.
60
*
61
* \param referencePosition reference position to consider
62
* \return the current position based on the provided referencePosition
63
* \sa ns3::MobilityModel::DoGetPositionWithReference
64
*/
65
Vector
GetPositionWithReference
(
const
Vector& referencePosition)
const
;
66
/**
67
* \param position the position to set.
68
*/
69
void
SetPosition
(
const
Vector& position);
70
/**
71
* \return the current velocity.
72
*/
73
Vector
GetVelocity
()
const
;
74
/**
75
* \param position a reference to another mobility model
76
* \return the distance between the two objects. Unit is meters.
77
*/
78
double
GetDistanceFrom
(
Ptr<const MobilityModel>
position)
const
;
79
/**
80
* \param other reference to another object's mobility model
81
* \return the relative speed between the two objects. Unit is meters/s.
82
*/
83
double
GetRelativeSpeed
(
Ptr<const MobilityModel>
other)
const
;
84
/**
85
* Assign a fixed random variable stream number to the random variables
86
* used by this model. Return the number of streams (possibly zero) that
87
* have been assigned.
88
*
89
* \param stream first stream index to use
90
* \return the number of stream indices assigned by this model
91
*/
92
int64_t
AssignStreams
(int64_t stream);
93
94
/**
95
* TracedCallback signature.
96
*
97
* \param [in] model Value of the MobilityModel.
98
*/
99
typedef
void (*
TracedCallback
)(
Ptr<const MobilityModel>
model);
100
101
protected
:
102
/**
103
* Must be invoked by subclasses when the course of the
104
* position changes to notify course change listeners.
105
*/
106
void
NotifyCourseChange
()
const
;
107
108
private
:
109
/**
110
* \return the current position.
111
*
112
* Concrete subclasses of this base class must
113
* implement this method.
114
*/
115
virtual
Vector
DoGetPosition
()
const
= 0;
116
/**
117
* \param referencePosition the reference position to consider
118
* \return the current position.
119
*
120
* Unless subclasses override, this method will disregard the reference
121
* position and return "DoGetPosition ()".
122
*/
123
virtual
Vector
DoGetPositionWithReference
(
const
Vector& referencePosition)
const
;
124
/**
125
* \param position the position to set.
126
*
127
* Concrete subclasses of this base class must
128
* implement this method.
129
*/
130
virtual
void
DoSetPosition
(
const
Vector& position) = 0;
131
/**
132
* \return the current velocity.
133
*
134
* Concrete subclasses of this base class must
135
* implement this method.
136
*/
137
virtual
Vector
DoGetVelocity
()
const
= 0;
138
/**
139
* The default implementation does nothing but return the passed-in
140
* parameter. Subclasses using random variables are expected to
141
* override this.
142
* \param start starting stream index
143
* \return the number of streams used
144
*/
145
virtual
int64_t
DoAssignStreams
(int64_t start);
146
147
/**
148
* Used to alert subscribers that a change in direction, velocity,
149
* or position has occurred.
150
*/
151
ns3::TracedCallback<Ptr<const MobilityModel>
>
m_courseChangeTrace
;
152
};
153
154
}
// namespace ns3
155
156
#endif
/* MOBILITY_MODEL_H */
ns3::MobilityModel
Keep track of the current position and velocity of an object.
Definition:
mobility-model.h:40
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:151
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:73
ns3::MobilityModel::GetTypeId
static TypeId GetTypeId()
Register this type with the TypeId system.
Definition:
mobility-model.cc:32
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition:
mobility-model.cc:98
ns3::MobilityModel::~MobilityModel
~MobilityModel() override=0
Definition:
mobility-model.cc:62
ns3::MobilityModel::GetRelativeSpeed
double GetRelativeSpeed(Ptr< const MobilityModel > other) const
Definition:
mobility-model.cc:106
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:118
ns3::MobilityModel::DoGetPosition
virtual Vector DoGetPosition() const =0
ns3::MobilityModel::DoGetPositionWithReference
virtual Vector DoGetPositionWithReference(const Vector &referencePosition) const
Definition:
mobility-model.cc:80
ns3::MobilityModel::GetVelocity
Vector GetVelocity() const
Definition:
mobility-model.cc:86
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:125
ns3::MobilityModel::GetPosition
Vector GetPosition() const
Definition:
mobility-model.cc:67
ns3::MobilityModel::SetPosition
void SetPosition(const Vector &position)
Definition:
mobility-model.cc:92
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:112
ns3::MobilityModel::DoGetVelocity
virtual Vector DoGetVelocity() const =0
ns3::MobilityModel::MobilityModel
MobilityModel()
Definition:
mobility-model.cc:58
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition:
traced-callback.h:54
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
mobility
model
mobility-model.h
Generated on Tue May 28 2024 23:38:17 for ns-3 by
1.9.6