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);
89  void DoWalk (Time delayLeft);
93  void DoInitializePrivate (void);
102  std::pair<bool, Ptr<Building> > IsLineClearOfBuildings (Vector currentPosition, Vector nextPosition ) const;
111  Vector CalculateIntersectionFromOutside (const Vector &current, const Vector &next, const Box boundaries) const;
112 
113  virtual void DoDispose (void);
114  virtual void DoInitialize (void);
115  virtual Vector DoGetPosition (void) const;
116  virtual void DoSetPosition (const Vector &position);
117  virtual Vector DoGetVelocity (void) const;
118  virtual int64_t DoAssignStreams (int64_t);
119 
122  enum Mode m_mode;
123  double m_modeDistance;
128  double m_epsilon;
129  uint32_t m_maxIter;
130  Vector m_prevPosition;
131 };
132 
133 
134 } // namespace ns3
135 
136 #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 ...
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.
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).
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:103
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.