author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Fri, 15 Feb 2008 20:03:48 +0100 | |
changeset 2336 | 28ce210b91bb |
parent 2251 | 04963d8cca51 |
child 2399 | fd9d94d518d2 |
permissions | -rw-r--r-- |
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 INRIA |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* All rights reserved. |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
1a1101c83922
add a 3d random waypoint 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 |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
*/ |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#ifndef RANDOM_WAYPOINT_MOBILITY_MODEL_H |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#define RANDOM_WAYPOINT_MOBILITY_MODEL_H |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
|
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "static-speed-helper.h" |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include "mobility-model.h" |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
#include "random-position.h" |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
#include "ns3/ptr.h" |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
28 |
#include "ns3/random-variable.h" |
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
namespace ns3 { |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
|
1636 | 32 |
/** |
33 |
* \brief the parameters which control the behavior of a random waypoint |
|
34 |
* mobility model. |
|
35 |
*/ |
|
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
class RandomWaypointMobilityModelParameters : public Object |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
{ |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
public: |
1636 | 39 |
/** |
1854
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
40 |
* Default parameters from \valueref{RandomWaypointPause}, |
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
41 |
* and, \valueref{RandomWaypointPosition}. |
1636 | 42 |
*/ |
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
RandomWaypointMobilityModelParameters (); |
1636 | 44 |
/** |
45 |
* \param randomPosition a random position model to choose the position of waypoints. |
|
46 |
* \param speed a random variable to choose the speed |
|
47 |
* \param pause a random variable to choose the pause delay |
|
48 |
*/ |
|
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
RandomWaypointMobilityModelParameters (Ptr<RandomPosition> randomPosition, |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
const RandomVariable &speed, |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
const RandomVariable &pause); |
1636 | 52 |
/** |
53 |
* \param randomPosition a random position model to choose the position of waypoints. |
|
54 |
*/ |
|
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
55 |
void SetWaypointPositionModel (Ptr<RandomPosition> randomPosition); |
1636 | 56 |
/** |
57 |
* \param speed a random variable to choose the speed |
|
58 |
*/ |
|
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
59 |
void SetSpeed (const RandomVariable &speed); |
1636 | 60 |
/** |
61 |
* \param pause a random variable to choose the pause delay |
|
62 |
*/ |
|
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
63 |
void SetPause (const RandomVariable &pause); |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
private: |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
friend class RandomWaypointMobilityModel; |
1601
84805e29dd21
add default value support to random waypoint
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1600
diff
changeset
|
66 |
static Ptr<RandomWaypointMobilityModelParameters> GetCurrent (void); |
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
virtual void DoDispose (void); |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
68 |
RandomVariable m_speed; |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
69 |
RandomVariable m_pause; |
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
70 |
Ptr<RandomPosition> m_position; |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
}; |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
72 |
|
1636 | 73 |
/** |
74 |
* \brief a random waypoint mobility model |
|
75 |
* |
|
76 |
* Each object chooses a random destination "waypoint", a random speed, |
|
77 |
* and a random pause time: it then pauses for the specified pause time, |
|
78 |
* and starts moving towards the specified destination with the specified |
|
79 |
* speed. Once the destination is reached the process starts again. |
|
80 |
* |
|
81 |
* The implementation of this model is not 2d-specific. i.e. if you provide |
|
82 |
* a 3d random waypoint position model to this mobility model, the model |
|
83 |
* will still work. |
|
84 |
*/ |
|
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
85 |
class RandomWaypointMobilityModel : public MobilityModel |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
86 |
{ |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
87 |
public: |
2251
04963d8cca51
iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
88 |
static TypeId GetTypeId (void); |
1636 | 89 |
/** |
1854
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
90 |
* Default parameters from \valueref{RandomWaypointPause}, |
8a3deb9c57dc
use the \valueref macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1818
diff
changeset
|
91 |
* and, \valueref{RandomWaypointPosition}. |
1636 | 92 |
*/ |
1601
84805e29dd21
add default value support to random waypoint
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1600
diff
changeset
|
93 |
RandomWaypointMobilityModel (); |
1636 | 94 |
/** |
95 |
* \param parameters the parameters which control the behavior of this model. |
|
96 |
*/ |
|
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
97 |
RandomWaypointMobilityModel (Ptr<RandomWaypointMobilityModelParameters> parameters); |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
98 |
private: |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
99 |
void Start (void); |
1663
ea3848cdbdaf
According to the literature, in RandomWaypointMobilityModel the pause should come before the walk, not after; fixed.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1660
diff
changeset
|
100 |
void BeginWalk (void); |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1816
diff
changeset
|
101 |
virtual Vector DoGetPosition (void) const; |
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1816
diff
changeset
|
102 |
virtual void DoSetPosition (const Vector &position); |
1818
fbdc8361dc77
GetSpeed -> GetVelocity
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
103 |
virtual Vector DoGetVelocity (void) const; |
1624
6e7d48a8c120
add MobilityModel::GetSpeed method and implement it in all mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1602
diff
changeset
|
104 |
|
1600
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
105 |
StaticSpeedHelper m_helper; |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
106 |
Ptr<RandomWaypointMobilityModelParameters> m_parameters; |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
107 |
EventId m_event; |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
108 |
}; |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
109 |
|
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
110 |
} // namespace ns3 |
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
111 |
|
1a1101c83922
add a 3d random waypoint model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
112 |
#endif /* RANDOM_WAYPOINT_MOBILITY_MODEL_H */ |