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
random-direction-2d-mobility-model.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
#ifndef RANDOM_DIRECTION_MOBILITY_MODEL_H
9
#define RANDOM_DIRECTION_MOBILITY_MODEL_H
10
11
#include "
constant-velocity-helper.h
"
12
#include "
mobility-model.h
"
13
#include "
rectangle.h
"
14
15
#include "ns3/event-id.h"
16
#include "ns3/nstime.h"
17
#include "ns3/object.h"
18
#include "ns3/ptr.h"
19
#include "ns3/random-variable-stream.h"
20
21
namespace
ns3
22
{
23
24
/**
25
* @ingroup mobility
26
* @brief Random direction mobility model.
27
*
28
* The movement of objects is based on random directions: each object
29
* pauses for a specific delay, chooses a random direction and speed and
30
* then travels in the specific direction until it reaches one of
31
* the boundaries of the model. When it reaches the boundary, it pauses,
32
* and selects a new direction and speed.
33
*/
34
class
RandomDirection2dMobilityModel
:
public
MobilityModel
35
{
36
public
:
37
/**
38
* Register this type with the TypeId system.
39
* @return the object TypeId
40
*/
41
static
TypeId
GetTypeId
();
42
RandomDirection2dMobilityModel
();
43
~RandomDirection2dMobilityModel
()
override
;
44
45
// Inherited from MobilityModel
46
Ptr<MobilityModel>
Copy
()
const override
47
{
48
return
CreateObject<RandomDirection2dMobilityModel>
(*
this
);
49
}
50
51
private
:
52
/**
53
* Set a new direction and speed
54
*/
55
void
ResetDirectionAndSpeed
();
56
/**
57
* Pause, cancel currently scheduled event, schedule end of pause event
58
*/
59
void
BeginPause
();
60
/**
61
* Set new velocity and direction, and schedule next pause event
62
* @param direction (radians)
63
*/
64
void
SetDirectionAndSpeed
(
double
direction);
65
/**
66
* Sets a new random direction and calls SetDirectionAndSpeed
67
*/
68
void
DoInitializePrivate
();
69
void
DoDispose
()
override
;
70
void
DoInitialize
()
override
;
71
Vector
DoGetPosition
()
const override
;
72
void
DoSetPosition
(
const
Vector& position)
override
;
73
Vector
DoGetVelocity
()
const override
;
74
int64_t
DoAssignStreams
(int64_t)
override
;
75
76
Ptr<UniformRandomVariable>
m_direction
;
//!< rv to control direction
77
Rectangle
m_bounds
;
//!< the 2D bounding area
78
Ptr<RandomVariableStream>
m_speed
;
//!< a random variable to control speed
79
Ptr<RandomVariableStream>
m_pause
;
//!< a random variable to control pause
80
EventId
m_event
;
//!< event ID of next scheduled event
81
ConstantVelocityHelper
m_helper
;
//!< helper for velocity computations
82
};
83
84
}
// namespace ns3
85
86
#endif
/* RANDOM_DIRECTION_MOBILITY_MODEL_H */
ns3::ConstantVelocityHelper
Utility class used to move node with constant velocity.
Definition
constant-velocity-helper.h:27
ns3::EventId
An identifier for simulation events.
Definition
event-id.h:44
ns3::MobilityModel::MobilityModel
MobilityModel()
Definition
mobility-model.cc:47
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:67
ns3::RandomDirection2dMobilityModel::DoGetPosition
Vector DoGetPosition() const override
Definition
random-direction-2d-mobility-model.cc:150
ns3::RandomDirection2dMobilityModel::~RandomDirection2dMobilityModel
~RandomDirection2dMobilityModel() override
Definition
random-direction-2d-mobility-model.cc:56
ns3::RandomDirection2dMobilityModel::DoSetPosition
void DoSetPosition(const Vector &position) override
Definition
random-direction-2d-mobility-model.cc:157
ns3::RandomDirection2dMobilityModel::SetDirectionAndSpeed
void SetDirectionAndSpeed(double direction)
Set new velocity and direction, and schedule next pause event.
Definition
random-direction-2d-mobility-model.cc:95
ns3::RandomDirection2dMobilityModel::m_event
EventId m_event
event ID of next scheduled event
Definition
random-direction-2d-mobility-model.h:80
ns3::RandomDirection2dMobilityModel::DoAssignStreams
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
Definition
random-direction-2d-mobility-model.cc:171
ns3::RandomDirection2dMobilityModel::m_helper
ConstantVelocityHelper m_helper
helper for velocity computations
Definition
random-direction-2d-mobility-model.h:81
ns3::RandomDirection2dMobilityModel::BeginPause
void BeginPause()
Pause, cancel currently scheduled event, schedule end of pause event.
Definition
random-direction-2d-mobility-model.cc:83
ns3::RandomDirection2dMobilityModel::DoInitializePrivate
void DoInitializePrivate()
Sets a new random direction and calls SetDirectionAndSpeed.
Definition
random-direction-2d-mobility-model.cc:76
ns3::RandomDirection2dMobilityModel::DoInitialize
void DoInitialize() override
Initialize() implementation.
Definition
random-direction-2d-mobility-model.cc:69
ns3::RandomDirection2dMobilityModel::GetTypeId
static TypeId GetTypeId()
Register this type with the TypeId system.
Definition
random-direction-2d-mobility-model.cc:26
ns3::RandomDirection2dMobilityModel::DoDispose
void DoDispose() override
Destructor implementation.
Definition
random-direction-2d-mobility-model.cc:62
ns3::RandomDirection2dMobilityModel::DoGetVelocity
Vector DoGetVelocity() const override
Definition
random-direction-2d-mobility-model.cc:165
ns3::RandomDirection2dMobilityModel::m_speed
Ptr< RandomVariableStream > m_speed
a random variable to control speed
Definition
random-direction-2d-mobility-model.h:78
ns3::RandomDirection2dMobilityModel::ResetDirectionAndSpeed
void ResetDirectionAndSpeed()
Set a new direction and speed.
Definition
random-direction-2d-mobility-model.cc:112
ns3::RandomDirection2dMobilityModel::m_bounds
Rectangle m_bounds
the 2D bounding area
Definition
random-direction-2d-mobility-model.h:77
ns3::RandomDirection2dMobilityModel::RandomDirection2dMobilityModel
RandomDirection2dMobilityModel()
Definition
random-direction-2d-mobility-model.cc:51
ns3::RandomDirection2dMobilityModel::m_direction
Ptr< UniformRandomVariable > m_direction
rv to control direction
Definition
random-direction-2d-mobility-model.h:76
ns3::RandomDirection2dMobilityModel::Copy
Ptr< MobilityModel > Copy() const override
Copy function allows one to copy the underlying MobilityModel from a MobilityModel pointer,...
Definition
random-direction-2d-mobility-model.h:46
ns3::RandomDirection2dMobilityModel::m_pause
Ptr< RandomVariableStream > m_pause
a random variable to control pause
Definition
random-direction-2d-mobility-model.h:79
ns3::Rectangle
a 2d rectangle
Definition
rectangle.h:24
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
constant-velocity-helper.h
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
mobility-model.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
rectangle.h
src
mobility
model
random-direction-2d-mobility-model.h
Generated on Fri Oct 3 2025 18:22:37 for ns-3 by
1.13.2