Eclipse SUMO - Simulation of Urban MObility
MSDevice_SSM.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2013-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // An SSM-device logs encounters / conflicts of the carrying vehicle with other surrounding vehicles.
18 // XXX: Preliminary implementation. Use with care. Especially rerouting vehicles could be problematic.
19 /****************************************************************************/
20 #ifndef MSDevice_SSM_h
21 #define MSDevice_SSM_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <queue>
30 #include "MSVehicleDevice.h"
31 #include <utils/common/SUMOTime.h>
33 #include <utils/geom/Position.h>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class SUMOVehicle;
40 class SUMOTrafficObject;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
55 class MSCrossSection;
56 
57 class MSDevice_SSM : public MSVehicleDevice {
58 
59 private:
61  static std::set<MSDevice_SSM*, ComparatorNumericalIdLess>* myInstances;
62 
63 public:
67  // Other vehicle is closer than range, but not on a lane conflicting with the ego's route ahead
69  // Ego and foe vehicles' edges form a part of a consecutive sequence of edges
70  // This type may be specified further by ENCOUNTER_TYPE_FOLLOWING_LEADER or ENCOUNTER_TYPE_FOLLOWING_FOLLOWER
72  // Ego vehicle is on an edge that has a sequence of successors connected to the other vehicle's edge
74  // Other vehicle is on an edge that has a sequence of successors connected to the ego vehicle's current edge
76  // Other vehicle is on an edge that has a sequence of successors connected to the ego vehicle's current edge
78  // Ego and foe share an upcoming edge of their routes while the merging point for the routes is still ahead
79  // This type may be specified further by ENCOUNTER_TYPE_MERGING_LEADER or ENCOUNTER_TYPE_MERGING_FOLLOWER
81  // Other vehicle is on an edge that has a sequence of successors connected to an edge on the ego vehicle's route
82  // and the estimated arrival vehicle at the merge point is earlier for the ego than for the foe
84  // Other vehicle is on an edge that has a sequence of successors connected to an edge on the ego vehicle's route
85  // and the estimated arrival vehicle at the merge point is earlier for the foe than for the ego
87  // Vehicles' bestlanes lead to the same edge but to adjacent lanes
89  // Ego's and foe's routes have crossing edges
90  // This type may be specified further by ENCOUNTER_TYPE_CROSSING_LEADER or ENCOUNTER_TYPE_CROSSING_FOLLOWER
92  // Other vehicle is on an edge that has a sequence of successors leading to an internal edge that crosses the ego vehicle's edge at a junction
93  // and the estimated arrival vehicle at the merge point is earlier for the ego than for the foe
95  // Other vehicle is on an edge that has a sequence of successors leading to an internal edge that crosses the ego vehicle's edge at a junction
96  // and the estimated arrival vehicle at the merge point is earlier for the foe than for the ego
98  // The encounter is a possible crossing conflict, and the ego vehicle has entered the conflict area
100  // The encounter is a possible crossing conflict, and the foe vehicle has entered the conflict area
102  // The encounter has been a possible crossing conflict, but the ego vehicle has left the conflict area
104  // The encounter has been a possible crossing conflict, but the foe vehicle has left the conflict area
106  // The encounter has been a possible crossing conflict, and both vehicles have entered the conflict area (one must have already left, otherwise this must be a collision)
108  // The encounter has been a possible crossing conflict, but both vehicle have left the conflict area
110  // FOLLOWING_PASSED and MERGING_PASSED are reserved to achieve that these encounter types may be tracked longer (see updatePassedEncounter)
111  // The encounter has been a following situation, but is not active any more
113  // The encounter has been a merging situation, but is not active any more
115  // Ego vehicle and foe are driving in opposite directions towards each other on the same lane (or sequence of consecutive lanes)
117  // Collision (currently unused, might be differentiated further)
119  };
120 
121  static std::string toString(EncounterType type) {
122  switch (type) {
124  return ("NOCONFLICT_AHEAD");
126  return ("FOLLOWING");
128  return ("FOLLOWING_FOLLOWER");
130  return ("FOLLOWING_LEADER");
132  return ("ON_ADJACENT_LANES");
133  case (ENCOUNTER_TYPE_MERGING):
134  return ("MERGING");
136  return ("MERGING_LEADER");
138  return ("MERGING_FOLLOWER");
140  return ("MERGING_ADJACENT");
142  return ("CROSSING");
144  return ("CROSSING_LEADER");
146  return ("CROSSING_FOLLOWER");
148  return ("EGO_ENTERED_CONFLICT_AREA");
150  return ("FOE_ENTERED_CONFLICT_AREA");
152  return ("EGO_LEFT_CONFLICT_AREA");
154  return ("FOE_LEFT_CONFLICT_AREA");
156  return ("BOTH_ENTERED_CONFLICT_AREA");
158  return ("BOTH_LEFT_CONFLICT_AREA");
160  return ("FOLLOWING_PASSED");
162  return ("MERGING_PASSED");
164  return ("ONCOMING");
166  return ("COLLISION");
167  }
168  return ("UNKNOWN");
169  };
170 
171 private:
174  class Encounter {
175  private:
178  struct Trajectory {
179  // positions
181  // momentary speeds
183  };
188  double time;
196  double value;
197 
198  ConflictPointInfo(double time, Position x, EncounterType type, double ssmValue) :
199  time(time), pos(x), type(type), value(ssmValue) {};
200  };
201 
202  public:
204  Encounter(const MSVehicle* _ego, const MSVehicle* const _foe, double _begin, double extraTime);
206  ~Encounter();
207 
209  void add(double time, EncounterType type, Position egoX, Position egoV, Position foeX, Position foeV,
210  Position conflictPoint, double egoDistToConflict, double foeDistToConflict, double ttc, double drac, std::pair<double, double> pet);
211 
213  std::size_t size() const {
214  return timeSpan.size();
215  }
216 
218  void resetExtraTime(double value);
220  void countDownExtraTime(double amount);
222  double getRemainingExtraTime() const;
223 
225  struct compare {
226  typedef bool value_type;
227  bool operator()(Encounter* e1, Encounter* e2) {
228  if (e1->begin == e2->begin) {
229  return e1->foeID > e2->foeID;
230  } else {
231  return e1->begin > e2->begin;
232  }
233  };
234  };
235 
236 
237 
238  public:
239  const MSVehicle* ego;
240  const MSVehicle* foe;
241  const std::string egoID;
242  const std::string foeID;
243  double begin, end;
245 
248 
253 
255  std::vector<double> timeSpan;
257  std::vector<int> typeSpan;
263  std::vector<double> egoDistsToConflict;
265  std::vector<double> foeDistsToConflict;
266 
271 
273  std::vector<double> TTCspan;
275  std::vector<double> DRACspan;
276 
277 // /// @brief Cross sections at which a PET shall be calculated for the corresponding vehicle
278 // std::vector<std::pair<std::pair<const MSLane*, double>, double> > egoPETCrossSections;
279 // std::vector<std::pair<std::pair<const MSLane*, double>, double> > foePETCrossSections;
280 
287 
290 
291  private:
293  Encounter(const Encounter&);
295  Encounter& operator=(const Encounter&);
297  };
298 
299 
318  double ttc;
319  double drac;
320  std::pair<double, double> pet;
321  std::pair<const MSLane*, double> egoConflictEntryCrossSection;
322  std::pair<const MSLane*, double> foeConflictEntryCrossSection;
323  };
324 
325 
329  struct FoeInfo {
330  virtual ~FoeInfo() {};
331  const MSLane* egoConflictLane;
333  };
334  // TODO: consider introducing a class foeCollector, which holds the foe info content
335  // plus a vehicle container to be used in findSurrounding vehicles.
336  // findSurroundingVehicles() would then deliver a vector of such foeCollectors
337  // (one for each possible egoConflictLane) instead of a map vehicle->foeInfo
338  // This could be helpful to resolve the resolution for several different
339  // projected conflicts with the same foe.
340 
341 
347  const MSEdge* edge;
348  double pos;
349  double range;
352  };
353 
354  typedef std::priority_queue<Encounter*, std::vector<Encounter*>, Encounter::compare> EncounterQueue;
355  typedef std::vector<Encounter*> EncounterVector;
356  typedef std::map<const MSVehicle*, FoeInfo*> FoeInfoMap;
357 public:
358 
362  static void insertOptions(OptionsCont& oc);
363 
364 
375  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
376 
377 
380  static const std::set<MSDevice_SSM*, ComparatorNumericalIdLess>& getInstances();
381 
387  void updateAndWriteOutput();
388 
389 private:
390  void update();
391  void writeOutConflict(Encounter* e);
392 
394  static void toGeo(Position& x);
396  static void toGeo(PositionVector& x);
397 
398 public:
401  static void cleanup();
402 
403 
404 public:
406  ~MSDevice_SSM();
407 
408 
420  static void findSurroundingVehicles(const MSVehicle& veh, double range, FoeInfoMap& foeCollector);
421 
424  static void getUpstreamVehicles(const UpstreamScanStartInfo& scanStart, FoeInfoMap& foeCollector, std::set<const MSJunction*>& seenJunctions);
425 
428  static void getVehiclesOnJunction(const MSJunction*, double egoDistToConflictLane, const MSLane* const egoConflictLane, FoeInfoMap& foeCollector);
429 
430 
433 
443  bool notifyMove(SUMOTrafficObject& veh, double oldPos,
444  double newPos, double newSpeed);
445 
446 
456  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
457 
458 
467  bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
468  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
470 
471 
473  const std::string deviceName() const {
474  return "ssm";
475  }
476 
483  void generateOutput() const;
484 
485 
486 
487 private:
499  MSDevice_SSM(SUMOVehicle& holder, const std::string& id, std::string outputFilename, std::map<std::string, double> thresholds,
500  bool trajectories, double range, double extraTime, bool useGeoCoords);
501 
510  void processEncounters(FoeInfoMap& foes, bool forceClose = false);
511 
512 
517 
518 
519 
522  void createEncounters(FoeInfoMap& foes);
523 
524 
529  void computeGlobalMeasures();
530 
533  void resetEncounters();
534 
538  void flushConflicts(bool all = false);
539 
543  void flushGlobalMeasures();
544 
549  bool updateEncounter(Encounter* e, FoeInfo* foeInfo);
550 
560  void updatePassedEncounter(Encounter* e, FoeInfo* foeInfo, EncounterApproachInfo& eInfo);
561 
562 
573  EncounterType classifyEncounter(const FoeInfo* foeInfo, EncounterApproachInfo& eInfo) const;
574 
575 
581  static void determineConflictPoint(EncounterApproachInfo& eInfo);
582 
583 
593  static void estimateConflictTimes(EncounterApproachInfo& eInfo);
594 
595 
602  static void checkConflictEntryAndExit(EncounterApproachInfo& eInfo);
603 
604 
613  const MSLane* findFoeConflictLane(const MSVehicle* foe, const MSLane* egoConflictLane, double& distToConflictLane) const;
614 
617  void closeEncounter(Encounter* e);
618 
621  bool qualifiesAsConflict(Encounter* e);
622 
627  void computeSSMs(EncounterApproachInfo& e) const;
628 
629 
633  void determinePET(EncounterApproachInfo& eInfo) const;
634 
635 
639  void determineTTCandDRAC(EncounterApproachInfo& eInfo) const;
640 
641 
645  double computeTTC(double gap, double followerSpeed, double leaderSpeed) const;
646 
647 
653  static double computeDRAC(double gap, double followerSpeed, double leaderSpeed);
654 
666  static double computeDRAC(const EncounterApproachInfo& eInfo);
667 
675  static std::string makeStringWithNAs(std::vector<double> v, double NA, std::string sep = " ");
676  static std::string makeStringWithNAs(std::vector<double> v, std::vector<double> NAs, std::string sep = " ");
677 
680  static std::string getOutputFilename(const SUMOVehicle& v, std::string deviceID);
681  static double getDetectionRange(const SUMOVehicle& v);
682  static double getExtraTime(const SUMOVehicle& v);
683  static bool useGeoCoords(const SUMOVehicle& v);
684  static bool requestsTrajectories(const SUMOVehicle& v);
685  static bool getMeasuresAndThresholds(const SUMOVehicle& v, std::string deviceID,
686  std::map<std::string, double>& thresholds);
688 
689 private:
694  std::map<std::string, double> myThresholds;
699  double myRange;
701  double myExtraTime;
708 
709 
719 
720 
721 
724  std::vector<double> myGlobalMeasuresTimeSpan;
726  std::vector<double> myBRspan;
728  std::vector<double> mySGAPspan;
730  std::vector<double> myTGAPspan;
733  std::pair<std::pair<double, Position>, double> myMaxBR;
734  std::pair<std::pair<std::pair<double, Position>, double>, std::string> myMinSGAP;
735  std::pair<std::pair<std::pair<double, Position>, double>, std::string> myMinTGAP;
738 
741 
743  static std::set<std::string> createdOutputFiles;
744 
745 
752  SSM_WARN_RANGE = 1 << 3,
754  SSM_WARN_FILE = 1 << 5,
755  SSM_WARN_GEO = 1 << 6
756  };
757 
758 
759 
760 private:
762  MSDevice_SSM(const MSDevice_SSM&);
763 
766 
767 
768 };
769 
770 #endif
771 
772 /****************************************************************************/
773 
MSDevice_SSM::EncounterApproachInfo::foeConflictAreaLength
double foeConflictAreaLength
Definition: MSDevice_SSM.h:315
MSDevice_SSM::operator=
MSDevice_SSM & operator=(const MSDevice_SSM &)
Invalidated assignment operator.
MSDevice_SSM::UpstreamScanStartInfo::range
double range
Definition: MSDevice_SSM.h:349
MSDevice_SSM::UpstreamScanStartInfo::UpstreamScanStartInfo
UpstreamScanStartInfo(const MSEdge *edge, double pos, double range, double egoDistToConflictLane, const MSLane *egoConflictLane)
Definition: MSDevice_SSM.h:345
MSDevice_SSM::FoeInfo::~FoeInfo
virtual ~FoeInfo()
Definition: MSDevice_SSM.h:330
MSDevice_SSM::Encounter::TTCspan
std::vector< double > TTCspan
All values for TTC.
Definition: MSDevice_SSM.h:273
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:48
MSDevice_SSM::Encounter::countDownExtraTime
void countDownExtraTime(double amount)
decreases myRemaingExtraTime by given amount in seconds
Definition: MSDevice_SSM.cpp:360
MSDevice_SSM::getExtraTime
static double getExtraTime(const SUMOVehicle &v)
Definition: MSDevice_SSM.cpp:3307
MSDevice_SSM::myTGAPspan
std::vector< double > myTGAPspan
All values for time gap.
Definition: MSDevice_SSM.h:730
MSDevice_SSM::ENCOUNTER_TYPE_FOLLOWING_PASSED
ENCOUNTER_TYPE_FOLLOWING_PASSED.
Definition: MSDevice_SSM.h:112
MSDevice_SSM::Encounter::timeSpan
std::vector< double > timeSpan
time points corresponding to the trajectories
Definition: MSDevice_SSM.h:255
MSDevice_SSM::Encounter::foeID
const std::string foeID
Definition: MSDevice_SSM.h:242
MSDevice_SSM::UpstreamScanStartInfo::egoDistToConflictLane
double egoDistToConflictLane
Definition: MSDevice_SSM.h:350
MSDevice_SSM::Encounter::ConflictPointInfo::type
EncounterType type
Type of the conflict.
Definition: MSDevice_SSM.h:194
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
MSDevice_SSM::Encounter::operator=
Encounter & operator=(const Encounter &)
Invalidated assignment operator.
MSDevice_SSM
A device which collects info on the vehicle trip (mainly on departure and arrival)
Definition: MSDevice_SSM.h:57
MSDevice_SSM::updatePassedEncounter
void updatePassedEncounter(Encounter *e, FoeInfo *foeInfo, EncounterApproachInfo &eInfo)
Updates an encounter, which was classified as ENCOUNTER_TYPE_NOCONFLICT_AHEAD this may be the case be...
Definition: MSDevice_SSM.cpp:1635
MSDevice_SSM::Encounter::egoTrajectory
Trajectory egoTrajectory
Trajectory of the ego vehicle.
Definition: MSDevice_SSM.h:259
MSDevice_SSM::closeEncounter
void closeEncounter(Encounter *e)
Finalizes the encounter and calculates SSM values.
Definition: MSDevice_SSM.cpp:656
MSVehicleDevice.h
MSJunction
The base class for an intersection.
Definition: MSJunction.h:61
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
MSDevice_SSM::Encounter::ConflictPointInfo::pos
Position pos
Predicted location of the conflict: In case of MERGING and CROSSING: entry point to conflict area for...
Definition: MSDevice_SSM.h:192
MSDevice_SSM::FoeInfo::egoConflictLane
const MSLane * egoConflictLane
Definition: MSDevice_SSM.h:330
MSDevice_SSM::EncounterApproachInfo::ttc
double ttc
Definition: MSDevice_SSM.h:318
MSDevice_SSM::Encounter::Trajectory::x
PositionVector x
Definition: MSDevice_SSM.h:180
MSDevice_SSM::Encounter::egoID
const std::string egoID
Definition: MSDevice_SSM.h:241
MSDevice_SSM::computeGlobalMeasures
void computeGlobalMeasures()
Stores measures, that are not associated to a specific encounter as headways and brake rates.
Definition: MSDevice_SSM.cpp:453
MSDevice_SSM::makeStringWithNAs
static std::string makeStringWithNAs(std::vector< double > v, double NA, std::string sep=" ")
make a string of a double vector and treat a special value as invalid ("NA")
Definition: MSDevice_SSM.cpp:2698
MSDevice_SSM::resetEncounters
void resetEncounters()
Closes all current Encounters and moves conflicts to myPastConflicts,.
Definition: MSDevice_SSM.cpp:537
MSDevice_SSM::myGlobalMeasuresTimeSpan
std::vector< double > myGlobalMeasuresTimeSpan
Definition: MSDevice_SSM.h:724
MSDevice_SSM::createdOutputFiles
static std::set< std::string > createdOutputFiles
remember which files were created already (don't duplicate xml root-elements)
Definition: MSDevice_SSM.h:743
MSDevice_SSM::ENCOUNTER_TYPE_BOTH_LEFT_CONFLICT_AREA
ENCOUNTER_TYPE_BOTH_LEFT_CONFLICT_AREA.
Definition: MSDevice_SSM.h:109
MSDevice_SSM::updateAndWriteOutput
void updateAndWriteOutput()
This is called once per time step in MSNet::writeOutput() and collects the surrounding vehicles,...
Definition: MSDevice_SSM.cpp:394
MSDevice_SSM::myRange
double myRange
Detection range. For vehicles closer than this distance from the ego vehicle, SSMs are traced.
Definition: MSDevice_SSM.h:699
MSDevice_SSM::SSM_WARN_GEO
Definition: MSDevice_SSM.h:755
MSDevice_SSM::ENCOUNTER_TYPE_COLLISION
ENCOUNTER_TYPE_COLLISION.
Definition: MSDevice_SSM.h:118
MSDevice_SSM::myMaxBR
std::pair< std::pair< double, Position >, double > myMaxBR
Extremal values for the global measures (as <<<time, Position>, value>, [leaderID]>-pairs)
Definition: MSDevice_SSM.h:733
MSDevice_SSM::SSM_WARN_RANGE
Definition: MSDevice_SSM.h:752
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
MSDevice_SSM::ENCOUNTER_TYPE_CROSSING_LEADER
ENCOUNTER_TYPE_CROSSING_LEADER.
Definition: MSDevice_SSM.h:94
MSDevice_SSM::toGeo
static void toGeo(Position &x)
convert SUMO-positions to geo coordinates (in place)
Definition: MSDevice_SSM.cpp:2603
MSDevice_SSM::EncounterApproachInfo::egoLeftConflict
bool egoLeftConflict
Definition: MSDevice_SSM.h:316
MSDevice_SSM::EncounterApproachInfo::egoConflictAreaLength
double egoConflictAreaLength
Definition: MSDevice_SSM.h:314
MSDevice_SSM::myThresholds
std::map< std::string, double > myThresholds
Definition: MSDevice_SSM.h:694
MSDevice_SSM::cleanup
static void cleanup()
Clean up remaining devices instances.
Definition: MSDevice_SSM.cpp:191
MSDevice_SSM::EncounterApproachInfo::conflictPoint
Position conflictPoint
Definition: MSDevice_SSM.h:305
MSDevice_SSM::myOutputFile
OutputDevice * myOutputFile
Output device.
Definition: MSDevice_SSM.h:740
MSCrossSection
A simple description of a position on a lane (crossing of a lane)
Definition: MSCrossSection.h:44
MSDevice_SSM::getInstances
static const std::set< MSDevice_SSM *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing SSM devices
Definition: MSDevice_SSM.cpp:186
MSDevice_SSM::issuedParameterWarnFlags
static int issuedParameterWarnFlags
bitset storing info whether warning has already been issued about unset parameter (warn only once!...
Definition: MSDevice_SSM.h:747
MSDevice_SSM::flushGlobalMeasures
void flushGlobalMeasures()
Write out all non-encounter specific measures as headways and braking rates.
Definition: MSDevice_SSM.cpp:2549
MSDevice_SSM::myComputeTTC
bool myComputeTTC
Flags for switching on / off comutation of different SSMs, derived from myMeasures.
Definition: MSDevice_SSM.h:705
MSDevice_SSM::EncounterApproachInfo::foeLeftConflict
bool foeLeftConflict
Definition: MSDevice_SSM.h:317
PositionVector
A list of positions.
Definition: PositionVector.h:46
MSDevice_SSM::UpstreamScanStartInfo
Auxiliary structure used to handle upstream scanning start points Upstream scan has to be started aft...
Definition: MSDevice_SSM.h:344
MSDevice_SSM::createEncounters
void createEncounters(FoeInfoMap &foes)
Makes new encounters for all given vehicles (these should be the ones entering the device's range in ...
Definition: MSDevice_SSM.cpp:506
MSDevice_SSM::computeSSMs
void computeSSMs(EncounterApproachInfo &e) const
Compute current values of the logged SSMs (myMeasures) for the given encounter 'e' and update 'e' acc...
Definition: MSDevice_SSM.cpp:990
MSDevice_SSM::ENCOUNTER_TYPE_EGO_ENTERED_CONFLICT_AREA
ENCOUNTER_TYPE_EGO_ENTERED_CONFLICT_AREA.
Definition: MSDevice_SSM.h:99
MSDevice_SSM::Encounter::typeSpan
std::vector< int > typeSpan
Evolution of the encounter classification (.
Definition: MSDevice_SSM.h:257
MSDevice_SSM::Encounter::~Encounter
~Encounter()
Destructor.
Definition: MSDevice_SSM.cpp:294
MSDevice_SSM::ENCOUNTER_TYPE_FOE_ENTERED_CONFLICT_AREA
ENCOUNTER_TYPE_FOE_ENTERED_CONFLICT_AREA.
Definition: MSDevice_SSM.h:101
MSDevice_SSM::writeOutConflict
void writeOutConflict(Encounter *e)
Definition: MSDevice_SSM.cpp:2615
MSDevice_SSM::myMinTGAP
std::pair< std::pair< std::pair< double, Position >, double >, std::string > myMinTGAP
Definition: MSDevice_SSM.h:735
MSDevice_SSM::Encounter::conflictPointSpan
PositionVector conflictPointSpan
Predicted location of the conflict: In case of MERGING and CROSSING: entry point to conflict area for...
Definition: MSDevice_SSM.h:270
MSDevice_SSM::FoeInfo
Definition: MSDevice_SSM.h:329
MSDevice_SSM::myMinSGAP
std::pair< std::pair< std::pair< double, Position >, double >, std::string > myMinSGAP
Definition: MSDevice_SSM.h:734
MSDevice_SSM::Encounter::foeConflictEntryTime
double foeConflictEntryTime
Times when the foe vehicle entered/left the conflict area. Currently only applies for crossing situat...
Definition: MSDevice_SSM.h:252
MSDevice_SSM::SSM_WARN_EXTRATIME
Definition: MSDevice_SSM.h:753
MSDevice_SSM::classifyEncounter
EncounterType classifyEncounter(const FoeInfo *foeInfo, EncounterApproachInfo &eInfo) const
Classifies the current type of the encounter provided some information on the opponents.
Definition: MSDevice_SSM.cpp:1798
MSDevice_SSM::EncounterApproachInfo::egoConflictExitDist
double egoConflictExitDist
Definition: MSDevice_SSM.h:308
MSDevice_SSM::updateEncounter
bool updateEncounter(Encounter *e, FoeInfo *foeInfo)
Updates the encounter (adds a new trajectory point).
Definition: MSDevice_SSM.cpp:703
MSDevice_SSM::Encounter::begin
double begin
Definition: MSDevice_SSM.h:243
MSDevice_SSM::SSMParameterWarning
SSMParameterWarning
Definition: MSDevice_SSM.h:748
MSDevice_SSM::UpstreamScanStartInfo::edge
const MSEdge * edge
Definition: MSDevice_SSM.h:346
MSDevice_SSM::~MSDevice_SSM
~MSDevice_SSM()
Destructor.
Definition: MSDevice_SSM.cpp:2774
MSDevice_SSM::getDetectionRange
static double getDetectionRange(const SUMOVehicle &v)
Definition: MSDevice_SSM.cpp:3280
MSDevice_SSM::Encounter::foeDistsToConflict
std::vector< double > foeDistsToConflict
Evolution of the foe vehicle's distance to the conflict point.
Definition: MSDevice_SSM.h:265
MSDevice_SSM::Encounter::add
void add(double time, EncounterType type, Position egoX, Position egoV, Position foeX, Position foeV, Position conflictPoint, double egoDistToConflict, double foeDistToConflict, double ttc, double drac, std::pair< double, double > pet)
add a new data point and update encounter type
Definition: MSDevice_SSM.cpp:304
MSDevice_SSM::EncounterApproachInfo::foeEstimatedConflictExitTime
double foeEstimatedConflictExitTime
Definition: MSDevice_SSM.h:313
MSDevice_SSM::EncounterApproachInfo::EncounterApproachInfo
EncounterApproachInfo(Encounter *e)
Definition: MSDevice_SSM.cpp:371
MSDevice_SSM::flushConflicts
void flushConflicts(bool all=false)
Writes out all past conflicts that have begun earlier than the oldest active encounter.
Definition: MSDevice_SSM.cpp:2527
MSDevice_SSM::Encounter::ConflictPointInfo::ConflictPointInfo
ConflictPointInfo(double time, Position x, EncounterType type, double ssmValue)
Definition: MSDevice_SSM.h:198
MSDevice_SSM::ENCOUNTER_TYPE_EGO_LEFT_CONFLICT_AREA
ENCOUNTER_TYPE_EGO_LEFT_CONFLICT_AREA.
Definition: MSDevice_SSM.h:103
MSDevice_SSM::myActiveEncounters
EncounterVector myActiveEncounters
Definition: MSDevice_SSM.h:713
MSDevice_SSM::buildVehicleDevices
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice_SSM.cpp:230
MSDevice_SSM::Encounter::minTTC
ConflictPointInfo minTTC
Definition: MSDevice_SSM.h:283
MSDevice_SSM::Encounter::egoConflictExitTime
double egoConflictExitTime
Definition: MSDevice_SSM.h:250
MSDevice_SSM::generateOutput
void generateOutput() const
Finalizes output. Called on vehicle removal.
Definition: MSDevice_SSM.cpp:3217
MSDevice_SSM::Encounter::compare
Compares encounters regarding to their start time.
Definition: MSDevice_SSM.h:225
MSDevice_SSM::EncounterVector
std::vector< Encounter * > EncounterVector
Definition: MSDevice_SSM.h:355
MSDevice_SSM::update
void update()
Definition: MSDevice_SSM.cpp:413
MSDevice_SSM::Encounter::PET
ConflictPointInfo PET
Definition: MSDevice_SSM.h:285
MSDevice_SSM::ENCOUNTER_TYPE_MERGING
ENCOUNTER_TYPE_MERGING.
Definition: MSDevice_SSM.h:80
MSDevice_SSM::Encounter::end
double end
Definition: MSDevice_SSM.h:243
MSDevice_SSM::Encounter::remainingExtraTime
double remainingExtraTime
Remaining extra time (decreases after an encounter ended)
Definition: MSDevice_SSM.h:247
MSDevice_SSM::mySaveTrajectories
bool mySaveTrajectories
This determines whether the whole trajectories of the vehicles (position, speed, ssms) shall be saved...
Definition: MSDevice_SSM.h:697
MSDevice_SSM::ENCOUNTER_TYPE_BOTH_ENTERED_CONFLICT_AREA
ENCOUNTER_TYPE_BOTH_ENTERED_CONFLICT_AREA.
Definition: MSDevice_SSM.h:107
MSDevice_SSM::EncounterApproachInfo
Structure to collect some info on the encounter needed during ssm calculation by various functions.
Definition: MSDevice_SSM.h:301
MSDevice_SSM::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_SSM.h:473
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
MSDevice_SSM::insertOptions
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_SSM-options.
Definition: MSDevice_SSM.cpp:208
MSDevice_SSM::myHolderMS
MSVehicle * myHolderMS
Definition: MSDevice_SSM.h:706
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
MSDevice_SSM::EncounterApproachInfo::foeEstimatedConflictEntryTime
double foeEstimatedConflictEntryTime
Definition: MSDevice_SSM.h:311
MSDevice_SSM::ENCOUNTER_TYPE_CROSSING_FOLLOWER
ENCOUNTER_TYPE_CROSSING_FOLLOWER.
Definition: MSDevice_SSM.h:97
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
MSDevice_SSM::ENCOUNTER_TYPE_FOLLOWING_FOLLOWER
ENCOUNTER_TYPE_FOLLOWING_FOLLOWER.
Definition: MSDevice_SSM.h:73
MSDevice_SSM::UpstreamScanStartInfo::egoConflictLane
const MSLane * egoConflictLane
Definition: MSDevice_SSM.h:351
MSDevice_SSM::Encounter::currentType
EncounterType currentType
Definition: MSDevice_SSM.h:244
MSDevice_SSM::Encounter::foeConflictExitTime
double foeConflictExitTime
Definition: MSDevice_SSM.h:252
MSDevice_SSM::FoeInfo::egoDistToConflictLane
double egoDistToConflictLane
Definition: MSDevice_SSM.h:332
MSDevice_SSM::storeEncountersExceedingMaxLength
void storeEncountersExceedingMaxLength()
Closes encounters, whose duration exceeds the maximal encounter length. If it is classified as confli...
MSDevice_SSM::myInstances
static std::set< MSDevice_SSM *, ComparatorNumericalIdLess > * myInstances
All currently existing SSM devices.
Definition: MSDevice_SSM.h:61
MSDevice_SSM::getUpstreamVehicles
static void getUpstreamVehicles(const UpstreamScanStartInfo &scanStart, FoeInfoMap &foeCollector, std::set< const MSJunction * > &seenJunctions)
Collects all vehicles within range 'range' upstream of the position 'pos' on the edge 'edge' into foe...
Definition: MSDevice_SSM.cpp:3056
MSDevice_SSM::ENCOUNTER_TYPE_MERGING_LEADER
ENCOUNTER_TYPE_MERGING_LEADER.
Definition: MSDevice_SSM.h:83
MSDevice_SSM::Encounter::Encounter
Encounter(const MSVehicle *_ego, const MSVehicle *const _foe, double _begin, double extraTime)
Constructor.
Definition: MSDevice_SSM.cpp:270
MSDevice_SSM::EncounterApproachInfo::drac
double drac
Definition: MSDevice_SSM.h:319
MSDevice_SSM::computeTTC
double computeTTC(double gap, double followerSpeed, double leaderSpeed) const
Computes the time to collision (in seconds) for two vehicles with a given initial gap under the assum...
Definition: MSDevice_SSM.cpp:1334
MSDevice_SSM::qualifiesAsConflict
bool qualifiesAsConflict(Encounter *e)
Tests if the SSM values exceed the threshold for qualification as conflict.
Definition: MSDevice_SSM.cpp:633
MSDevice_SSM::checkConflictEntryAndExit
static void checkConflictEntryAndExit(EncounterApproachInfo &eInfo)
Checks whether ego or foe have entered or left the conflict area in the last step and eventually writ...
Definition: MSDevice_SSM.cpp:1492
MSDevice_SSM::ENCOUNTER_TYPE_ONCOMING
Definition: MSDevice_SSM.h:116
OutputDevice_File.h
MSDevice_SSM::ENCOUNTER_TYPE_FOLLOWING_LEADER
ENCOUNTER_TYPE_FOLLOWING_LEADER.
Definition: MSDevice_SSM.h:75
MSDevice_SSM::myBRspan
std::vector< double > myBRspan
All values for brake rate.
Definition: MSDevice_SSM.h:726
MSDevice_SSM::EncounterApproachInfo::egoConflictEntryCrossSection
std::pair< const MSLane *, double > egoConflictEntryCrossSection
Definition: MSDevice_SSM.h:321
MSDevice_SSM::Encounter::size
std::size_t size() const
Returns the number of trajectory points stored.
Definition: MSDevice_SSM.h:213
MSDevice_SSM::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
Definition: MSDevice_SSM.cpp:2812
MSDevice_SSM::determinePET
void determinePET(EncounterApproachInfo &eInfo) const
Discriminates between different encounter types and correspondingly determines the PET for those case...
Definition: MSDevice_SSM.cpp:1045
Position.h
MSDevice_SSM::getMeasuresAndThresholds
static bool getMeasuresAndThresholds(const SUMOVehicle &v, std::string deviceID, std::map< std::string, double > &thresholds)
Definition: MSDevice_SSM.cpp:3365
MSDevice_SSM::Encounter::DRACspan
std::vector< double > DRACspan
All values for DRAC.
Definition: MSDevice_SSM.h:275
MSDevice_SSM::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder leaves a lane.
Definition: MSDevice_SSM.cpp:2798
MSDevice_SSM::requestsTrajectories
static bool requestsTrajectories(const SUMOVehicle &v)
Definition: MSDevice_SSM.cpp:3338
MSDevice_SSM::toString
static std::string toString(EncounterType type)
Definition: MSDevice_SSM.h:121
MSDevice_SSM::EncounterQueue
std::priority_queue< Encounter *, std::vector< Encounter * >, Encounter::compare > EncounterQueue
Definition: MSDevice_SSM.h:354
MSDevice_SSM::UpstreamScanStartInfo::pos
double pos
Definition: MSDevice_SSM.h:348
MSDevice_SSM::EncounterApproachInfo::encounter
Encounter * encounter
Definition: MSDevice_SSM.h:303
MSDevice_SSM::myExtraTime
double myExtraTime
Extra time in seconds to be logged after a conflict is over.
Definition: MSDevice_SSM.h:701
MSDevice_SSM::Encounter::ConflictPointInfo::value
double value
value of the corresponding SSM
Definition: MSDevice_SSM.h:196
MSDevice_SSM::EncounterApproachInfo::egoEstimatedConflictExitTime
double egoEstimatedConflictExitTime
Definition: MSDevice_SSM.h:312
MSDevice_SSM::Encounter::compare::value_type
bool value_type
Definition: MSDevice_SSM.h:226
MSDevice_SSM::myComputeTGAP
bool myComputeTGAP
Definition: MSDevice_SSM.h:705
MSDevice_SSM::findSurroundingVehicles
static void findSurroundingVehicles(const MSVehicle &veh, double range, FoeInfoMap &foeCollector)
Returns all vehicles, which are within the given range of the given vehicle.
Definition: MSDevice_SSM.cpp:2824
MSDevice_SSM::ENCOUNTER_TYPE_NOCONFLICT_AHEAD
ENCOUNTER_TYPE_NOCONFLICT_AHEAD.
Definition: MSDevice_SSM.h:68
MSDevice_SSM::Encounter::ConflictPointInfo::time
double time
time point of the conflict
Definition: MSDevice_SSM.h:188
MSDevice_SSM::ENCOUNTER_TYPE_CROSSING
ENCOUNTER_TYPE_CROSSING.
Definition: MSDevice_SSM.h:91
MSDevice_SSM::Encounter::egoDistsToConflict
std::vector< double > egoDistsToConflict
Evolution of the ego vehicle's distance to the conflict point.
Definition: MSDevice_SSM.h:263
MSDevice_SSM::getOutputFilename
static std::string getOutputFilename(const SUMOVehicle &v, std::string deviceID)
Definition: MSDevice_SSM.cpp:3227
MSDevice_SSM::Encounter
An encounter is an episode involving two vehicles, which are closer to each other than some specified...
Definition: MSDevice_SSM.h:174
MSDevice_SSM::SSM_WARN_MEASURES
Definition: MSDevice_SSM.h:749
MSDevice_SSM::SSM_WARN_TRAJECTORIES
Definition: MSDevice_SSM.h:751
MSDevice_SSM::myComputeDRAC
bool myComputeDRAC
Definition: MSDevice_SSM.h:705
MSDevice_SSM::EncounterApproachInfo::egoEstimatedConflictEntryTime
double egoEstimatedConflictEntryTime
Definition: MSDevice_SSM.h:310
MSDevice_SSM::useGeoCoords
static bool useGeoCoords(const SUMOVehicle &v)
Definition: MSDevice_SSM.cpp:3253
MSDevice_SSM::Encounter::getRemainingExtraTime
double getRemainingExtraTime() const
returns the remaining extra time
Definition: MSDevice_SSM.cpp:366
MSDevice_SSM::EncounterApproachInfo::pet
std::pair< double, double > pet
Definition: MSDevice_SSM.h:320
MSDevice_SSM::EncounterApproachInfo::foeConflictExitDist
double foeConflictExitDist
Definition: MSDevice_SSM.h:309
MSDevice_SSM::Encounter::ConflictPointInfo
ConflictPointInfo stores some information on a specific conflict point (used to store information on ...
Definition: MSDevice_SSM.h:186
MSDevice_SSM::myOldestActiveEncounterBegin
double myOldestActiveEncounterBegin
begin time of the oldest active encounter
Definition: MSDevice_SSM.h:715
config.h
MSDevice_SSM::EncounterApproachInfo::type
EncounterType type
Definition: MSDevice_SSM.h:304
MSDevice_SSM::ENCOUNTER_TYPE_MERGING_PASSED
ENCOUNTER_TYPE_FOLLOWING_PASSED.
Definition: MSDevice_SSM.h:114
MSDevice_SSM::myPastConflicts
EncounterQueue myPastConflicts
Past encounters that where qualified as conflicts and are not yet flushed to the output file.
Definition: MSDevice_SSM.h:717
MSDevice_SSM::Encounter::ego
const MSVehicle * ego
Definition: MSDevice_SSM.h:239
MSDevice_SSM::mySGAPspan
std::vector< double > mySGAPspan
All values for space gap.
Definition: MSDevice_SSM.h:728
MSDevice_SSM::Encounter::foeTrajectory
Trajectory foeTrajectory
Trajectory of the foe vehicle.
Definition: MSDevice_SSM.h:261
MSDevice_SSM::getVehiclesOnJunction
static void getVehiclesOnJunction(const MSJunction *, double egoDistToConflictLane, const MSLane *const egoConflictLane, FoeInfoMap &foeCollector)
Collects all vehicles on the junction into foeCollector.
Definition: MSDevice_SSM.cpp:3152
MSDevice_SSM::ENCOUNTER_TYPE_ON_ADJACENT_LANES
ENCOUNTER_TYPE_ON_ADJACENT_LANES.
Definition: MSDevice_SSM.h:77
MSDevice_SSM::findFoeConflictLane
const MSLane * findFoeConflictLane(const MSVehicle *foe, const MSLane *egoConflictLane, double &distToConflictLane) const
Computes the conflict lane for the foe.
Definition: MSDevice_SSM.cpp:2393
MSDevice_SSM::myComputePET
bool myComputePET
Definition: MSDevice_SSM.h:705
MSDevice_SSM::FoeInfoMap
std::map< const MSVehicle *, FoeInfo * > FoeInfoMap
Definition: MSDevice_SSM.h:356
MSDevice_SSM::ENCOUNTER_TYPE_MERGING_FOLLOWER
ENCOUNTER_TYPE_MERGING_FOLLOWER.
Definition: MSDevice_SSM.h:86
MSDevice_SSM::Encounter::Trajectory::v
PositionVector v
Definition: MSDevice_SSM.h:182
MSDevice_SSM::computeDRAC
static double computeDRAC(double gap, double followerSpeed, double leaderSpeed)
Computes the DRAC (deceleration to avoid a collision) for a lead/follow situation as defined,...
Definition: MSDevice_SSM.cpp:1356
MSDevice_SSM::ENCOUNTER_TYPE_FOLLOWING
ENCOUNTER_TYPE_FOLLOWING.
Definition: MSDevice_SSM.h:71
MSDevice_SSM::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder enteres a lane.
Definition: MSDevice_SSM.cpp:2785
MSDevice_SSM::EncounterApproachInfo::egoConflictEntryDist
double egoConflictEntryDist
Definition: MSDevice_SSM.h:306
MSDevice_SSM::Encounter::egoConflictEntryTime
double egoConflictEntryTime
Times when the ego vehicle entered/left the conflict area. Currently only applies for crossing situat...
Definition: MSDevice_SSM.h:250
MSDevice_SSM::EncounterApproachInfo::foeConflictEntryDist
double foeConflictEntryDist
Definition: MSDevice_SSM.h:307
MSDevice_SSM::myComputeBR
bool myComputeBR
Definition: MSDevice_SSM.h:705
MSDevice_SSM::Encounter::maxDRAC
ConflictPointInfo maxDRAC
Definition: MSDevice_SSM.h:284
MSDevice_SSM::Encounter::resetExtraTime
void resetExtraTime(double value)
resets remainingExtraTime to the given value
Definition: MSDevice_SSM.cpp:354
MSDevice_SSM::estimateConflictTimes
static void estimateConflictTimes(EncounterApproachInfo &eInfo)
Estimates the time until conflict for the vehicles based on the distance to the conflict entry points...
Definition: MSDevice_SSM.cpp:857
MSDevice_SSM::determineTTCandDRAC
void determineTTCandDRAC(EncounterApproachInfo &eInfo) const
Discriminates between different encounter types and correspondingly determines TTC and DRAC for those...
Definition: MSDevice_SSM.cpp:1147
MSDevice_SSM::MSDevice_SSM
MSDevice_SSM(SUMOVehicle &holder, const std::string &id, std::string outputFilename, std::map< std::string, double > thresholds, bool trajectories, double range, double extraTime, bool useGeoCoords)
Constructor.
Definition: MSDevice_SSM.cpp:2719
MSDevice_SSM::SSM_WARN_THRESHOLDS
Definition: MSDevice_SSM.h:750
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:89
MSDevice_SSM::myUseGeoCoords
bool myUseGeoCoords
Whether to use the original coordinate system for output.
Definition: MSDevice_SSM.h:703
MSDevice_SSM::ENCOUNTER_TYPE_FOE_LEFT_CONFLICT_AREA
ENCOUNTER_TYPE_FOE_LEFT_CONFLICT_AREA.
Definition: MSDevice_SSM.h:105
MSDevice_SSM::Encounter::closingRequested
bool closingRequested
this flag is set by updateEncounter() or directly in processEncounters(), where encounters are closed...
Definition: MSDevice_SSM.h:289
MSDevice_SSM::EncounterApproachInfo::foeConflictEntryCrossSection
std::pair< const MSLane *, double > foeConflictEntryCrossSection
Definition: MSDevice_SSM.h:322
MSDevice_SSM::myComputeSGAP
bool myComputeSGAP
Definition: MSDevice_SSM.h:705
MSDevice_SSM::determineConflictPoint
static void determineConflictPoint(EncounterApproachInfo &eInfo)
Calculates the (x,y)-coordinate for the eventually predicted conflict point and stores the result in ...
Definition: MSDevice_SSM.cpp:804
MSDevice_SSM::Encounter::Trajectory
A trajectory encloses a series of positions x and speeds v for one vehicle (the times are stored only...
Definition: MSDevice_SSM.h:178
MSDevice_SSM::processEncounters
void processEncounters(FoeInfoMap &foes, bool forceClose=false)
Finds encounters for which the foe vehicle has disappeared from range. remainingExtraTime is decrease...
Definition: MSDevice_SSM.cpp:545
MSDevice_SSM::EncounterType
EncounterType
Different types of encounters corresponding to relative positions of the vehicles....
Definition: MSDevice_SSM.h:66
MSDevice_SSM::ENCOUNTER_TYPE_MERGING_ADJACENT
ENCOUNTER_TYPE_MERGING_ADJACENT.
Definition: MSDevice_SSM.h:88
MSDevice_SSM::Encounter::compare::operator()
bool operator()(Encounter *e1, Encounter *e2)
Definition: MSDevice_SSM.h:227
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
MSDevice_SSM::SSM_WARN_FILE
Definition: MSDevice_SSM.h:754
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:55
MSDevice_SSM::Encounter::foe
const MSVehicle * foe
Definition: MSDevice_SSM.h:240