A Discrete-Event Network Simulator
API
random-walk-2d-outdoor-mobility-model.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006,2007 INRIA
3  * Copyright (c) 2019 University of Padova
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Author: Michele Polese <michele.polese@gmail.com>
20  */
21 
22 #ifndef RANDOM_WALK_2D_OUTDOOR_MOBILITY_MODEL_H
23 #define RANDOM_WALK_2D_OUTDOOR_MOBILITY_MODEL_H
24 
25 #include "building.h"
26 
27 #include "ns3/constant-velocity-helper.h"
28 #include "ns3/event-id.h"
29 #include "ns3/mobility-model.h"
30 #include "ns3/nstime.h"
31 #include "ns3/object.h"
32 #include "ns3/random-variable-stream.h"
33 #include "ns3/rectangle.h"
34 
35 namespace ns3
36 {
37 
58 {
59  public:
64  static TypeId GetTypeId();
65 
67  enum Mode
68  {
70  MODE_TIME
71  };
72 
73  private:
78  void Rebound(Time timeLeft);
84  void AvoidBuilding(Time delayLeft, Vector intersectPosition);
90  void DoWalk(Time delayLeft);
94  void DoInitializePrivate();
105  std::pair<bool, Ptr<Building>> IsLineClearOfBuildings(Vector currentPosition,
106  Vector nextPosition) const;
115  Vector CalculateIntersectionFromOutside(const Vector& current,
116  const Vector& next,
117  const Box boundaries) const;
118 
119  void DoDispose() override;
120  void DoInitialize() override;
121  Vector DoGetPosition() const override;
122  void DoSetPosition(const Vector& position) override;
123  Vector DoGetVelocity() const override;
124  int64_t DoAssignStreams(int64_t) override;
125 
129  double m_modeDistance;
134  double m_epsilon;
135  uint32_t m_maxIter;
136  Vector m_prevPosition;
137 };
138 
139 } // namespace ns3
140 
141 #endif /* RANDOM_WALK_2D_OUTDOOR_MOBILITY_MODEL_H */
a 3d box
Definition: box.h:35
Utility class used to move node with constant velocity.
An identifier for simulation events.
Definition: event-id.h:55
Keep track of the current position and velocity of an object.
2D random walk mobility model which avoids buildings.
void AvoidBuilding(Time delayLeft, Vector intersectPosition)
Avoid a building.
void DoInitializePrivate()
Perform initialization of the object before MobilityModel::DoInitialize ()
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
double m_modeDistance
Change direction and speed after this distance.
ConstantVelocityHelper m_helper
helper for this object
Mode
An enum representing the different working modes of this module.
Vector m_prevPosition
Store the previous position in case a step back is needed.
void Rebound(Time timeLeft)
Performs the rebound of the node if it reaches a boundary.
uint32_t m_maxIter
Maximum number of tries to find the next position.
Vector CalculateIntersectionFromOutside(const Vector &current, const Vector &next, const Box boundaries) const
Compute the intersecting point of the box represented by boundaries and the line between current and ...
Ptr< RandomVariableStream > m_direction
rv for picking direction
void DoDispose() override
Destructor implementation.
double m_epsilon
Tolerance for the intersection point with buildings.
void DoWalk(Time delayLeft)
Walk according to position and velocity, until distance is reached, time is reached,...
std::pair< bool, Ptr< Building > > IsLineClearOfBuildings(Vector currentPosition, Vector nextPosition) const
Check if there is a building between two positions (or if the nextPosition is inside a building).
static TypeId GetTypeId()
Register this type with the TypeId system.
void DoInitialize() override
Initialize() implementation.
Time m_modeTime
Change current direction and speed after this delay.
Ptr< RandomVariableStream > m_speed
rv for picking speed
a 2d rectangle
Definition: rectangle.h:35
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.