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
MSAbstractLaneChangeModel.h
Go to the documentation of this file.
1
/****************************************************************************/
11
// Interface for lane-change models
12
/****************************************************************************/
13
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14
// Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
15
/****************************************************************************/
16
//
17
// This file is part of SUMO.
18
// SUMO is free software: you can redistribute it and/or modify
19
// it under the terms of the GNU General Public License as published by
20
// the Free Software Foundation, either version 3 of the License, or
21
// (at your option) any later version.
22
//
23
/****************************************************************************/
24
#ifndef MSAbstractLaneChangeModel_h
25
#define MSAbstractLaneChangeModel_h
26
27
// ===========================================================================
28
// included modules
29
// ===========================================================================
30
#ifdef _MSC_VER
31
#include <
windows_config.h
>
32
#else
33
#include <
config.h
>
34
#endif
35
36
#include "
MSVehicle.h
"
37
class
MSLane
;
38
39
// ===========================================================================
40
// used enumeration
41
// ===========================================================================
45
enum
LaneChangeAction
{
48
50
LCA_NONE
= 0,
52
LCA_STAY
= 1 << 0,
54
LCA_LEFT
= 1 << 1,
56
LCA_RIGHT
= 1 << 2,
57
59
LCA_STRATEGIC
= 1 << 3,
61
LCA_COOPERATIVE
= 1 << 4,
63
LCA_SPEEDGAIN
= 1 << 5,
65
LCA_KEEPRIGHT
= 1 << 6,
67
LCA_TRACI
= 1 << 7,
68
70
LCA_URGENT
= 1 << 8,
71
72
LCA_WANTS_LANECHANGE
=
LCA_LEFT
|
LCA_RIGHT
,
73
LCA_WANTS_LANECHANGE_OR_STAY
=
LCA_WANTS_LANECHANGE
|
LCA_STAY
,
75
78
80
LCA_BLOCKED_BY_LEFT_LEADER
= 1 << 9,
82
LCA_BLOCKED_BY_LEFT_FOLLOWER
= 1 << 10,
83
85
LCA_BLOCKED_BY_RIGHT_LEADER
= 1 << 11,
87
LCA_BLOCKED_BY_RIGHT_FOLLOWER
= 1 << 12,
88
89
// The vehicle is blocked being overlapping
90
LCA_OVERLAPPING
= 1 << 13,
91
92
LCA_BLOCKED_LEFT
=
LCA_BLOCKED_BY_LEFT_LEADER
|
LCA_BLOCKED_BY_LEFT_FOLLOWER
,
93
LCA_BLOCKED_RIGHT
=
LCA_BLOCKED_BY_RIGHT_LEADER
|
LCA_BLOCKED_BY_RIGHT_FOLLOWER
,
94
LCA_BLOCKED_BY_LEADER
=
LCA_BLOCKED_BY_LEFT_LEADER
|
LCA_BLOCKED_BY_RIGHT_LEADER
,
95
LCA_BLOCKED_BY_FOLLOWER
=
LCA_BLOCKED_BY_LEFT_FOLLOWER
|
LCA_BLOCKED_BY_RIGHT_FOLLOWER
,
96
LCA_BLOCKED
=
LCA_BLOCKED_LEFT
|
LCA_BLOCKED_RIGHT
97
99
100
};
101
102
103
104
105
106
// ===========================================================================
107
// class definitions
108
// ===========================================================================
113
class
MSAbstractLaneChangeModel
{
114
public
:
115
119
class
MSLCMessager
{
120
public
:
126
MSLCMessager
(
MSVehicle
* leader,
MSVehicle
* neighLead,
MSVehicle
* neighFollow)
127
:
myLeader
(leader),
myNeighLeader
(neighLead),
128
myNeighFollower
(neighFollow) { }
129
130
132
~MSLCMessager
() { }
133
134
140
void
*
informLeader
(
void
* info,
MSVehicle
* sender) {
141
assert(
myLeader
!= 0);
142
return
myLeader
->
getLaneChangeModel
().
inform
(info, sender);
143
}
144
145
151
void
*
informNeighLeader
(
void
* info,
MSVehicle
* sender) {
152
assert(
myNeighLeader
!= 0);
153
return
myNeighLeader
->
getLaneChangeModel
().
inform
(info, sender);
154
}
155
156
162
void
*
informNeighFollower
(
void
* info,
MSVehicle
* sender) {
163
assert(
myNeighFollower
!= 0);
164
return
myNeighFollower
->
getLaneChangeModel
().
inform
(info, sender);
165
}
166
167
168
private
:
170
MSVehicle
*
myLeader
;
172
MSVehicle
*
myNeighLeader
;
174
MSVehicle
*
myNeighFollower
;
175
176
};
177
179
void
static
initGlobalOptions
(
const
OptionsCont
& oc);
180
185
static
MSAbstractLaneChangeModel
*
build
(
LaneChangeModel
lcm,
MSVehicle
& vehicle);
186
190
MSAbstractLaneChangeModel
(
MSVehicle
& v);
191
193
virtual
~MSAbstractLaneChangeModel
();
194
195
inline
int
getOwnState
()
const
{
196
return
myOwnState
;
197
}
198
199
inline
void
setOwnState
(
int
state) {
200
myOwnState
= state;
201
}
202
203
virtual
void
prepareStep
() { }
204
209
virtual
int
wantsChange
(
210
int
laneOffset,
211
MSAbstractLaneChangeModel::MSLCMessager
& msgPass,
int
blocked,
212
const
std::pair<MSVehicle*, SUMOReal>& leader,
213
const
std::pair<MSVehicle*, SUMOReal>& neighLead,
214
const
std::pair<MSVehicle*, SUMOReal>& neighFollow,
215
const
MSLane
& neighLane,
216
const
std::vector<MSVehicle::LaneQ>& preb,
217
MSVehicle
** lastBlocked,
218
MSVehicle
** firstBlocked) = 0;
219
220
virtual
void
*
inform
(
void
* info,
MSVehicle
* sender) = 0;
221
233
virtual
SUMOReal
patchSpeed
(
const
SUMOReal
min
,
const
SUMOReal
wanted,
const
SUMOReal
max
,
234
const
MSCFModel
& cfModel) = 0;
235
236
virtual
void
changed
() = 0;
237
238
void
unchanged
() {
239
myLastLaneChangeOffset
+=
DELTA_T
;
240
}
241
245
MSLane
*
getShadowLane
()
const
{
246
return
myShadowLane
;
247
}
248
249
250
inline
SUMOTime
getLastLaneChangeOffset
()
const
{
251
return
myLastLaneChangeOffset
;
252
}
253
254
256
inline
bool
isLaneChangeMidpointPassed
()
const
{
257
return
myLaneChangeMidpointPassed
;
258
}
259
261
inline
SUMOReal
getLaneChangeCompletion
()
const
{
262
return
myLaneChangeCompletion
;
263
}
264
266
inline
bool
isChangingLanes
()
const
{
267
return
myLaneChangeCompletion
< (1 -
NUMERICAL_EPS
);
268
}
269
271
inline
int
getLaneChangeDirection
()
const
{
272
return
myLaneChangeDirection
;
273
}
274
276
inline
bool
alreadyMoved
()
const
{
277
return
myAlreadyMoved
;
278
}
279
281
void
resetMoved
() {
282
myAlreadyMoved
=
false
;
283
}
284
285
287
bool
startLaneChangeManeuver
(
MSLane
* source,
MSLane
* target,
int
direction);
288
289
290
/* @brief continue the lane change maneuver
291
* @param[in] moved Whether the vehicle has moved to a new lane
292
*/
293
void
continueLaneChangeManeuver
(
bool
moved);
294
295
/* @brief finish the lane change maneuver
296
*/
297
inline
void
endLaneChangeManeuver
() {
298
removeLaneChangeShadow
();
299
myLaneChangeCompletion
= 1;
300
myShadowLane
= 0;
301
}
302
304
void
removeLaneChangeShadow
();
305
307
virtual
void
saveBlockerLength
(
SUMOReal
length) {
308
UNUSED_PARAMETER
(length);
309
};
310
311
protected
:
312
virtual
bool
congested
(
const
MSVehicle
*
const
neighLeader);
313
314
virtual
bool
predInteraction
(
const
MSVehicle
*
const
leader);
315
317
bool
cancelRequest
(
int
state);
318
319
320
protected
:
322
MSVehicle
&
myVehicle
;
323
325
int
myOwnState
;
326
328
SUMOTime
myLastLaneChangeOffset
;
329
331
SUMOReal
myLaneChangeCompletion
;
332
334
int
myLaneChangeDirection
;
335
337
bool
myLaneChangeMidpointPassed
;
338
340
bool
myAlreadyMoved
;
341
343
MSLane
*
myShadowLane
;
344
346
bool
myHaveShadow
;
347
349
const
MSCFModel
&
myCarFollowModel
;
350
352
static
bool
myAllowOvertakingRight
;
353
354
private
:
356
MSAbstractLaneChangeModel
&
operator=
(
const
MSAbstractLaneChangeModel
& s);
357
};
358
359
360
#endif
361
362
/****************************************************************************/
363
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
MSAbstractLaneChangeModel.h
Generated on Thu Nov 20 2014 19:49:54 for SUMO - Simulation of Urban MObility by
1.8.1.2