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 // Inherited from MobilityModel
46 Ptr<MobilityModel> Copy() const override
47 {
49 }
50
51 private:
52 /**
53 * Set a new direction and speed
54 */
56 /**
57 * Pause, cancel currently scheduled event, schedule end of pause event
58 */
59 void BeginPause();
60 /**
61 * Set new velocity and direction, and schedule next pause event
62 * @param direction (radians)
63 */
64 void SetDirectionAndSpeed(double direction);
65 /**
66 * Sets a new random direction and calls SetDirectionAndSpeed
67 */
69 void DoDispose() override;
70 void DoInitialize() override;
71 Vector DoGetPosition() const override;
72 void DoSetPosition(const Vector& position) override;
73 Vector DoGetVelocity() const override;
74 int64_t DoAssignStreams(int64_t) override;
75
76 Ptr<UniformRandomVariable> m_direction; //!< rv to control direction
77 Rectangle m_bounds; //!< the 2D bounding area
78 Ptr<RandomVariableStream> m_speed; //!< a random variable to control speed
79 Ptr<RandomVariableStream> m_pause; //!< a random variable to control pause
80 EventId m_event; //!< event ID of next scheduled event
81 ConstantVelocityHelper m_helper; //!< helper for velocity computations
82};
83
84} // namespace ns3
85
86#endif /* RANDOM_DIRECTION_MOBILITY_MODEL_H */
Utility class used to move node with constant velocity.
An identifier for simulation events.
Definition event-id.h:44
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
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< MobilityModel > Copy() const override
Copy function allows one to copy the underlying MobilityModel from a MobilityModel pointer,...
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:49
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Every class exported by the ns3 library is enclosed in the ns3 namespace.