author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Fri, 16 Nov 2007 08:48:57 +0100 | |
changeset 2132 | b6599fb46d19 |
parent 2114 | bfd8e5afb36d |
parent 1854 | 8a3deb9c57dc |
child 2249 | 3a1da26d61dc |
permissions | -rw-r--r-- |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
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 |
* All rights reserved. |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* 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
|
7 |
* 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
|
8 |
* published by the Free Software Foundation; |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* 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
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* 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
|
16 |
* along with this program; if not, write to the Free Software |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* 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
|
18 |
* |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
*/ |
1581
95a193d3ac1d
POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
21 |
#ifndef RANDOM_DIRECTION_MOBILITY_MODEL_H |
95a193d3ac1d
POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
22 |
#define RANDOM_DIRECTION_MOBILITY_MODEL_H |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
|
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "ns3/object.h" |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include "ns3/ptr.h" |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
#include "ns3/nstime.h" |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
#include "ns3/event-id.h" |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
#include "ns3/component-manager.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
|
29 |
#include "ns3/rectangle.h" |
1580
0d2cf8839aee
position.h -> mobility-model.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1579
diff
changeset
|
30 |
#include "mobility-model.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
|
31 |
#include "static-speed-helper.h" |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
namespace ns3 { |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
|
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
class RandomVariable; |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
|
1634 | 37 |
/** |
38 |
* \brief the parameters to control a RandomDirection mobility model. |
|
39 |
*/ |
|
1635
935bed1e13e7
RandomDirection2dParameters -> RandomDirection2dMobilityModelParameters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1634
diff
changeset
|
40 |
class RandomDirection2dMobilityModelParameters : public Object |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
{ |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
public: |
1634 | 43 |
/** |
1854
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
44 |
* Create from \valueref{RandomDirection2dSpeed}, |
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
45 |
* \valueref{RandomDirection2dPause}, and, |
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
46 |
* \valueref{RandomDirection2dArea}. |
1634 | 47 |
*/ |
1635
935bed1e13e7
RandomDirection2dParameters -> RandomDirection2dMobilityModelParameters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1634
diff
changeset
|
48 |
RandomDirection2dMobilityModelParameters (); |
1634 | 49 |
/** |
50 |
* \param bounds the 2d bounds of the mobility model |
|
51 |
* \param speedVariable the random variable used to pick a random speed |
|
52 |
* \param pauseVariable the random variable used to pick a random pause delay |
|
53 |
*/ |
|
1635
935bed1e13e7
RandomDirection2dParameters -> RandomDirection2dMobilityModelParameters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1634
diff
changeset
|
54 |
RandomDirection2dMobilityModelParameters (const Rectangle &bounds, |
1634 | 55 |
const RandomVariable &speedVariable, |
56 |
const RandomVariable &pauseVariable); |
|
1635
935bed1e13e7
RandomDirection2dParameters -> RandomDirection2dMobilityModelParameters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1634
diff
changeset
|
57 |
virtual ~RandomDirection2dMobilityModelParameters (); |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
|
1634 | 59 |
/** |
60 |
* \param speedVariable the random variable used to pick a random speed. |
|
61 |
*/ |
|
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
void SetSpeed (const RandomVariable &speedVariable); |
1634 | 63 |
/** |
64 |
* \param pauseVariable the random variable used to pick a random pause delay. |
|
65 |
*/ |
|
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
void SetPause (const RandomVariable &pauseVariable); |
1634 | 67 |
/** |
68 |
* \param bounds the 2d bounds of the mobility model. |
|
69 |
*/ |
|
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
|
70 |
void SetBounds (const Rectangle &bounds); |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
private: |
1626
feaecfd93b5d
RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1625
diff
changeset
|
72 |
friend class RandomDirection2dMobilityModel; |
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
|
73 |
|
1635
935bed1e13e7
RandomDirection2dParameters -> RandomDirection2dMobilityModelParameters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1634
diff
changeset
|
74 |
static Ptr<RandomDirection2dMobilityModelParameters> GetCurrent (void); |
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
|
75 |
|
69baa7b1c487
remove mobility model helper, re-enable random direction model with new helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1592
diff
changeset
|
76 |
Rectangle m_bounds; |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
77 |
RandomVariable *m_speedVariable; |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
RandomVariable *m_pauseVariable; |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
79 |
}; |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
|
1634 | 81 |
/** |
82 |
* \brief a RandomDirection mobility model |
|
83 |
* |
|
84 |
* The movement of objects is based on random directions: each object |
|
85 |
* pauses for a specific delay, chooses a random direction and speed and |
|
86 |
* then travels in the specific direction until it reaches one of |
|
87 |
* the boundaries of the model. When it reaches the boundary, it pauses, |
|
88 |
* selects a new direction and speed, aso. |
|
89 |
*/ |
|
1626
feaecfd93b5d
RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1625
diff
changeset
|
90 |
class RandomDirection2dMobilityModel : public MobilityModel |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
91 |
{ |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
92 |
public: |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
93 |
static const ClassId cid; |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
94 |
|
1634 | 95 |
/** |
1854
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
96 |
* Create from \valueref{RandomDirection2dSpeed}, |
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
97 |
* \valueref{RandomDirection2dPause}, and, |
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
98 |
* \valueref{RandomDirection2dArea}. |
1634 | 99 |
*/ |
1626
feaecfd93b5d
RandomDirection -> RandomDirection2d
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1625
diff
changeset
|
100 |
RandomDirection2dMobilityModel (); |
1634 | 101 |
/** |
102 |
* \param parameters the parameters which control the behavior of the model. |
|
103 |
* Create a RandomDirection model using the parameters specified. |
|
104 |
*/ |
|
1635
935bed1e13e7
RandomDirection2dParameters -> RandomDirection2dMobilityModelParameters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1634
diff
changeset
|
105 |
RandomDirection2dMobilityModel (Ptr<RandomDirection2dMobilityModelParameters> parameters); |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
106 |
private: |
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
|
107 |
void Start (void); |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
108 |
void ResetDirectionAndSpeed (void); |
1661
7583786bd063
Adapt to StaticSpeedHelper change
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1637
diff
changeset
|
109 |
void BeginPause (void); |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
110 |
void SetDirectionAndSpeed (double direction); |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
111 |
void InitializeDirectionAndSpeed (void); |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
112 |
virtual void DoDispose (void); |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1816
diff
changeset
|
113 |
virtual Vector DoGetPosition (void) const; |
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1816
diff
changeset
|
114 |
virtual void DoSetPosition (const Vector &position); |
1818
fbdc8361dc77
GetSpeed -> GetVelocity
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
115 |
virtual Vector DoGetVelocity (void) const; |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
116 |
|
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
117 |
static const double PI; |
1635
935bed1e13e7
RandomDirection2dParameters -> RandomDirection2dMobilityModelParameters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1634
diff
changeset
|
118 |
Ptr<RandomDirection2dMobilityModelParameters> m_parameters; |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
119 |
EventId m_event; |
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
|
120 |
StaticSpeedHelper m_helper; |
1575
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
121 |
}; |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
122 |
|
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
123 |
} // namespace ns3 |
cbc37ce4b91d
RandomDirection model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
124 |
|
1581
95a193d3ac1d
POSITION_H -> MOBILITY_MODEL_H
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1580
diff
changeset
|
125 |
#endif /* RANDOM_DIRECTION_MOBILITY_MODEL_H */ |