author | Tom Henderson <tomh@tomh.org> |
Mon, 15 Dec 2014 21:47:59 -0800 | |
changeset 11104 | 635076116247 |
parent 11057 | 35e001b4202d |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7179
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 INRIA |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
1581
95a193d3ac1d
POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
20 |
#ifndef RANDOM_DIRECTION_MOBILITY_MODEL_H |
95a193d3ac1d
POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
21 |
#define RANDOM_DIRECTION_MOBILITY_MODEL_H |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
#include "ns3/object.h" |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "ns3/ptr.h" |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include "ns3/nstime.h" |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
#include "ns3/event-id.h" |
1620
69baa7b1c487
remove mobility model helper, re-enable random direction model with new helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1592
diff
changeset
|
27 |
#include "ns3/rectangle.h" |
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
28 |
#include "ns3/random-variable-stream.h" |
1580
0d2cf8839aee
position.h -> mobility-model.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1579
diff
changeset
|
29 |
#include "mobility-model.h" |
4258
8b6b5fbc1976
StaticSpeedHelper -> ConstantVelocityHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4226
diff
changeset
|
30 |
#include "constant-velocity-helper.h" |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
|
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
namespace ns3 { |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
|
1634 | 34 |
/** |
6471
a2028222c362
Doxygen cleanup in mobility module
Pavel Boyko <boyko@iitp.ru>
parents:
5524
diff
changeset
|
35 |
* \ingroup mobility |
a2028222c362
Doxygen cleanup in mobility module
Pavel Boyko <boyko@iitp.ru>
parents:
5524
diff
changeset
|
36 |
* \brief Random direction mobility model. |
1634 | 37 |
* |
38 |
* The movement of objects is based on random directions: each object |
|
39 |
* pauses for a specific delay, chooses a random direction and speed and |
|
40 |
* then travels in the specific direction until it reaches one of |
|
41 |
* the boundaries of the model. When it reaches the boundary, it pauses, |
|
42 |
* selects a new direction and speed, aso. |
|
43 |
*/ |
|
1626
feaecfd93b5d
RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1625
diff
changeset
|
44 |
class RandomDirection2dMobilityModel : public MobilityModel |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
{ |
7179
9d72cc013844
mobility coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6839
diff
changeset
|
46 |
public: |
11104
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
47 |
/** |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
48 |
* Register this type with the TypeId system. |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
49 |
* \return the object TypeId |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
50 |
*/ |
2251
04963d8cca51
iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
51 |
static TypeId GetTypeId (void); |
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
52 |
RandomDirection2dMobilityModel (); |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
|
7179
9d72cc013844
mobility coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6839
diff
changeset
|
54 |
private: |
11104
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
55 |
/** |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
56 |
* Set a new direction and speed |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
57 |
*/ |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
void ResetDirectionAndSpeed (void); |
11104
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
59 |
/** |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
60 |
* Pause, cancel currently scheduled event, schedule end of pause event |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
61 |
*/ |
1661
7583786bd063
Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1637
diff
changeset
|
62 |
void BeginPause (void); |
11104
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
63 |
/** |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
64 |
* Set new velocity and direction, and schedule next pause event |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
65 |
* \param direction (radians) |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
66 |
*/ |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
void SetDirectionAndSpeed (double direction); |
11104
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
68 |
/** |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
69 |
* Sets a new random direction and calls SetDirectionAndSpeed |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
70 |
*/ |
9703
681f35b212ff
Rename Start and DoStart methods to Initialize and DoInitialize
Vedran Miletić <rivanvx@gmail.com>
parents:
8984
diff
changeset
|
71 |
void DoInitializePrivate (void); |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
72 |
virtual void DoDispose (void); |
9703
681f35b212ff
Rename Start and DoStart methods to Initialize and DoInitialize
Vedran Miletić <rivanvx@gmail.com>
parents:
8984
diff
changeset
|
73 |
virtual void DoInitialize (void); |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1816
diff
changeset
|
74 |
virtual Vector DoGetPosition (void) const; |
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1816
diff
changeset
|
75 |
virtual void DoSetPosition (const Vector &position); |
1818
fbdc8361dc77
GetSpeed -> GetVelocity
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
76 |
virtual Vector DoGetVelocity (void) const; |
8984
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
77 |
virtual int64_t DoAssignStreams (int64_t); |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
|
11104
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
79 |
Ptr<UniformRandomVariable> m_direction; //!< rv to control direction |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
80 |
Rectangle m_bounds; //!< the 2D bounding area |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
81 |
Ptr<RandomVariableStream> m_speed; //!< a random variable to control speed |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
82 |
Ptr<RandomVariableStream> m_pause; //!< a random variable to control pause |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
83 |
EventId m_event; //!< event ID of next scheduled event |
635076116247
Doxygen warnings for mobility/helper and mobility/model directories
Tom Henderson <tomh@tomh.org>
parents:
11057
diff
changeset
|
84 |
ConstantVelocityHelper m_helper; //!< helper for velocity computations |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
85 |
}; |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
86 |
|
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
87 |
} // namespace ns3 |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
88 |
|
1581
95a193d3ac1d
POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
89 |
#endif /* RANDOM_DIRECTION_MOBILITY_MODEL_H */ |