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 * 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
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
21namespace 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 */
35{
36 public:
37 /**
38 * Register this type with the TypeId system.
39 * \return the object TypeId
40 */
41 static TypeId GetTypeId();
44
45 private:
46 /**
47 * Set a new direction and speed
48 */
50 /**
51 * Pause, cancel currently scheduled event, schedule end of pause event
52 */
53 void BeginPause();
54 /**
55 * Set new velocity and direction, and schedule next pause event
56 * \param direction (radians)
57 */
58 void SetDirectionAndSpeed(double direction);
59 /**
60 * Sets a new random direction and calls SetDirectionAndSpeed
61 */
63 void DoDispose() override;
64 void DoInitialize() override;
65 Vector DoGetPosition() const override;
66 void DoSetPosition(const Vector& position) override;
67 Vector DoGetVelocity() const override;
68 int64_t DoAssignStreams(int64_t) override;
69
70 Ptr<UniformRandomVariable> m_direction; //!< rv to control direction
71 Rectangle m_bounds; //!< the 2D bounding area
72 Ptr<RandomVariableStream> m_speed; //!< a random variable to control speed
73 Ptr<RandomVariableStream> m_pause; //!< a random variable to control pause
74 EventId m_event; //!< event ID of next scheduled event
75 ConstantVelocityHelper m_helper; //!< helper for velocity computations
76};
77
78} // namespace ns3
79
80#endif /* RANDOM_DIRECTION_MOBILITY_MODEL_H */
Utility class used to move node with constant velocity.
An identifier for simulation events.
Definition event-id.h:45
Keep track of the current position and velocity of an object.
Smart pointer class similar to boost::intrusive_ptr.
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:24
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.