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 
345  UpstreamScanStartInfo(const MSEdge* edge, double pos, double range, double egoDistToConflictLane, const MSLane* egoConflictLane) :
346  edge(edge), pos(pos), range(range), egoDistToConflictLane(egoDistToConflictLane), egoConflictLane(egoConflictLane) {};
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 
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 
603 
604 
613  const MSLane* findFoeConflictLane(const MSVehicle* foe, const MSLane* egoConflictLane, double& distToConflictLane) const;
614 
617  void closeEncounter(Encounter* e);
618 
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 
713  EncounterVector myActiveEncounters;
717  EncounterQueue myPastConflicts;
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 
bool myUseGeoCoords
Whether to use the original coordinate system for output.
Definition: MSDevice_SSM.h:703
static void determineConflictPoint(EncounterApproachInfo &eInfo)
Calculates the (x,y)-coordinate for the eventually predicted conflict point and stores the result in ...
std::vector< double > myBRspan
All values for brake rate.
Definition: MSDevice_SSM.h:726
std::pair< const MSLane *, double > egoConflictEntryCrossSection
Definition: MSDevice_SSM.h:321
ENCOUNTER_TYPE_MERGING_ADJACENT.
Definition: MSDevice_SSM.h:88
const std::string egoID
Definition: MSDevice_SSM.h:241
static void getVehiclesOnJunction(const MSJunction *, double egoDistToConflictLane, const MSLane *const egoConflictLane, FoeInfoMap &foeCollector)
Collects all vehicles on the junction into foeCollector.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
void createEncounters(FoeInfoMap &foes)
Makes new encounters for all given vehicles (these should be the ones entering the device&#39;s range in ...
ConflictPointInfo minTTC
Definition: MSDevice_SSM.h:283
bool operator()(Encounter *e1, Encounter *e2)
Definition: MSDevice_SSM.h:227
A simple description of a position on a lane (crossing of a lane)
ConflictPointInfo maxDRAC
Definition: MSDevice_SSM.h:284
static void cleanup()
Clean up remaining devices instances.
EncounterType
Different types of encounters corresponding to relative positions of the vehicles. The name describes the type from the ego perspective.
Definition: MSDevice_SSM.h:66
PositionVector conflictPointSpan
Predicted location of the conflict: In case of MERGING and CROSSING: entry point to conflict area for...
Definition: MSDevice_SSM.h:270
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...
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_SSM-options.
MSVehicle * myHolderMS
Definition: MSDevice_SSM.h:706
double egoConflictEntryTime
Times when the ego vehicle entered/left the conflict area. Currently only applies for crossing situat...
Definition: MSDevice_SSM.h:250
void determinePET(EncounterApproachInfo &eInfo) const
Discriminates between different encounter types and correspondingly determines the PET for those case...
ConflictPointInfo(double time, Position x, EncounterType type, double ssmValue)
Definition: MSDevice_SSM.h:198
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
Definition: MSDevice_SSM.h:57
bool updateEncounter(Encounter *e, FoeInfo *foeInfo)
Updates the encounter (adds a new trajectory point).
void determineTTCandDRAC(EncounterApproachInfo &eInfo) const
Discriminates between different encounter types and correspondingly determines TTC and DRAC for those...
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
The base class for an intersection.
Definition: MSJunction.h:61
const MSVehicle * foe
Definition: MSDevice_SSM.h:240
EncounterVector myActiveEncounters
Definition: MSDevice_SSM.h:713
Notification
Definition of a vehicle state.
ENCOUNTER_TYPE_FOLLOWING_PASSED.
Definition: MSDevice_SSM.h:112
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...
EncounterType classifyEncounter(const FoeInfo *foeInfo, EncounterApproachInfo &eInfo) const
Classifies the current type of the encounter provided some information on the opponents.
std::vector< double > myGlobalMeasuresTimeSpan
Definition: MSDevice_SSM.h:724
void closeEncounter(Encounter *e)
Finalizes the encounter and calculates SSM values.
static double getDetectionRange(const SUMOVehicle &v)
ENCOUNTER_TYPE_COLLISION.
Definition: MSDevice_SSM.h:118
static void toGeo(Position &x)
convert SUMO-positions to geo coordinates (in place)
std::vector< double > TTCspan
All values for TTC.
Definition: MSDevice_SSM.h:273
ENCOUNTER_TYPE_EGO_ENTERED_CONFLICT_AREA.
Definition: MSDevice_SSM.h:99
Position pos
Predicted location of the conflict: In case of MERGING and CROSSING: entry point to conflict area for...
Definition: MSDevice_SSM.h:192
ENCOUNTER_TYPE_CROSSING.
Definition: MSDevice_SSM.h:91
const std::string foeID
Definition: MSDevice_SSM.h:242
double time
time point of the conflict
Definition: MSDevice_SSM.h:188
void generateOutput() const
Finalizes output. Called on vehicle removal.
void resetExtraTime(double value)
resets remainingExtraTime to the given value
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.
ENCOUNTER_TYPE_CROSSING_FOLLOWER.
Definition: MSDevice_SSM.h:97
ENCOUNTER_TYPE_BOTH_ENTERED_CONFLICT_AREA.
Definition: MSDevice_SSM.h:107
std::pair< const MSLane *, double > foeConflictEntryCrossSection
Definition: MSDevice_SSM.h:322
std::vector< double > mySGAPspan
All values for space gap.
Definition: MSDevice_SSM.h:728
static bool requestsTrajectories(const SUMOVehicle &v)
Encounter(const MSVehicle *_ego, const MSVehicle *const _foe, double _begin, double extraTime)
Constructor.
ENCOUNTER_TYPE_CROSSING_LEADER.
Definition: MSDevice_SSM.h:94
EncounterType currentType
Definition: MSDevice_SSM.h:244
std::vector< double > DRACspan
All values for DRAC.
Definition: MSDevice_SSM.h:275
ENCOUNTER_TYPE_FOLLOWING_LEADER.
Definition: MSDevice_SSM.h:75
bool myComputeSGAP
Definition: MSDevice_SSM.h:705
A road/street connecting two junctions.
Definition: MSEdge.h:76
ENCOUNTER_TYPE_MERGING_FOLLOWER.
Definition: MSDevice_SSM.h:86
ENCOUNTER_TYPE_MERGING.
Definition: MSDevice_SSM.h:80
std::size_t size() const
Returns the number of trajectory points stored.
Definition: MSDevice_SSM.h:213
static bool getMeasuresAndThresholds(const SUMOVehicle &v, std::string deviceID, std::map< std::string, double > &thresholds)
ENCOUNTER_TYPE_BOTH_LEFT_CONFLICT_AREA.
Definition: MSDevice_SSM.h:109
std::vector< double > myTGAPspan
All values for time gap.
Definition: MSDevice_SSM.h:730
Representation of a vehicle.
Definition: SUMOVehicle.h:61
static std::string toString(EncounterType type)
Definition: MSDevice_SSM.h:121
static double computeDRAC(double gap, double followerSpeed, double leaderSpeed)
Computes the DRAC (deceleration to avoid a collision) for a lead/follow situation as defined...
static const std::set< MSDevice_SSM *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing SSM devices
UpstreamScanStartInfo(const MSEdge *edge, double pos, double range, double egoDistToConflictLane, const MSLane *egoConflictLane)
Definition: MSDevice_SSM.h:345
void processEncounters(FoeInfoMap &foes, bool forceClose=false)
Finds encounters for which the foe vehicle has disappeared from range. remainingExtraTime is decrease...
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A trajectory encloses a series of positions x and speeds v for one vehicle (the times are stored only...
Definition: MSDevice_SSM.h:178
bool myComputeTTC
Flags for switching on / off comutation of different SSMs, derived from myMeasures.
Definition: MSDevice_SSM.h:705
A list of positions.
OutputDevice * myOutputFile
Output device.
Definition: MSDevice_SSM.h:740
ENCOUNTER_TYPE_FOE_LEFT_CONFLICT_AREA.
Definition: MSDevice_SSM.h:105
void resetEncounters()
Closes all current Encounters and moves conflicts to myPastConflicts,.
double getRemainingExtraTime() const
returns the remaining extra time
double myRange
Detection range. For vehicles closer than this distance from the ego vehicle, SSMs are traced...
Definition: MSDevice_SSM.h:699
std::vector< double > egoDistsToConflict
Evolution of the ego vehicle&#39;s distance to the conflict point.
Definition: MSDevice_SSM.h:263
static std::set< MSDevice_SSM *, ComparatorNumericalIdLess > * myInstances
All currently existing SSM devices.
Definition: MSDevice_SSM.h:61
static int issuedParameterWarnFlags
bitset storing info whether warning has already been issued about unset parameter (warn only once!) ...
Definition: MSDevice_SSM.h:747
ENCOUNTER_TYPE_FOLLOWING_FOLLOWER.
Definition: MSDevice_SSM.h:73
ENCOUNTER_TYPE_NOCONFLICT_AHEAD.
Definition: MSDevice_SSM.h:68
void computeSSMs(EncounterApproachInfo &e) const
Compute current values of the logged SSMs (myMeasures) for the given encounter &#39;e&#39; and update &#39;e&#39; acc...
bool qualifiesAsConflict(Encounter *e)
Tests if the SSM values exceed the threshold for qualification as conflict.
static void checkConflictEntryAndExit(EncounterApproachInfo &eInfo)
Checks whether ego or foe have entered or left the conflict area in the last step and eventually writ...
ENCOUNTER_TYPE_MERGING_LEADER.
Definition: MSDevice_SSM.h:83
std::pair< std::pair< std::pair< double, Position >, double >, std::string > myMinTGAP
Definition: MSDevice_SSM.h:735
ENCOUNTER_TYPE_FOE_ENTERED_CONFLICT_AREA.
Definition: MSDevice_SSM.h:101
void updateAndWriteOutput()
This is called once per time step in MSNet::writeOutput() and collects the surrounding vehicles...
ConflictPointInfo PET
Definition: MSDevice_SSM.h:285
void flushGlobalMeasures()
Write out all non-encounter specific measures as headways and braking rates.
const MSLane * findFoeConflictLane(const MSVehicle *foe, const MSLane *egoConflictLane, double &distToConflictLane) const
Computes the conflict lane for the foe.
EncounterType type
Type of the conflict.
Definition: MSDevice_SSM.h:194
double myOldestActiveEncounterBegin
begin time of the oldest active encounter
Definition: MSDevice_SSM.h:715
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder leaves a lane.
void storeEncountersExceedingMaxLength()
Closes encounters, whose duration exceeds the maximal encounter length. If it is classified as confli...
ENCOUNTER_TYPE_FOLLOWING.
Definition: MSDevice_SSM.h:71
bool mySaveTrajectories
This determines whether the whole trajectories of the vehicles (position, speed, ssms) shall be saved...
Definition: MSDevice_SSM.h:697
static std::string getOutputFilename(const SUMOVehicle &v, std::string deviceID)
const MSVehicle * ego
Definition: MSDevice_SSM.h:239
static double getExtraTime(const SUMOVehicle &v)
void flushConflicts(bool all=false)
Writes out all past conflicts that have begun earlier than the oldest active encounter.
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")
Compares encounters regarding to their start time.
Definition: MSDevice_SSM.h:225
std::vector< double > foeDistsToConflict
Evolution of the foe vehicle&#39;s distance to the conflict point.
Definition: MSDevice_SSM.h:265
bool closingRequested
this flag is set by updateEncounter() or directly in processEncounters(), where encounters are closed...
Definition: MSDevice_SSM.h:289
bool myComputeDRAC
Definition: MSDevice_SSM.h:705
ENCOUNTER_TYPE_FOLLOWING_PASSED.
Definition: MSDevice_SSM.h:114
std::vector< Encounter * > EncounterVector
Definition: MSDevice_SSM.h:355
static bool useGeoCoords(const SUMOVehicle &v)
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void countDownExtraTime(double amount)
decreases myRemaingExtraTime by given amount in seconds
bool myComputeTGAP
Definition: MSDevice_SSM.h:705
Representation of a vehicle or person.
double foeConflictEntryTime
Times when the foe vehicle entered/left the conflict area. Currently only applies for crossing situat...
Definition: MSDevice_SSM.h:252
std::map< const MSVehicle *, FoeInfo * > FoeInfoMap
Definition: MSDevice_SSM.h:356
Trajectory egoTrajectory
Trajectory of the ego vehicle.
Definition: MSDevice_SSM.h:259
~MSDevice_SSM()
Destructor.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder enteres a lane.
void computeGlobalMeasures()
Stores measures, that are not associated to a specific encounter as headways and brake rates...
Structure to collect some info on the encounter needed during ssm calculation by various functions...
Definition: MSDevice_SSM.h:301
std::vector< double > timeSpan
time points corresponding to the trajectories
Definition: MSDevice_SSM.h:255
A storage for options typed value containers)
Definition: OptionsCont.h:90
ENCOUNTER_TYPE_EGO_LEFT_CONFLICT_AREA.
Definition: MSDevice_SSM.h:103
Abstract in-vehicle device.
std::pair< double, double > pet
Definition: MSDevice_SSM.h:320
std::map< std::string, double > myThresholds
Definition: MSDevice_SSM.h:694
ConflictPointInfo stores some information on a specific conflict point (used to store information on ...
Definition: MSDevice_SSM.h:186
Encounter & operator=(const Encounter &)
Invalidated assignment operator.
std::pair< std::pair< std::pair< double, Position >, double >, std::string > myMinSGAP
Definition: MSDevice_SSM.h:734
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
An encounter is an episode involving two vehicles, which are closer to each other than some specified...
Definition: MSDevice_SSM.h:174
Auxiliary structure used to handle upstream scanning start points Upstream scan has to be started aft...
Definition: MSDevice_SSM.h:344
double myExtraTime
Extra time in seconds to be logged after a conflict is over.
Definition: MSDevice_SSM.h:701
std::vector< int > typeSpan
Evolution of the encounter classification (.
Definition: MSDevice_SSM.h:257
double remainingExtraTime
Remaining extra time (decreases after an encounter ended)
Definition: MSDevice_SSM.h:247
ENCOUNTER_TYPE_ON_ADJACENT_LANES.
Definition: MSDevice_SSM.h:77
static void estimateConflictTimes(EncounterApproachInfo &eInfo)
Estimates the time until conflict for the vehicles based on the distance to the conflict entry points...
void writeOutConflict(Encounter *e)
static std::set< std::string > createdOutputFiles
remember which files were created already (don&#39;t duplicate xml root-elements)
Definition: MSDevice_SSM.h:743
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
EncounterQueue myPastConflicts
Past encounters that where qualified as conflicts and are not yet flushed to the output file...
Definition: MSDevice_SSM.h:717
double value
value of the corresponding SSM
Definition: MSDevice_SSM.h:196
static void getUpstreamVehicles(const UpstreamScanStartInfo &scanStart, FoeInfoMap &foeCollector, std::set< const MSJunction *> &seenJunctions)
Collects all vehicles within range &#39;range&#39; upstream of the position &#39;pos&#39; on the edge &#39;edge&#39; into foe...
Trajectory foeTrajectory
Trajectory of the foe vehicle.
Definition: MSDevice_SSM.h:261
static void findSurroundingVehicles(const MSVehicle &veh, double range, FoeInfoMap &foeCollector)
Returns all vehicles, which are within the given range of the given vehicle.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice *> &into)
Build devices for the given vehicle, if needed.
std::priority_queue< Encounter *, std::vector< Encounter * >, Encounter::compare > EncounterQueue
Definition: MSDevice_SSM.h:354
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
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_SSM.h:473