Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MEVehicle.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A vehicle from the mesoscopic point of view
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <iostream>
24#include <cassert>
25#include <map>
26#include <vector>
28#include <microsim/MSEdge.h>
30#include "MESegment.h"
31
32class MSLane;
33class MSLink;
34
35// ===========================================================================
36// class definitions
37// ===========================================================================
42class MEVehicle : public MSBaseVehicle {
43public:
52 MSVehicleType* type, const double speedFactor);
53
54
58 double getPositionOnLane() const;
59
60
64 double getBackPositionOnLane(const MSLane* lane) const;
65
66
70 double getAngle() const;
71
72
76 double getSlope() const;
77
81 const MSLane* getLane() const {
82 return nullptr;
83 }
84
92 Position getPosition(const double offset = 0) const;
93
94
99 double getSpeed() const;
100
105 double getAverageSpeed() const;
106
108 double estimateLeaveSpeed(const MSLink* link) const;
109
110
116 double getConservativeSpeed(SUMOTime& earliestArrival) const;
117
119
120
130
131
135 bool moveRoutePointer();
136
140 bool hasArrived() const;
141
145 bool isOnRoad() const;
146
150 virtual bool isIdling() const;
151
152
157 void setApproaching(MSLink* link);
158
161 return 0;
162 }
163
165 void processStop();
166
172
177 bool resumeFromStopping();
178
180 double getBrakeGap(bool delayed = false) const {
181 UNUSED_PARAMETER(delayed);
182 return 0;
183 }
184
188 inline void setEventTime(SUMOTime t, bool hasDelay = true) {
189 assert(t > myLastEntryTime);
190 if (hasDelay && mySegment != nullptr) {
192 }
193 myEventTime = t;
194 }
195
196
200 inline SUMOTime getEventTime() const {
201 return myEventTime;
202 }
203
204
209 inline virtual void setSegment(MESegment* s, int idx = 0) {
210 mySegment = s;
211 myQueIndex = idx;
212 }
213
214
218 inline MESegment* getSegment() const {
219 return mySegment;
220 }
221
222
226 inline int getQueIndex() const {
227 return myQueIndex;
228 }
229
235 double getRightSideOnEdge(const MSLane* /*lane*/) const;
236
240 inline void setLastEntryTime(SUMOTime t) {
241 myLastEntryTime = t;
242 }
243
244
249 return myLastEntryTime;
250 }
251
252
256 inline void setBlockTime(const SUMOTime t) {
257 assert(t > myLastEntryTime);
258 myBlockTime = t;
259 }
260
261
265 inline SUMOTime getBlockTime() const {
266 return myBlockTime;
267 }
268
269
271 inline SUMOTime getWaitingTime() const {
272 return MAX2(SUMOTime(0), myEventTime - myBlockTime);
273 }
274
275 inline SUMOTime getTimeLoss() const {
276 // slow-downs while driving are not modelled
277 return getWaitingTime();
278 }
279
282 return getWaitingTime();
283 }
284
285
287 double getEventTimeSeconds() const {
288 return STEPS2TIME(getEventTime());
289 }
290
292 double getLastEntryTimeSeconds() const {
294 }
295
297 double getBlockTimeSeconds() const {
298 return STEPS2TIME(getBlockTime());
299 }
300
302 double getCurrentLinkPenaltySeconds() const;
303
305 double getCurrentStoppingTimeSeconds() const;
306
308 bool replaceRoute(ConstMSRoutePtr route, const std::string& info, bool onInit = false, int offset = 0, bool addRouteStops = true, bool removeStops = true, std::string* msgReturn = nullptr);
309
313 bool mayProceed();
314
317 void updateDetectorForWriting(MSMoveReminder* rem, SUMOTime currentTime, SUMOTime exitTime);
318
321 void updateDetectors(SUMOTime currentTime, const bool isLeave,
323
329 BaseInfluencer& getBaseInfluencer();
330
331 const BaseInfluencer* getBaseInfluencer() const;
332
333 bool hasInfluencer() const {
334 return myInfluencer != nullptr;
335 }
336
338
339
341 void saveState(OutputDevice& out);
342
345 void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset);
347
348
349protected:
352
355
358
361
364
367
368};
long long int SUMOTime
Definition GUI.h:36
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
#define STEPS2TIME(x)
Definition SUMOTime.h:55
#define UNUSED_PARAMETER(x)
Definition StdDefs.h:30
T MAX2(T a, T b)
Definition StdDefs.h:82
A single mesoscopic segment (cell)
Definition MESegment.h:49
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition MESegment.h:359
A vehicle from the mesoscopic point of view.
Definition MEVehicle.h:42
double getConservativeSpeed(SUMOTime &earliestArrival) const
Returns the vehicle's estimated speed taking into account delays.
double getLastEntryTimeSeconds() const
Returns the entry time for the current segment.
Definition MEVehicle.h:292
double getBlockTimeSeconds() const
Returns the time at which the vehicle was blocked on the current segment.
Definition MEVehicle.h:297
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition MEVehicle.h:333
double getAverageSpeed() const
Returns the vehicle's estimated average speed on the segment assuming no further delays.
double getAngle() const
Returns the vehicle's direction in degrees.
Definition MEVehicle.cpp:88
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
Definition MEVehicle.cpp:74
bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addRouteStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
SUMOTime myEventTime
The (planned) time of leaving the segment (cell)
Definition MEVehicle.h:357
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
void updateDetectorForWriting(MSMoveReminder *rem, SUMOTime currentTime, SUMOTime exitTime)
Updates a single vehicle detector if present.
BaseInfluencer & getBaseInfluencer()
Returns the velocity/lane influencer.
double getCurrentStoppingTimeSeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
double getBrakeGap(bool delayed=false) const
get distance for coming to a stop (used for rerouting checks)
Definition MEVehicle.h:180
SUMOTime getAccumulatedWaitingTime() const
Returns the duration for which the vehicle was blocked.
Definition MEVehicle.h:281
bool mayProceed()
Returns whether the vehicle is allowed to pass the next junction, checks also for triggered stops.
double estimateLeaveSpeed(const MSLink *link) const
Returns the vehicle's estimated speed after driving accross the link.
void processStop()
ends the current stop and performs loading/unloading
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
int myQueIndex
Index of the que the vehicle is in (important for multiqueue extension)
Definition MEVehicle.h:354
SUMOTime checkStop(SUMOTime time)
Returns until when to stop at the current segment and sets the information that the stop has been rea...
void updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_JUNCTION)
Updates all vehicle detectors.
virtual bool isIdling() const
Returns whether the vehicle is trying to re-enter the net.
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
Definition MEVehicle.h:248
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition MEVehicle.cpp:80
SUMOTime myLastEntryTime
The time the vehicle entered its current segment.
Definition MEVehicle.h:360
void setEventTime(SUMOTime t, bool hasDelay=true)
Sets the (planned) time at which the vehicle leaves its current segment.
Definition MEVehicle.h:188
BaseInfluencer * myInfluencer
An instance of a velocity/lane influencing instance; built in "getInfluencer".
Definition MEVehicle.h:366
void setApproaching(MSLink *link)
registers vehicle with the given link
void saveState(OutputDevice &out)
Saves the states of a vehicle.
SUMOTime getTimeLoss() const
Definition MEVehicle.h:275
MESegment * getSegment() const
Returns the current segment the vehicle is on.
Definition MEVehicle.h:218
void setLastEntryTime(SUMOTime t)
Sets the entry time for the current segment.
Definition MEVehicle.h:240
MESegment * mySegment
The segment the vehicle is at.
Definition MEVehicle.h:351
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition MEVehicle.h:226
SUMOTime getWaitingTime() const
Returns the duration for which the vehicle was blocked.
Definition MEVehicle.h:271
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition MEVehicle.h:81
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
Definition MEVehicle.h:209
SUMOTime remainingStopDuration() const
Returns the remaining stop duration for a stopped vehicle or 0.
Definition MEVehicle.h:160
double getCurrentLinkPenaltySeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves its current segment.
Definition MEVehicle.h:200
void setBlockTime(const SUMOTime t)
Sets the time at which the vehicle was blocked.
Definition MEVehicle.h:256
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
bool resumeFromStopping()
double getSpeed() const
Returns the vehicle's estimated speed assuming no delays.
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
Definition MEVehicle.cpp:95
double getEventTimeSeconds() const
Returns the earliest leave time for the current segment.
Definition MEVehicle.h:287
SUMOTime myBlockTime
The time at which the vehicle was blocked on its current segment.
Definition MEVehicle.h:363
double getRightSideOnEdge(const MSLane *) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
SUMOTime getBlockTime() const
Returns the time at which the vehicle was blocked.
Definition MEVehicle.h:265
The base class for microscopic and mesoscopic vehicles.
void markDelayed() const
Definition MSEdge.h:702
Representation of a lane in the micro simulation.
Definition MSLane.h:84
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
The car-following model and parameter.
Static storage of an output device and its base (abstract) implementation.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
Encapsulated SAX-Attributes.
Structure representing possible vehicle parameter.