Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_GLOSA.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2013-2024 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 device for Green Light Optimal Speed Advisory
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include "MSVehicleDevice.h"
25
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
31class MSLink;
32
33
34// ===========================================================================
35// class definitions
36// ===========================================================================
46public:
50 static void insertOptions(OptionsCont& oc);
51
52
63 static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
64
66 static void cleanup();
67
68public:
71
72
73
76
86 bool notifyMove(SUMOTrafficObject& veh, double oldPos,
87 double newPos, double newSpeed);
88
89
98 bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
99
100
102
103
105 const std::string deviceName() const {
106 return "glosa";
107 }
108
113 inline double getOriginalSpeedFactor() const {
115 }
116
120 inline bool getOverrideSafety() const {
121 return myOverrideSafety;
122 }
123
127 inline bool isSpeedAdviceActive() const {
128 return mySpeedAdviceActive;
129 }
130
132 std::string getParameter(const std::string& key) const;
133
135 void setParameter(const std::string& key, const std::string& value);
136
143 void generateOutput(OutputDevice* tripinfoOut) const;
144
145
146
147private:
148
150 static double getTimeToSwitch(const MSLink* tlsLink, int& countOld);
151
153 static double getTimeToNextSwitch(const MSLink* tlsLink, bool &currentPhaseGreen, bool &currentPhaseStop, int& countOld);
154
155 static double timeGreen(const MSLink* tlsLink);
156
158 double earliest_arrival(double speed, double distance);
159
161 double latest_arrival(double speed, double distance, double earliest);
162
163 double distance_at_continuous_accel(double speed, double time);
164
165 double time_to_junction_at_continuous_accel(double d, double v);
166
168 void adaptSpeed(double distance, double timeToJunction, double timeToSwitch, bool &solved);
169
175 MSDevice_GLOSA(SUMOVehicle& holder, const std::string& id, double minSpeed, double range, double maxSpeedFactor,
176 double addSwitchTime, bool useQueue, bool overrideSafety, bool ignoreCFModel);
177
178
179
180private:
183
188
192 double myRange;
201
204
209
210
211private:
214
217
218
219};
A device which collects info on the vehicle trip (mainly on departure and arrival)
bool isSpeedAdviceActive() const
Returns if the GLOSA device is currently changing the speedFactor.
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
const MSLink * myNextTLSLink
the upcoming traffic light
MSVehicle & myVeh
myHolder cast to needed type
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
static double timeGreen(const MSLink *tlsLink)
bool mySpeedAdviceActive
If speedFactor is currently beeing changed by the GLOSA device.
bool myOverrideSafety
if true ignore the current light state, always follow GLOSA's predicted state
bool myUseQueue
if true the queue in front of the TLS is used for calculation
double myAddSwitchTime
Additional time the vehicle shall need to reach the intersection after the signal turns green.
double getOriginalSpeedFactor() const
Returns the precomputed, original factor by which the driver wants to be faster than the speed limit.
double myMaxSpeedFactor
maximum speed factor when trying to reach green light
double myRange
maximum communication range
void adaptSpeed(double distance, double timeToJunction, double timeToSwitch, bool &solved)
adapt speed to reach junction at green
double myMinSpeed
minimum approach speed towards red light
~MSDevice_GLOSA()
Destructor.
double time_to_junction_at_continuous_accel(double d, double v)
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_GLOSA-options.
static double getTimeToSwitch(const MSLink *tlsLink, int &countOld)
compute time to next (relevant) switch
MSDevice_GLOSA(const MSDevice_GLOSA &)
Invalidated copy constructor.
double myDistance
the distance to the upcoming traffic light
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
updates next tls link
double distance_at_continuous_accel(double speed, double time)
double earliest_arrival(double speed, double distance)
return minimum number of seconds to reach the junction
double myOriginalSpeedFactor
original speed factor
double latest_arrival(double speed, double distance, double earliest)
return maximum number of seconds to reach the junction
static void cleanup()
resets counters
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
updates distance and computes speed advice
static double getTimeToNextSwitch(const MSLink *tlsLink, bool &currentPhaseGreen, bool &currentPhaseStop, int &countOld)
compute time to next (relevant) switch the vehicle can reach
bool getOverrideSafety() const
Returns if the traffic light stop calculation of the CF model shall be ignored.
const std::string deviceName() const
return the name for this type of device
bool myIgnoreCFModel
if true ignore non-critical speed calculations from the CF model, follow GLOSA's perfect speed calcul...
MSDevice_GLOSA & operator=(const MSDevice_GLOSA &)
Invalidated assignment operator.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition SUMOVehicle.h:62