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 /****************************************************************************/
16 // An SSM-device logs encounters / conflicts of the carrying vehicle with other surrounding vehicles.
17 // XXX: Preliminary implementation. Use with care. Especially rerouting vehicles could be problematic.
18 /****************************************************************************/
19 #ifndef MSDevice_SSM_h
20 #define MSDevice_SSM_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <queue>
29 #include "MSVehicleDevice.h"
30 #include <utils/common/SUMOTime.h>
32 #include <utils/geom/Position.h>
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class SUMOVehicle;
39 class SUMOTrafficObject;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
54 class MSCrossSection;
55 
56 class MSDevice_SSM : public MSVehicleDevice {
57 
58 private:
60  static std::set<MSDevice_SSM*, ComparatorNumericalIdLess>* myInstances;
61 
62 public:
66  // Other vehicle is closer than range, but not on a lane conflicting with the ego's route ahead
68  // Ego and foe vehicles' edges form a part of a consecutive sequence of edges
69  // This type may be specified further by ENCOUNTER_TYPE_FOLLOWING_LEADER or ENCOUNTER_TYPE_FOLLOWING_FOLLOWER
71  // Ego vehicle is on an edge that has a sequence of successors connected to the other vehicle's edge
73  // Other vehicle is on an edge that has a sequence of successors connected to the ego vehicle's current edge
75  // Other vehicle is on an edge that has a sequence of successors connected to the ego vehicle's current edge
77  // Ego and foe share an upcoming edge of their routes while the merging point for the routes is still ahead
78  // This type may be specified further by ENCOUNTER_TYPE_MERGING_LEADER or ENCOUNTER_TYPE_MERGING_FOLLOWER
80  // Other vehicle is on an edge that has a sequence of successors connected to an edge on the ego vehicle's route
81  // and the estimated arrival vehicle at the merge point is earlier for the ego than for the foe
83  // Other vehicle is on an edge that has a sequence of successors connected to an edge on the ego vehicle's route
84  // and the estimated arrival vehicle at the merge point is earlier for the foe than for the ego
86  // Vehicles' bestlanes lead to the same edge but to adjacent lanes
88  // Ego's and foe's routes have crossing edges
89  // This type may be specified further by ENCOUNTER_TYPE_CROSSING_LEADER or ENCOUNTER_TYPE_CROSSING_FOLLOWER
91  // 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
92  // and the estimated arrival vehicle at the merge point is earlier for the ego than for the foe
94  // 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
95  // and the estimated arrival vehicle at the merge point is earlier for the foe than for the ego
97  // The encounter is a possible crossing conflict, and the ego vehicle has entered the conflict area
99  // The encounter is a possible crossing conflict, and the foe vehicle has entered the conflict area
101  // The encounter has been a possible crossing conflict, but the ego vehicle has left the conflict area
103  // The encounter has been a possible crossing conflict, but the foe vehicle has left the conflict area
105  // 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)
107  // The encounter has been a possible crossing conflict, but both vehicle have left the conflict area
109  // FOLLOWING_PASSED and MERGING_PASSED are reserved to achieve that these encounter types may be tracked longer (see updatePassedEncounter)
110  // The encounter has been a following situation, but is not active any more
112  // The encounter has been a merging situation, but is not active any more
114  // Ego vehicle and foe are driving in opposite directions towards each other on the same lane (or sequence of consecutive lanes)
116  // Collision (currently unused, might be differentiated further)
118  };
119 
120  static std::string encounterToString(EncounterType type) {
121  switch (type) {
123  return ("NOCONFLICT_AHEAD");
125  return ("FOLLOWING");
127  return ("FOLLOWING_FOLLOWER");
129  return ("FOLLOWING_LEADER");
131  return ("ON_ADJACENT_LANES");
132  case (ENCOUNTER_TYPE_MERGING):
133  return ("MERGING");
135  return ("MERGING_LEADER");
137  return ("MERGING_FOLLOWER");
139  return ("MERGING_ADJACENT");
141  return ("CROSSING");
143  return ("CROSSING_LEADER");
145  return ("CROSSING_FOLLOWER");
147  return ("EGO_ENTERED_CONFLICT_AREA");
149  return ("FOE_ENTERED_CONFLICT_AREA");
151  return ("EGO_LEFT_CONFLICT_AREA");
153  return ("FOE_LEFT_CONFLICT_AREA");
155  return ("BOTH_ENTERED_CONFLICT_AREA");
157  return ("BOTH_LEFT_CONFLICT_AREA");
159  return ("FOLLOWING_PASSED");
161  return ("MERGING_PASSED");
163  return ("ONCOMING");
165  return ("COLLISION");
166  }
167  return ("UNKNOWN");
168  };
169 
170 private:
173  class Encounter {
174  private:
177  struct Trajectory {
178  // positions
180  // momentary speeds
182  };
187  double time;
195  double value;
196 
197  ConflictPointInfo(double time, Position x, EncounterType type, double ssmValue) :
198  time(time), pos(x), type(type), value(ssmValue) {};
199  };
200 
201  public:
203  Encounter(const MSVehicle* _ego, const MSVehicle* const _foe, double _begin, double extraTime);
205  ~Encounter();
206 
208  void add(double time, EncounterType type, Position egoX, Position egoV, Position foeX, Position foeV,
209  Position conflictPoint, double egoDistToConflict, double foeDistToConflict, double ttc, double drac, std::pair<double, double> pet);
210 
212  std::size_t size() const {
213  return timeSpan.size();
214  }
215 
217  void resetExtraTime(double value);
219  void countDownExtraTime(double amount);
221  double getRemainingExtraTime() const;
222 
224  struct compare {
225  typedef bool value_type;
226  bool operator()(Encounter* e1, Encounter* e2) {
227  if (e1->begin == e2->begin) {
228  return e1->foeID > e2->foeID;
229  } else {
230  return e1->begin > e2->begin;
231  }
232  };
233  };
234 
235 
236 
237  public:
238  const MSVehicle* ego;
239  const MSVehicle* foe;
240  const std::string egoID;
241  const std::string foeID;
242  double begin, end;
244 
247 
252 
254  std::vector<double> timeSpan;
256  std::vector<int> typeSpan;
262  std::vector<double> egoDistsToConflict;
264  std::vector<double> foeDistsToConflict;
265 
270 
272  std::vector<double> TTCspan;
274  std::vector<double> DRACspan;
275 
276 // /// @brief Cross sections at which a PET shall be calculated for the corresponding vehicle
277 // std::vector<std::pair<std::pair<const MSLane*, double>, double> > egoPETCrossSections;
278 // std::vector<std::pair<std::pair<const MSLane*, double>, double> > foePETCrossSections;
279 
286 
289 
290  private:
292  Encounter(const Encounter&);
294  Encounter& operator=(const Encounter&);
296  };
297 
298 
317  double ttc;
318  double drac;
319  std::pair<double, double> pet;
320  std::pair<const MSLane*, double> egoConflictEntryCrossSection;
321  std::pair<const MSLane*, double> foeConflictEntryCrossSection;
322  };
323 
324 
328  struct FoeInfo {
329  virtual ~FoeInfo() {};
330  const MSLane* egoConflictLane;
332  };
333  // TODO: consider introducing a class foeCollector, which holds the foe info content
334  // plus a vehicle container to be used in findSurrounding vehicles.
335  // findSurroundingVehicles() would then deliver a vector of such foeCollectors
336  // (one for each possible egoConflictLane) instead of a map vehicle->foeInfo
337  // This could be helpful to resolve the resolution for several different
338  // projected conflicts with the same foe.
339 
340 
346  const MSEdge* edge;
347  double pos;
348  double range;
351  };
352 
353  typedef std::priority_queue<Encounter*, std::vector<Encounter*>, Encounter::compare> EncounterQueue;
354  typedef std::vector<Encounter*> EncounterVector;
355  typedef std::map<const MSVehicle*, FoeInfo*> FoeInfoMap;
356 public:
357 
361  static void insertOptions(OptionsCont& oc);
362 
363 
374  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
375 
376 
379  static const std::set<MSDevice_SSM*, ComparatorNumericalIdLess>& getInstances();
380 
386  void updateAndWriteOutput();
387 
389  std::string getParameter(const std::string& key) const;
390 
392  void setParameter(const std::string& key, const std::string& value);
393 
394 private:
395  void update();
396  void writeOutConflict(Encounter* e);
397 
399  static void toGeo(Position& x);
401  static void toGeo(PositionVector& x);
402 
403 public:
406  static void cleanup();
407 
408 
409 public:
411  ~MSDevice_SSM();
412 
413 
425  static void findSurroundingVehicles(const MSVehicle& veh, double range, FoeInfoMap& foeCollector);
426 
429  static void getUpstreamVehicles(const UpstreamScanStartInfo& scanStart, FoeInfoMap& foeCollector, std::set<const MSLane*>& seenLanes, const std::set<const MSJunction*>& routeJunctions);
430 
433  static void getVehiclesOnJunction(const MSJunction*, const MSLane* egoJunctionLane, double egoDistToConflictLane, const MSLane* const egoConflictLane, FoeInfoMap& foeCollector, std::set<const MSLane*>& seenLanes);
434 
435 
438 
448  bool notifyMove(SUMOTrafficObject& veh, double oldPos,
449  double newPos, double newSpeed);
450 
451 
461  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
462 
463 
472  bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
473  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
475 
476 
478  const std::string deviceName() const {
479  return "ssm";
480  }
481 
488  void generateOutput() const;
489 
490 
491 
492 private:
504  MSDevice_SSM(SUMOVehicle& holder, const std::string& id, std::string outputFilename, std::map<std::string, double> thresholds,
505  bool trajectories, double range, double extraTime, bool useGeoCoords);
506 
515  void processEncounters(FoeInfoMap& foes, bool forceClose = false);
516 
517 
522 
523 
524 
527  void createEncounters(FoeInfoMap& foes);
528 
529 
534  void computeGlobalMeasures();
535 
538  void resetEncounters();
539 
543  void flushConflicts(bool all = false);
544 
548  void flushGlobalMeasures();
549 
554  bool updateEncounter(Encounter* e, FoeInfo* foeInfo);
555 
565  void updatePassedEncounter(Encounter* e, FoeInfo* foeInfo, EncounterApproachInfo& eInfo);
566 
567 
578  EncounterType classifyEncounter(const FoeInfo* foeInfo, EncounterApproachInfo& eInfo) const;
579 
580 
586  static void determineConflictPoint(EncounterApproachInfo& eInfo);
587 
588 
598  static void estimateConflictTimes(EncounterApproachInfo& eInfo);
599 
600 
607  static void checkConflictEntryAndExit(EncounterApproachInfo& eInfo);
608 
609 
618  const MSLane* findFoeConflictLane(const MSVehicle* foe, const MSLane* egoConflictLane, double& distToConflictLane) const;
619 
622  void closeEncounter(Encounter* e);
623 
626  bool qualifiesAsConflict(Encounter* e);
627 
632  void computeSSMs(EncounterApproachInfo& e) const;
633 
634 
638  void determinePET(EncounterApproachInfo& eInfo) const;
639 
640 
644  void determineTTCandDRAC(EncounterApproachInfo& eInfo) const;
645 
646 
650  double computeTTC(double gap, double followerSpeed, double leaderSpeed) const;
651 
652 
658  static double computeDRAC(double gap, double followerSpeed, double leaderSpeed);
659 
671  static double computeDRAC(const EncounterApproachInfo& eInfo);
672 
680  static std::string makeStringWithNAs(std::vector<double> v, double NA, std::string sep = " ");
681  static std::string makeStringWithNAs(std::vector<double> v, std::vector<double> NAs, std::string sep = " ");
682 
685  static std::string getOutputFilename(const SUMOVehicle& v, std::string deviceID);
686  static double getDetectionRange(const SUMOVehicle& v);
687  static double getExtraTime(const SUMOVehicle& v);
688  static bool useGeoCoords(const SUMOVehicle& v);
689  static bool requestsTrajectories(const SUMOVehicle& v);
690  static bool getMeasuresAndThresholds(const SUMOVehicle& v, std::string deviceID,
691  std::map<std::string, double>& thresholds);
693 
694 private:
699  std::map<std::string, double> myThresholds;
704  double myRange;
706  double myExtraTime;
713 
714 
724 
725 
726 
729  std::vector<double> myGlobalMeasuresTimeSpan;
731  std::vector<double> myBRspan;
733  std::vector<double> mySGAPspan;
735  std::vector<double> myTGAPspan;
738  std::pair<std::pair<double, Position>, double> myMaxBR;
739  std::pair<std::pair<std::pair<double, Position>, double>, std::string> myMinSGAP;
740  std::pair<std::pair<std::pair<double, Position>, double>, std::string> myMinTGAP;
743 
746 
748  static std::set<std::string> createdOutputFiles;
749 
750 
757  SSM_WARN_RANGE = 1 << 3,
759  SSM_WARN_FILE = 1 << 5,
760  SSM_WARN_GEO = 1 << 6
761  };
762 
763 
764 
765 private:
767  MSDevice_SSM(const MSDevice_SSM&);
768 
771 
772 
773 };
774 
775 #endif
776 
777 /****************************************************************************/
778 
MSDevice_SSM::EncounterApproachInfo::foeConflictAreaLength
double foeConflictAreaLength
Definition: MSDevice_SSM.h:314
MSDevice_SSM::operator=
MSDevice_SSM & operator=(const MSDevice_SSM &)
Invalidated assignment operator.
MSDevice_SSM::UpstreamScanStartInfo::range
double range
Definition: MSDevice_SSM.h:348
MSDevice_SSM::UpstreamScanStartInfo::UpstreamScanStartInfo
UpstreamScanStartInfo(const MSEdge *edge, double pos, double range, double egoDistToConflictLane, const MSLane *egoConflictLane)
Definition: MSDevice_SSM.h:344
MSDevice_SSM::FoeInfo::~FoeInfo
virtual ~FoeInfo()
Definition: MSDevice_SSM.h:329
MSDevice_SSM::Encounter::TTCspan
std::vector< double > TTCspan
All values for TTC.
Definition: MSDevice_SSM.h:272
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
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:3420
MSDevice_SSM::myTGAPspan
std::vector< double > myTGAPspan
All values for time gap.
Definition: MSDevice_SSM.h:735
MSDevice_SSM::ENCOUNTER_TYPE_FOLLOWING_PASSED
ENCOUNTER_TYPE_FOLLOWING_PASSED.
Definition: MSDevice_SSM.h:111
MSDevice_SSM::Encounter::timeSpan
std::vector< double > timeSpan
time points corresponding to the trajectories
Definition: MSDevice_SSM.h:254
MSDevice_SSM::getParameter
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
Definition: MSDevice_SSM.cpp:3581
MSDevice_SSM::Encounter::foeID
const std::string foeID
Definition: MSDevice_SSM.h:241
MSDevice_SSM::UpstreamScanStartInfo::egoDistToConflictLane
double egoDistToConflictLane
Definition: MSDevice_SSM.h:349
MSDevice_SSM::Encounter::ConflictPointInfo::type
EncounterType type
Type of the conflict.
Definition: MSDevice_SSM.h:193
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
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:56
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:258
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:60
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
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:191
MSDevice_SSM::FoeInfo::egoConflictLane
const MSLane * egoConflictLane
Definition: MSDevice_SSM.h:329
MSDevice_SSM::EncounterApproachInfo::ttc
double ttc
Definition: MSDevice_SSM.h:317
MSDevice_SSM::Encounter::Trajectory::x
PositionVector x
Definition: MSDevice_SSM.h:179
MSDevice_SSM::Encounter::egoID
const std::string egoID
Definition: MSDevice_SSM.h:240
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:2699
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:729
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:748
MSDevice_SSM::ENCOUNTER_TYPE_BOTH_LEFT_CONFLICT_AREA
ENCOUNTER_TYPE_BOTH_LEFT_CONFLICT_AREA.
Definition: MSDevice_SSM.h:108
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:704
MSDevice_SSM::SSM_WARN_GEO
Definition: MSDevice_SSM.h:760
MSDevice_SSM::ENCOUNTER_TYPE_COLLISION
ENCOUNTER_TYPE_COLLISION.
Definition: MSDevice_SSM.h:117
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:738
MSDevice_SSM::SSM_WARN_RANGE
Definition: MSDevice_SSM.h:757
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSDevice_SSM::ENCOUNTER_TYPE_CROSSING_LEADER
ENCOUNTER_TYPE_CROSSING_LEADER.
Definition: MSDevice_SSM.h:93
MSDevice_SSM::toGeo
static void toGeo(Position &x)
convert SUMO-positions to geo coordinates (in place)
Definition: MSDevice_SSM.cpp:2604
MSDevice_SSM::EncounterApproachInfo::egoLeftConflict
bool egoLeftConflict
Definition: MSDevice_SSM.h:315
MSDevice_SSM::EncounterApproachInfo::egoConflictAreaLength
double egoConflictAreaLength
Definition: MSDevice_SSM.h:313
MSDevice_SSM::myThresholds
std::map< std::string, double > myThresholds
Definition: MSDevice_SSM.h:699
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:304
MSDevice_SSM::myOutputFile
OutputDevice * myOutputFile
Output device.
Definition: MSDevice_SSM.h:745
MSCrossSection
A simple description of a position on a lane (crossing of a lane)
Definition: MSCrossSection.h:43
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:752
MSDevice_SSM::flushGlobalMeasures
void flushGlobalMeasures()
Write out all non-encounter specific measures as headways and braking rates.
Definition: MSDevice_SSM.cpp:2550
MSDevice_SSM::myComputeTTC
bool myComputeTTC
Flags for switching on / off comutation of different SSMs, derived from myMeasures.
Definition: MSDevice_SSM.h:710
MSDevice_SSM::EncounterApproachInfo::foeLeftConflict
bool foeLeftConflict
Definition: MSDevice_SSM.h:316
PositionVector
A list of positions.
Definition: PositionVector.h:45
MSDevice_SSM::UpstreamScanStartInfo
Auxiliary structure used to handle upstream scanning start points Upstream scan has to be started aft...
Definition: MSDevice_SSM.h:343
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:98
MSDevice_SSM::Encounter::typeSpan
std::vector< int > typeSpan
Evolution of the encounter classification (.
Definition: MSDevice_SSM.h:256
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:100
MSDevice_SSM::writeOutConflict
void writeOutConflict(Encounter *e)
Definition: MSDevice_SSM.cpp:2616
MSDevice_SSM::myMinTGAP
std::pair< std::pair< std::pair< double, Position >, double >, std::string > myMinTGAP
Definition: MSDevice_SSM.h:740
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:269
MSDevice_SSM::FoeInfo
Definition: MSDevice_SSM.h:328
MSDevice_SSM::myMinSGAP
std::pair< std::pair< std::pair< double, Position >, double >, std::string > myMinSGAP
Definition: MSDevice_SSM.h:739
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:251
MSDevice_SSM::SSM_WARN_EXTRATIME
Definition: MSDevice_SSM.h:758
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:307
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:242
MSDevice_SSM::SSMParameterWarning
SSMParameterWarning
Definition: MSDevice_SSM.h:753
MSDevice_SSM::UpstreamScanStartInfo::edge
const MSEdge * edge
Definition: MSDevice_SSM.h:345
MSDevice_SSM::~MSDevice_SSM
~MSDevice_SSM()
Destructor.
Definition: MSDevice_SSM.cpp:2775
MSDevice_SSM::getDetectionRange
static double getDetectionRange(const SUMOVehicle &v)
Definition: MSDevice_SSM.cpp:3393
MSDevice_SSM::Encounter::foeDistsToConflict
std::vector< double > foeDistsToConflict
Evolution of the foe vehicle's distance to the conflict point.
Definition: MSDevice_SSM.h:264
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:312
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:2528
MSDevice_SSM::Encounter::ConflictPointInfo::ConflictPointInfo
ConflictPointInfo(double time, Position x, EncounterType type, double ssmValue)
Definition: MSDevice_SSM.h:197
MSDevice_SSM::ENCOUNTER_TYPE_EGO_LEFT_CONFLICT_AREA
ENCOUNTER_TYPE_EGO_LEFT_CONFLICT_AREA.
Definition: MSDevice_SSM.h:102
MSDevice_SSM::myActiveEncounters
EncounterVector myActiveEncounters
Definition: MSDevice_SSM.h:718
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:282
MSDevice_SSM::Encounter::egoConflictExitTime
double egoConflictExitTime
Definition: MSDevice_SSM.h:249
MSDevice_SSM::generateOutput
void generateOutput() const
Finalizes output. Called on vehicle removal.
Definition: MSDevice_SSM.cpp:3330
MSDevice_SSM::Encounter::compare
Compares encounters regarding to their start time.
Definition: MSDevice_SSM.h:224
MSDevice_SSM::EncounterVector
std::vector< Encounter * > EncounterVector
Definition: MSDevice_SSM.h:354
MSDevice_SSM::update
void update()
Definition: MSDevice_SSM.cpp:413
MSDevice_SSM::Encounter::PET
ConflictPointInfo PET
Definition: MSDevice_SSM.h:284
MSDevice_SSM::ENCOUNTER_TYPE_MERGING
ENCOUNTER_TYPE_MERGING.
Definition: MSDevice_SSM.h:79
MSDevice_SSM::Encounter::end
double end
Definition: MSDevice_SSM.h:242
MSDevice_SSM::Encounter::remainingExtraTime
double remainingExtraTime
Remaining extra time (decreases after an encounter ended)
Definition: MSDevice_SSM.h:246
MSDevice_SSM::mySaveTrajectories
bool mySaveTrajectories
This determines whether the whole trajectories of the vehicles (position, speed, ssms) shall be saved...
Definition: MSDevice_SSM.h:702
MSDevice_SSM::ENCOUNTER_TYPE_BOTH_ENTERED_CONFLICT_AREA
ENCOUNTER_TYPE_BOTH_ENTERED_CONFLICT_AREA.
Definition: MSDevice_SSM.h:106
MSDevice_SSM::EncounterApproachInfo
Structure to collect some info on the encounter needed during ssm calculation by various functions.
Definition: MSDevice_SSM.h:300
MSDevice_SSM::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_SSM.h:478
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
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:711
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
MSDevice_SSM::EncounterApproachInfo::foeEstimatedConflictEntryTime
double foeEstimatedConflictEntryTime
Definition: MSDevice_SSM.h:310
MSDevice_SSM::ENCOUNTER_TYPE_CROSSING_FOLLOWER
ENCOUNTER_TYPE_CROSSING_FOLLOWER.
Definition: MSDevice_SSM.h:96
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MSDevice_SSM::ENCOUNTER_TYPE_FOLLOWING_FOLLOWER
ENCOUNTER_TYPE_FOLLOWING_FOLLOWER.
Definition: MSDevice_SSM.h:72
MSDevice_SSM::UpstreamScanStartInfo::egoConflictLane
const MSLane * egoConflictLane
Definition: MSDevice_SSM.h:350
MSDevice_SSM::Encounter::currentType
EncounterType currentType
Definition: MSDevice_SSM.h:243
MSDevice_SSM::Encounter::foeConflictExitTime
double foeConflictExitTime
Definition: MSDevice_SSM.h:251
MSDevice_SSM::FoeInfo::egoDistToConflictLane
double egoDistToConflictLane
Definition: MSDevice_SSM.h:331
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:60
MSDevice_SSM::ENCOUNTER_TYPE_MERGING_LEADER
ENCOUNTER_TYPE_MERGING_LEADER.
Definition: MSDevice_SSM.h:82
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:318
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:115
OutputDevice_File.h
MSDevice_SSM::ENCOUNTER_TYPE_FOLLOWING_LEADER
ENCOUNTER_TYPE_FOLLOWING_LEADER.
Definition: MSDevice_SSM.h:74
MSDevice_SSM::myBRspan
std::vector< double > myBRspan
All values for brake rate.
Definition: MSDevice_SSM.h:731
MSDevice_SSM::EncounterApproachInfo::egoConflictEntryCrossSection
std::pair< const MSLane *, double > egoConflictEntryCrossSection
Definition: MSDevice_SSM.h:320
MSDevice_SSM::Encounter::size
std::size_t size() const
Returns the number of trajectory points stored.
Definition: MSDevice_SSM.h:212
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:2813
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:3478
MSDevice_SSM::Encounter::DRACspan
std::vector< double > DRACspan
All values for DRAC.
Definition: MSDevice_SSM.h:274
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:2799
MSDevice_SSM::requestsTrajectories
static bool requestsTrajectories(const SUMOVehicle &v)
Definition: MSDevice_SSM.cpp:3451
MSDevice_SSM::EncounterQueue
std::priority_queue< Encounter *, std::vector< Encounter * >, Encounter::compare > EncounterQueue
Definition: MSDevice_SSM.h:353
MSDevice_SSM::getUpstreamVehicles
static void getUpstreamVehicles(const UpstreamScanStartInfo &scanStart, FoeInfoMap &foeCollector, std::set< const MSLane * > &seenLanes, const std::set< const MSJunction * > &routeJunctions)
Collects all vehicles within range 'range' upstream of the position 'pos' on the edge 'edge' into foe...
Definition: MSDevice_SSM.cpp:3100
MSDevice_SSM::UpstreamScanStartInfo::pos
double pos
Definition: MSDevice_SSM.h:347
MSDevice_SSM::EncounterApproachInfo::encounter
Encounter * encounter
Definition: MSDevice_SSM.h:302
MSDevice_SSM::getVehiclesOnJunction
static void getVehiclesOnJunction(const MSJunction *, const MSLane *egoJunctionLane, double egoDistToConflictLane, const MSLane *const egoConflictLane, FoeInfoMap &foeCollector, std::set< const MSLane * > &seenLanes)
Collects all vehicles on the junction into foeCollector.
Definition: MSDevice_SSM.cpp:3231
MSDevice_SSM::myExtraTime
double myExtraTime
Extra time in seconds to be logged after a conflict is over.
Definition: MSDevice_SSM.h:706
MSDevice_SSM::Encounter::ConflictPointInfo::value
double value
value of the corresponding SSM
Definition: MSDevice_SSM.h:195
MSDevice_SSM::EncounterApproachInfo::egoEstimatedConflictExitTime
double egoEstimatedConflictExitTime
Definition: MSDevice_SSM.h:311
MSDevice_SSM::Encounter::compare::value_type
bool value_type
Definition: MSDevice_SSM.h:225
MSDevice_SSM::myComputeTGAP
bool myComputeTGAP
Definition: MSDevice_SSM.h:710
MSDevice_SSM::setParameter
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
Definition: MSDevice_SSM.cpp:3621
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:2825
MSDevice_SSM::ENCOUNTER_TYPE_NOCONFLICT_AHEAD
ENCOUNTER_TYPE_NOCONFLICT_AHEAD.
Definition: MSDevice_SSM.h:67
MSDevice_SSM::Encounter::ConflictPointInfo::time
double time
time point of the conflict
Definition: MSDevice_SSM.h:187
MSDevice_SSM::ENCOUNTER_TYPE_CROSSING
ENCOUNTER_TYPE_CROSSING.
Definition: MSDevice_SSM.h:90
MSDevice_SSM::Encounter::egoDistsToConflict
std::vector< double > egoDistsToConflict
Evolution of the ego vehicle's distance to the conflict point.
Definition: MSDevice_SSM.h:262
MSDevice_SSM::getOutputFilename
static std::string getOutputFilename(const SUMOVehicle &v, std::string deviceID)
Definition: MSDevice_SSM.cpp:3340
MSDevice_SSM::Encounter
An encounter is an episode involving two vehicles, which are closer to each other than some specified...
Definition: MSDevice_SSM.h:173
MSDevice_SSM::SSM_WARN_MEASURES
Definition: MSDevice_SSM.h:754
MSDevice_SSM::SSM_WARN_TRAJECTORIES
Definition: MSDevice_SSM.h:756
MSDevice_SSM::myComputeDRAC
bool myComputeDRAC
Definition: MSDevice_SSM.h:710
MSDevice_SSM::EncounterApproachInfo::egoEstimatedConflictEntryTime
double egoEstimatedConflictEntryTime
Definition: MSDevice_SSM.h:309
MSDevice_SSM::useGeoCoords
static bool useGeoCoords(const SUMOVehicle &v)
Definition: MSDevice_SSM.cpp:3366
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:319
MSDevice_SSM::EncounterApproachInfo::foeConflictExitDist
double foeConflictExitDist
Definition: MSDevice_SSM.h:308
MSDevice_SSM::Encounter::ConflictPointInfo
ConflictPointInfo stores some information on a specific conflict point (used to store information on ...
Definition: MSDevice_SSM.h:185
MSDevice_SSM::myOldestActiveEncounterBegin
double myOldestActiveEncounterBegin
begin time of the oldest active encounter
Definition: MSDevice_SSM.h:720
config.h
MSDevice_SSM::EncounterApproachInfo::type
EncounterType type
Definition: MSDevice_SSM.h:303
MSDevice_SSM::ENCOUNTER_TYPE_MERGING_PASSED
ENCOUNTER_TYPE_FOLLOWING_PASSED.
Definition: MSDevice_SSM.h:113
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:722
MSDevice_SSM::Encounter::ego
const MSVehicle * ego
Definition: MSDevice_SSM.h:238
MSDevice_SSM::mySGAPspan
std::vector< double > mySGAPspan
All values for space gap.
Definition: MSDevice_SSM.h:733
MSDevice_SSM::Encounter::foeTrajectory
Trajectory foeTrajectory
Trajectory of the foe vehicle.
Definition: MSDevice_SSM.h:260
MSDevice_SSM::ENCOUNTER_TYPE_ON_ADJACENT_LANES
ENCOUNTER_TYPE_ON_ADJACENT_LANES.
Definition: MSDevice_SSM.h:76
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:2394
MSDevice_SSM::myComputePET
bool myComputePET
Definition: MSDevice_SSM.h:710
MSDevice_SSM::FoeInfoMap
std::map< const MSVehicle *, FoeInfo * > FoeInfoMap
Definition: MSDevice_SSM.h:355
MSDevice_SSM::ENCOUNTER_TYPE_MERGING_FOLLOWER
ENCOUNTER_TYPE_MERGING_FOLLOWER.
Definition: MSDevice_SSM.h:85
MSDevice_SSM::Encounter::Trajectory::v
PositionVector v
Definition: MSDevice_SSM.h:181
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:70
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:2786
MSDevice_SSM::EncounterApproachInfo::egoConflictEntryDist
double egoConflictEntryDist
Definition: MSDevice_SSM.h:305
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:249
MSDevice_SSM::EncounterApproachInfo::foeConflictEntryDist
double foeConflictEntryDist
Definition: MSDevice_SSM.h:306
MSDevice_SSM::myComputeBR
bool myComputeBR
Definition: MSDevice_SSM.h:710
MSDevice_SSM::Encounter::maxDRAC
ConflictPointInfo maxDRAC
Definition: MSDevice_SSM.h:283
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:2720
MSDevice_SSM::SSM_WARN_THRESHOLDS
Definition: MSDevice_SSM.h:755
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
MSDevice_SSM::myUseGeoCoords
bool myUseGeoCoords
Whether to use the original coordinate system for output.
Definition: MSDevice_SSM.h:708
MSDevice_SSM::ENCOUNTER_TYPE_FOE_LEFT_CONFLICT_AREA
ENCOUNTER_TYPE_FOE_LEFT_CONFLICT_AREA.
Definition: MSDevice_SSM.h:104
MSDevice_SSM::Encounter::closingRequested
bool closingRequested
this flag is set by updateEncounter() or directly in processEncounters(), where encounters are closed...
Definition: MSDevice_SSM.h:288
MSDevice_SSM::EncounterApproachInfo::foeConflictEntryCrossSection
std::pair< const MSLane *, double > foeConflictEntryCrossSection
Definition: MSDevice_SSM.h:321
MSDevice_SSM::encounterToString
static std::string encounterToString(EncounterType type)
Definition: MSDevice_SSM.h:120
MSDevice_SSM::myComputeSGAP
bool myComputeSGAP
Definition: MSDevice_SSM.h:710
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:177
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:65
MSDevice_SSM::ENCOUNTER_TYPE_MERGING_ADJACENT
ENCOUNTER_TYPE_MERGING_ADJACENT.
Definition: MSDevice_SSM.h:87
MSDevice_SSM::Encounter::compare::operator()
bool operator()(Encounter *e1, Encounter *e2)
Definition: MSDevice_SSM.h:226
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
MSDevice_SSM::SSM_WARN_FILE
Definition: MSDevice_SSM.h:759
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:54
MSDevice_SSM::Encounter::foe
const MSVehicle * foe
Definition: MSDevice_SSM.h:239