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 
110  std::string getParameter(const std::string& key) const;
111 
113  void setParameter(const std::string& key, const std::string& value);
114 
121  void generateOutput(OutputDevice* tripinfoOut) const;
122 
123 
124 
125 private:
126 
128  static double getTimeToSwitch(const MSLink* tlsLink);
129 
131  double earliest_arrival(double speed, double distance);
132 
134  double latest_arrival(double speed, double distance, double earliest);
135 
136  double distance_at_continuous_accel(double speed, double time);
137 
138  double time_to_junction_at_continuous_accel(double d, double v);
139 
141  void adaptSpeed(double distance, double timeToJunction, double timeToSwitch);
142 
148  MSDevice_GLOSA(SUMOVehicle& holder, const std::string& id, double minSpeed, double range, double maxSpeedFactor);
149 
150 
151 
152 private:
155 
159  double myDistance;
160 
162  double myMinSpeed;
164  double myRange;
167 
170 
171 
172 private:
175 
178 
179 
180 };
A device which collects info on the vehicle trip (mainly on departure and arrival)
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.
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.
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
MSDevice_GLOSA & operator=(const MSDevice_GLOSA &)
Invalidated assignment operator.
const std::string deviceName() const
return the name for this type of device
MSDevice_GLOSA(SUMOVehicle &holder, const std::string &id, double minSpeed, double range, double maxSpeedFactor)
Constructor.
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:60