A Discrete-Event Network Simulator
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 * 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 RANDOM_DIRECTION_MOBILITY_MODEL_H
20#define RANDOM_DIRECTION_MOBILITY_MODEL_H
21
23#include "mobility-model.h"
24#include "rectangle.h"
25
26#include "ns3/event-id.h"
27#include "ns3/nstime.h"
28#include "ns3/object.h"
29#include "ns3/ptr.h"
30#include "ns3/random-variable-stream.h"
31
32namespace ns3
33{
34
35/**
36 * \ingroup mobility
37 * \brief Random direction mobility model.
38 *
39 * The movement of objects is based on random directions: each object
40 * pauses for a specific delay, chooses a random direction and speed and
41 * then travels in the specific direction until it reaches one of
42 * the boundaries of the model. When it reaches the boundary, it pauses,
43 * and selects a new direction and speed.
44 */
46{
47 public:
48 /**
49 * Register this type with the TypeId system.
50 * \return the object TypeId
51 */
52 static TypeId GetTypeId();
54
55 private:
56 /**
57 * Set a new direction and speed
58 */
60 /**
61 * Pause, cancel currently scheduled event, schedule end of pause event
62 */
63 void BeginPause();
64 /**
65 * Set new velocity and direction, and schedule next pause event
66 * \param direction (radians)
67 */
68 void SetDirectionAndSpeed(double direction);
69 /**
70 * Sets a new random direction and calls SetDirectionAndSpeed
71 */
73 void DoDispose() override;
74 void DoInitialize() override;
75 Vector DoGetPosition() const override;
76 void DoSetPosition(const Vector& position) override;
77 Vector DoGetVelocity() const override;
78 int64_t DoAssignStreams(int64_t) override;
79
80 Ptr<UniformRandomVariable> m_direction; //!< rv to control direction
81 Rectangle m_bounds; //!< the 2D bounding area
82 Ptr<RandomVariableStream> m_speed; //!< a random variable to control speed
83 Ptr<RandomVariableStream> m_pause; //!< a random variable to control pause
84 EventId m_event; //!< event ID of next scheduled event
85 ConstantVelocityHelper m_helper; //!< helper for velocity computations
86};
87
88} // namespace ns3
89
90#endif /* RANDOM_DIRECTION_MOBILITY_MODEL_H */
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.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
void DoSetPosition(const Vector &position) override
void SetDirectionAndSpeed(double direction)
Set new velocity and direction, and schedule next pause event.
EventId m_event
event ID of next scheduled event
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
ConstantVelocityHelper m_helper
helper for velocity computations
void BeginPause()
Pause, cancel currently scheduled event, schedule end of pause event.
void DoInitializePrivate()
Sets a new random direction and calls SetDirectionAndSpeed.
void DoInitialize() override
Initialize() implementation.
static TypeId GetTypeId()
Register this type with the TypeId system.
void DoDispose() override
Destructor implementation.
Ptr< RandomVariableStream > m_speed
a random variable to control speed
void ResetDirectionAndSpeed()
Set a new direction and speed.
Ptr< UniformRandomVariable > m_direction
rv to control direction
Ptr< RandomVariableStream > m_pause
a random variable to control pause
a 2d rectangle
Definition: rectangle.h:35
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.