Eclipse SUMO - Simulation of Urban MObility
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"
24 #include <utils/common/SUMOTime.h>
25 
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
30 class SUMOTrafficObject;
31 class MSLink;
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
46 public:
50  static void insertOptions(OptionsCont& oc);
51 
52 
63  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
64 
66  static void cleanup();
67 
68 public:
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 {
114  return myOriginalSpeedFactor;
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 
147 private:
148 
150  static double getTimeToSwitch(const MSLink* tlsLink);
151 
153  double earliest_arrival(double speed, double distance);
154 
156  double latest_arrival(double speed, double distance, double earliest);
157 
158  double distance_at_continuous_accel(double speed, double time);
159 
160  double time_to_junction_at_continuous_accel(double d, double v);
161 
163  void adaptSpeed(double distance, double timeToJunction, double timeToSwitch);
164 
170  MSDevice_GLOSA(SUMOVehicle& holder, const std::string& id, double minSpeed, double range, double maxSpeedFactor,
171  double addSwitchTime, bool overrideSafety, bool ignoreCFModel);
172 
173 
174 
175 private:
178 
182  double myDistance;
183 
185  double myMinSpeed;
187  double myRange;
196 
199 
202 
203 
204 private:
207 
210 
211 
212 };
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.
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
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)
adapt speed to reach junction at green
double myMinSpeed
minimum approach speed towards red light
~MSDevice_GLOSA()
Destructor.
MSDevice_GLOSA(SUMOVehicle &holder, const std::string &id, double minSpeed, double range, double maxSpeedFactor, double addSwitchTime, bool overrideSafety, bool ignoreCFModel)
Constructor.
double time_to_junction_at_continuous_accel(double d, double v)
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_GLOSA-options.
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 getTimeToSwitch(const MSLink *tlsLink)
compute time to next (relevant) switch
bool getOverrideSafety() const
Returns if the traffic light stop calculation of the CF model shall be ignored.
MSDevice_GLOSA & operator=(const MSDevice_GLOSA &)
Invalidated assignment operator.
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...
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.
Definition: OutputDevice.h:61
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:62