SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
MSPModel_Striping.h
Go to the documentation of this file.
1
/****************************************************************************/
7
// The pedestrian following model (prototype)
8
/****************************************************************************/
9
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10
// Copyright (C) 2014-2014 DLR (http://www.dlr.de/) and contributors
11
/****************************************************************************/
12
//
13
// This file is part of SUMO.
14
// SUMO is free software: you can redistribute it and/or modify
15
// it under the terms of the GNU General Public License as published by
16
// the Free Software Foundation, either version 3 of the License, or
17
// (at your option) any later version.
18
//
19
/****************************************************************************/
20
#ifndef MSPModel_Striping_h
21
#define MSPModel_Striping_h
22
23
// ===========================================================================
24
// included modules
25
// ===========================================================================
26
#ifdef _MSC_VER
27
#include <
windows_config.h
>
28
#else
29
#include <
config.h
>
30
#endif
31
32
#include <string>
33
#include <limits>
34
#include <
utils/common/SUMOTime.h
>
35
#include <
utils/common/Command.h
>
36
#include <
utils/options/OptionsCont.h
>
37
#include <
microsim/MSPerson.h
>
38
#include <
microsim/MSPModel.h
>
39
40
// ===========================================================================
41
// class declarations
42
// ===========================================================================
43
class
MSNet
;
44
class
MSLink
;
45
class
MSLane
;
46
class
MSJunction
;
47
48
49
// ===========================================================================
50
// class definitions
51
// ===========================================================================
57
class
MSPModel_Striping
:
public
MSPModel
{
58
59
friend
class
GUIPerson
;
// for debugging
60
61
public
:
62
64
MSPModel_Striping
(
const
OptionsCont
& oc,
MSNet
* net);
65
66
~MSPModel_Striping
();
67
69
PedestrianState
*
add
(
MSPerson
* person,
MSPerson::MSPersonStage_Walking
* stage,
SUMOTime
now);
70
72
bool
blockedAtDist
(
const
MSLane
* lane,
SUMOReal
distToCrossing, std::vector<const MSPerson*>* collectBlockers);
73
75
void
cleanupHelper
();
76
79
80
// @brief the width of a pedstrian stripe
81
static
SUMOReal
stripeWidth
;
82
83
// @brief the factor for random slow-down
84
static
SUMOReal
dawdling
;
85
86
// @brief the distance to look ahead for changing stripes
87
static
const
SUMOReal
LOOKAHEAD_SAMEDIR
;
88
// @brief the distance to look ahead for changing stripes (regarding oncoming pedestrians)
89
static
const
SUMOReal
LOOKAHEAD_ONCOMING
;
90
91
// @brief the speed penalty for moving sideways
92
static
const
SUMOReal
LATERAL_PENALTY
;
93
94
// @brief the factor by which pedestrian width is reduced when sqeezing past each other
95
static
const
SUMOReal
SQUEEZE
;
96
97
// @brief the maximum distance at which oncoming pedestrians block right turning traffic
98
static
const
SUMOReal
BLOCKER_LOOKAHEAD
;
99
100
// @brief fraction of the leftmost lanes to reserve for oncoming traffic
101
static
const
SUMOReal
RESERVE_FOR_ONCOMING_FACTOR
;
102
103
// @brief the time pedestrians take to reach maximum impatience
104
static
const
SUMOReal
MAX_WAIT_TOLERANCE
;
105
106
// @brief the fraction of forward speed to be used for lateral movemenk
107
static
const
SUMOReal
LATERAL_SPEED_FACTOR
;
108
110
111
112
protected
:
113
struct
Obstacle
;
114
struct
WalkingAreaPath
;
115
class
PState
;
116
typedef
std::vector<PState*>
Pedestrians
;
117
typedef
std::map<const MSLane*, Pedestrians>
ActiveLanes
;
118
typedef
std::vector<Obstacle>
Obstacles
;
119
typedef
std::map<const MSLane*, Obstacles>
NextLanesObstacles
;
120
typedef
std::map<std::pair<const MSLane*, const MSLane*>,
WalkingAreaPath
>
WalkingAreaPaths
;
121
122
struct
NextLaneInfo
{
123
NextLaneInfo
(
const
MSLane
* _lane,
const
MSLink
* _link,
int
_dir) :
124
lane
(_lane),
125
link
(_link),
126
dir
(_dir)
127
{ }
128
129
NextLaneInfo
() :
130
lane
(0),
131
link
(0),
132
dir
(
UNDEFINED_DIRECTION
)
133
{ }
134
135
// @brief the next lane to be used
136
const
MSLane
*
lane
;
137
// @brief the link from the current lane to the next lane
138
const
MSLink
*
link
;
139
// @brief the direction on the next lane
140
int
dir
;
141
};
142
144
struct
Obstacle
{
146
Obstacle
(
int
dir);
148
Obstacle
(
const
PState
& ped,
int
dir);
150
Obstacle
(
SUMOReal
_x,
SUMOReal
_speed,
const
std::string& _description) :
x
(_x),
speed
(_speed),
description
(_description) {};
151
153
SUMOReal
x
;
155
SUMOReal
speed
;
157
std::string
description
;
158
};
159
160
struct
WalkingAreaPath
{
161
WalkingAreaPath
(
const
MSLane
* _from,
const
MSLane
* _walkingArea,
const
MSLane
* _to,
const
PositionVector
& _shape) :
162
from
(_from),
163
to
(_to),
164
lane
(_walkingArea),
165
shape
(_shape),
166
length
(_shape.
length
())
167
{}
168
169
WalkingAreaPath
():
from
(0),
to
(0),
lane
(0) {};
170
171
const
MSLane
*
from
;
172
const
MSLane
*
to
;
173
const
MSLane
*
lane
;
// the walkingArea;
174
// actually const but needs to be copyable by some stl code
175
PositionVector
shape
;
176
SUMOReal
length
;
177
178
};
179
184
class
PState
:
public
PedestrianState
{
185
public
:
186
189
SUMOReal
getEdgePos
(
const
MSPerson::MSPersonStage_Walking
& stage,
SUMOTime
now)
const
;
190
Position
getPosition
(
const
MSPerson::MSPersonStage_Walking
& stage,
SUMOTime
now)
const
;
191
SUMOReal
getAngle
(
const
MSPerson::MSPersonStage_Walking
& stage,
SUMOTime
now)
const
;
192
SUMOTime
getWaitingTime
(
const
MSPerson::MSPersonStage_Walking
& stage,
SUMOTime
now)
const
;
193
SUMOReal
getSpeed
(
const
MSPerson::MSPersonStage_Walking
& stage)
const
;
195
196
PState
(
MSPerson
* person,
MSPerson::MSPersonStage_Walking
* stage,
const
MSLane
* lane);
197
~PState
() {};
198
MSPerson
*
myPerson
;
199
MSPerson::MSPersonStage_Walking
*
myStage
;
201
const
MSLane
*
myLane
;
203
SUMOReal
myRelX
;
205
SUMOReal
myRelY
;
207
int
myDir
;
209
SUMOReal
mySpeed
;
211
int
myBlockedByOncoming
;
213
bool
myWaitingToEnter
;
215
SUMOTime
myWaitingTime
;
217
NextLaneInfo
myNLI
;
219
WalkingAreaPath
*
myWalkingAreaPath
;
220
222
SUMOReal
getLength
()
const
;
223
225
SUMOReal
distToLaneEnd
()
const
;
226
228
bool
moveToNextLane
(
SUMOTime
currentTime);
229
231
void
walk
(
const
Obstacles
& obs,
SUMOTime
currentTime);
232
234
SUMOReal
getImpatience
(
SUMOTime
now)
const
;
// XXX
235
237
SUMOReal
getMingap
()
const
;
238
239
int
stripe
()
const
;
240
int
otherStripe
()
const
;
241
242
};
243
244
class
MovePedestrians
:
public
Command
{
245
public
:
246
MovePedestrians
(
MSPModel_Striping
* model) :
myModel
(model) {};
247
~MovePedestrians
() {};
248
SUMOTime
execute
(
SUMOTime
currentTime);
249
private
:
250
MSPModel_Striping
*
const
myModel
;
251
private
:
253
MovePedestrians
&
operator=
(
const
MovePedestrians
&);
254
};
255
256
class
by_xpos_sorter
{
257
public
:
259
by_xpos_sorter
(
int
dir):
myDir
(dir) {}
260
261
public
:
263
bool
operator()
(
const
PState
* p1,
const
PState
* p2)
const
{
264
if
(p1->
myRelX
!= p2->
myRelX
) {
265
return
myDir
* p1->
myRelX
>
myDir
* p2->
myRelX
;
266
}
267
return
p1->
myPerson
->
getID
() < p2->
myPerson
->
getID
();
268
}
269
270
private
:
271
const
int
myDir
;
272
273
private
:
275
by_xpos_sorter
&
operator=
(
const
by_xpos_sorter
&);
276
};
277
278
280
void
moveInDirection
(
SUMOTime
currentTime, std::set<MSPerson*>& changedLane,
int
dir);
281
282
const
ActiveLanes
&
getActiveLanes
() {
283
return
myActiveLanes
;
284
}
285
286
private
:
287
static
void
DEBUG_PRINT
(
const
Obstacles
& obs);
288
290
static
int
connectedDirection
(
const
MSLane
* from,
const
MSLane
* to);
291
297
static
NextLaneInfo
getNextLane
(
const
PState& ped,
const
MSLane
* currentLane,
const
MSLane
* prevLane);
298
300
static
const
MSLane
*
getNextWalkingArea
(
const
MSLane
* currentLane,
const
int
dir,
MSLink
*& link);
301
302
static
void
initWalkingAreaPaths
(
const
MSNet
* net);
303
305
static
int
numStripes
(
const
MSLane
* lane);
306
307
static
Obstacles
mergeObstacles
(
const
Obstacles
& obs1,
const
Obstacles
& obs2,
int
dir);
308
309
static
Obstacles
getNeighboringObstacles
(
const
Pedestrians
& pedestrians,
int
egoIndex,
int
stripes);
310
311
const
Obstacles
&
getNextLaneObstacles
(
NextLanesObstacles
& nextLanesObs,
const
MSLane
* nextLane,
int
stripes,
312
SUMOReal
nextLength,
int
nextDir,
SUMOReal
currentLength,
int
currentDir);
313
315
Pedestrians
&
getPedestrians
(
const
MSLane
* lane);
316
317
318
private
:
320
MovePedestrians
*
myCommand
;
321
323
int
myNumActivePedestrians
;
324
326
ActiveLanes
myActiveLanes
;
327
329
static
WalkingAreaPaths
myWalkingAreaPaths
;
330
332
static
Pedestrians
noPedestrians
;
333
334
};
335
336
337
#endif
/* MSPModel_Striping_h */
338
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
MSPModel_Striping.h
Generated on Thu Nov 20 2014 19:49:55 for SUMO - Simulation of Urban MObility by
1.8.1.2