A Discrete-Event Network Simulator
API
random-walk-2d-outdoor-mobility-model.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006,2007 INRIA
4  * Copyright (c) 2019 University of Padova
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: Michele Polese <michele.polese@gmail.com>
21  */
22 
23 #ifndef RANDOM_WALK_2D_OUTDOOR_MOBILITY_MODEL_H
24 #define RANDOM_WALK_2D_OUTDOOR_MOBILITY_MODEL_H
25 
26 #include "ns3/object.h"
27 #include "ns3/nstime.h"
28 #include "ns3/event-id.h"
29 #include "ns3/rectangle.h"
30 #include "ns3/random-variable-stream.h"
31 #include "ns3/mobility-model.h"
32 #include "ns3/constant-velocity-helper.h"
33 #include "ns3/building.h"
34 
35 namespace ns3 {
36 
37 
58 {
59 public:
64  static TypeId GetTypeId (void);
66  enum Mode
67  {
69  MODE_TIME
70  };
71 
72 private:
77  void Rebound (Time timeLeft);
83  void AvoidBuilding (Time delayLeft, Vector intersectPosition);
88  void DoWalk (Time timeLeft);
92  void DoInitializePrivate (void);
101  std::pair<bool, Ptr<Building> > IsLineClearOfBuildings (Vector currentPosition, Vector nextPosition ) const;
110  Vector CalculateIntersectionFromOutside (const Vector &current, const Vector &next, const Box boundaries) const;
111 
112  virtual void DoDispose (void);
113  virtual void DoInitialize (void);
114  virtual Vector DoGetPosition (void) const;
115  virtual void DoSetPosition (const Vector &position);
116  virtual Vector DoGetVelocity (void) const;
117  virtual int64_t DoAssignStreams (int64_t);
118 
121  enum Mode m_mode;
122  double m_modeDistance;
127  double m_epsilon;
128  uint32_t m_maxIter;
129  Vector m_prevPosition;
130 };
131 
132 
133 } // namespace ns3
134 
135 #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:54
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.
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.
void DoInitializePrivate(void)
Perform initialization of the object before MobilityModel::DoInitialize ()
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 ...
void DoWalk(Time timeLeft)
Walk according to position and velocity, until distance is reached, time is reached,...
Ptr< RandomVariableStream > m_direction
rv for picking direction
virtual void DoInitialize(void)
Initialize() implementation.
virtual void DoDispose(void)
Destructor implementation.
double m_epsilon
Tolerance for the intersection point with buildings.
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
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).
enum Mode m_mode
whether in time or distance mode
Time m_modeTime
Change current direction and speed after this delay.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
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:104
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.