author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sat, 04 Jul 2009 08:15:48 +0200 | |
changeset 4654 | 2eaebe77d66b |
parent 4258 | 8b6b5fbc1976 |
permissions | -rw-r--r-- |
1553
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2006,2007 INRIA |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
20 |
#ifndef RANDOM_WALK_2D_MOBILITY_MODEL_H |
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
21 |
#define RANDOM_WALK_2D_MOBILITY_MODEL_H |
1553
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
#include "ns3/object.h" |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "ns3/nstime.h" |
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
25 |
#include "ns3/event-id.h" |
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
26 |
#include "ns3/rectangle.h" |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
27 |
#include "ns3/random-variable.h" |
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
28 |
#include "mobility-model.h" |
4258
8b6b5fbc1976
StaticSpeedHelper -> ConstantVelocityHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3226
diff
changeset
|
29 |
#include "constant-velocity-helper.h" |
1553
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
|
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
namespace ns3 { |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
33 |
|
1559
78bbcb0334ee
add dox documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1553
diff
changeset
|
34 |
/** |
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
35 |
* \brief a 2D random walk position model |
1553
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
* |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
* Each instance moves with a speed and direction choosen at random |
1628
2edabd03c1e1
doxygen for mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1624
diff
changeset
|
38 |
* with the user-provided random variables until |
1559
78bbcb0334ee
add dox documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1553
diff
changeset
|
39 |
* either a fixed distance has been walked or until a fixed amount |
3226
8c191779d1c2
doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
40 |
* of time. If we hit one of the boundaries (specified by a rectangle), |
8c191779d1c2
doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
41 |
* of the model, we rebound on the boundary with a reflexive angle |
8c191779d1c2
doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
42 |
* and speed. This model is often identified as a brownian motion |
8c191779d1c2
doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
43 |
* model. |
1553
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
*/ |
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
45 |
class RandomWalk2dMobilityModel : public MobilityModel |
1553
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
{ |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
public: |
2251
04963d8cca51
iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
48 |
static TypeId GetTypeId (void); |
2399
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
49 |
|
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
50 |
enum Mode { |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
51 |
MODE_DISTANCE, |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
52 |
MODE_TIME |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
53 |
}; |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
54 |
|
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
55 |
RandomWalk2dMobilityModel (); |
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
56 |
|
1553
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
private: |
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
58 |
void Start (void); |
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
59 |
void Rebound (Time timeLeft); |
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
60 |
void DoWalk (Time timeLeft); |
1573
23f53613f22d
implement Dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1563
diff
changeset
|
61 |
virtual void DoDispose (void); |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1816
diff
changeset
|
62 |
virtual Vector DoGetPosition (void) const; |
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1816
diff
changeset
|
63 |
virtual void DoSetPosition (const Vector &position); |
1818
fbdc8361dc77
GetSpeed -> GetVelocity
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
64 |
virtual Vector DoGetVelocity (void) const; |
1553
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
|
4258
8b6b5fbc1976
StaticSpeedHelper -> ConstantVelocityHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3226
diff
changeset
|
66 |
ConstantVelocityHelper m_helper; |
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
67 |
EventId m_event; |
2399
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
68 |
enum Mode m_mode; |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
69 |
double m_modeDistance; |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
70 |
Time m_modeTime; |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
71 |
RandomVariable m_speed; |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
72 |
RandomVariable m_direction; |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
73 |
Rectangle m_bounds; |
1553
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
74 |
}; |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
75 |
|
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
76 |
|
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
77 |
} // namespace ns3 |
09f32ecf07b9
random walk position model (untested)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
|
1605
c1b6f76ab722
a real random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1584
diff
changeset
|
79 |
#endif /* RANDOM_WALK_2D_MOBILITY_MODEL_H */ |