 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
19 #ifndef MSDevice_SSM_h
20 #define MSDevice_SSM_h
60 static std::set<MSDevice_SSM*, ComparatorNumericalIdLess>*
myInstances;
123 return (
"NOCONFLICT_AHEAD");
125 return (
"FOLLOWING");
127 return (
"FOLLOWING_FOLLOWER");
129 return (
"FOLLOWING_LEADER");
131 return (
"ON_ADJACENT_LANES");
135 return (
"MERGING_LEADER");
137 return (
"MERGING_FOLLOWER");
139 return (
"MERGING_ADJACENT");
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");
165 return (
"COLLISION");
209 Position conflictPoint,
double egoDistToConflict,
double foeDistToConflict,
double ttc,
double drac, std::pair<double, double> pet);
319 std::pair<double, double>
pet;
379 static const std::set<MSDevice_SSM*, ComparatorNumericalIdLess>&
getInstances();
392 void setParameter(
const std::string& key,
const std::string& value);
449 double newPos,
double newSpeed);
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);
650 double computeTTC(
double gap,
double followerSpeed,
double leaderSpeed)
const;
658 static double computeDRAC(
double gap,
double followerSpeed,
double leaderSpeed);
671 static double computeDRAC(
const EncounterApproachInfo& eInfo);
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 =
" ");
691 std::map<std::string, double>& thresholds);
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;
double foeConflictAreaLength
MSDevice_SSM & operator=(const MSDevice_SSM &)
Invalidated assignment operator.
UpstreamScanStartInfo(const MSEdge *edge, double pos, double range, double egoDistToConflictLane, const MSLane *egoConflictLane)
std::vector< double > TTCspan
All values for TTC.
Representation of a vehicle or person.
void countDownExtraTime(double amount)
decreases myRemaingExtraTime by given amount in seconds
static double getExtraTime(const SUMOVehicle &v)
std::vector< double > myTGAPspan
All values for time gap.
@ ENCOUNTER_TYPE_FOLLOWING_PASSED
ENCOUNTER_TYPE_FOLLOWING_PASSED.
std::vector< double > timeSpan
time points corresponding to the trajectories
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
double egoDistToConflictLane
EncounterType type
Type of the conflict.
Representation of a lane in the micro simulation.
Encounter & operator=(const Encounter &)
Invalidated assignment operator.
A device which collects info on the vehicle trip (mainly on departure and arrival)
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...
Trajectory egoTrajectory
Trajectory of the ego vehicle.
void closeEncounter(Encounter *e)
Finalizes the encounter and calculates SSM values.
The base class for an intersection.
Static storage of an output device and its base (abstract) implementation.
Position pos
Predicted location of the conflict: In case of MERGING and CROSSING: entry point to conflict area for...
const MSLane * egoConflictLane
void computeGlobalMeasures()
Stores measures, that are not associated to a specific encounter as headways and brake rates.
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")
void resetEncounters()
Closes all current Encounters and moves conflicts to myPastConflicts,.
std::vector< double > myGlobalMeasuresTimeSpan
static std::set< std::string > createdOutputFiles
remember which files were created already (don't duplicate xml root-elements)
@ ENCOUNTER_TYPE_BOTH_LEFT_CONFLICT_AREA
ENCOUNTER_TYPE_BOTH_LEFT_CONFLICT_AREA.
void updateAndWriteOutput()
This is called once per time step in MSNet::writeOutput() and collects the surrounding vehicles,...
double myRange
Detection range. For vehicles closer than this distance from the ego vehicle, SSMs are traced.
@ ENCOUNTER_TYPE_COLLISION
ENCOUNTER_TYPE_COLLISION.
std::pair< std::pair< double, Position >, double > myMaxBR
Extremal values for the global measures (as <<<time, Position>, value>, [leaderID]>-pairs)
Representation of a vehicle.
@ ENCOUNTER_TYPE_CROSSING_LEADER
ENCOUNTER_TYPE_CROSSING_LEADER.
static void toGeo(Position &x)
convert SUMO-positions to geo coordinates (in place)
double egoConflictAreaLength
std::map< std::string, double > myThresholds
static void cleanup()
Clean up remaining devices instances.
OutputDevice * myOutputFile
Output device.
A simple description of a position on a lane (crossing of a lane)
static const std::set< MSDevice_SSM *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing SSM devices
static int issuedParameterWarnFlags
bitset storing info whether warning has already been issued about unset parameter (warn only once!...
void flushGlobalMeasures()
Write out all non-encounter specific measures as headways and braking rates.
bool myComputeTTC
Flags for switching on / off comutation of different SSMs, derived from myMeasures.
Auxiliary structure used to handle upstream scanning start points Upstream scan has to be started aft...
void createEncounters(FoeInfoMap &foes)
Makes new encounters for all given vehicles (these should be the ones entering the device's range in ...
void computeSSMs(EncounterApproachInfo &e) const
Compute current values of the logged SSMs (myMeasures) for the given encounter 'e' and update 'e' acc...
@ ENCOUNTER_TYPE_EGO_ENTERED_CONFLICT_AREA
ENCOUNTER_TYPE_EGO_ENTERED_CONFLICT_AREA.
std::vector< int > typeSpan
Evolution of the encounter classification (.
@ ENCOUNTER_TYPE_FOE_ENTERED_CONFLICT_AREA
ENCOUNTER_TYPE_FOE_ENTERED_CONFLICT_AREA.
void writeOutConflict(Encounter *e)
std::pair< std::pair< std::pair< double, Position >, double >, std::string > myMinTGAP
PositionVector conflictPointSpan
Predicted location of the conflict: In case of MERGING and CROSSING: entry point to conflict area for...
std::pair< std::pair< std::pair< double, Position >, double >, std::string > myMinSGAP
double foeConflictEntryTime
Times when the foe vehicle entered/left the conflict area. Currently only applies for crossing situat...
EncounterType classifyEncounter(const FoeInfo *foeInfo, EncounterApproachInfo &eInfo) const
Classifies the current type of the encounter provided some information on the opponents.
double egoConflictExitDist
bool updateEncounter(Encounter *e, FoeInfo *foeInfo)
Updates the encounter (adds a new trajectory point).
~MSDevice_SSM()
Destructor.
static double getDetectionRange(const SUMOVehicle &v)
std::vector< double > foeDistsToConflict
Evolution of the foe vehicle's distance to the conflict point.
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
double foeEstimatedConflictExitTime
EncounterApproachInfo(Encounter *e)
void flushConflicts(bool all=false)
Writes out all past conflicts that have begun earlier than the oldest active encounter.
ConflictPointInfo(double time, Position x, EncounterType type, double ssmValue)
@ ENCOUNTER_TYPE_EGO_LEFT_CONFLICT_AREA
ENCOUNTER_TYPE_EGO_LEFT_CONFLICT_AREA.
EncounterVector myActiveEncounters
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
double egoConflictExitTime
void generateOutput() const
Finalizes output. Called on vehicle removal.
Compares encounters regarding to their start time.
std::vector< Encounter * > EncounterVector
@ ENCOUNTER_TYPE_MERGING
ENCOUNTER_TYPE_MERGING.
double remainingExtraTime
Remaining extra time (decreases after an encounter ended)
bool mySaveTrajectories
This determines whether the whole trajectories of the vehicles (position, speed, ssms) shall be saved...
@ ENCOUNTER_TYPE_BOTH_ENTERED_CONFLICT_AREA
ENCOUNTER_TYPE_BOTH_ENTERED_CONFLICT_AREA.
Structure to collect some info on the encounter needed during ssm calculation by various functions.
const std::string deviceName() const
return the name for this type of device
A point in 2D or 3D with translation and scaling methods.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_SSM-options.
A storage for options typed value containers)
double foeEstimatedConflictEntryTime
@ ENCOUNTER_TYPE_CROSSING_FOLLOWER
ENCOUNTER_TYPE_CROSSING_FOLLOWER.
A road/street connecting two junctions.
@ ENCOUNTER_TYPE_FOLLOWING_FOLLOWER
ENCOUNTER_TYPE_FOLLOWING_FOLLOWER.
const MSLane * egoConflictLane
EncounterType currentType
double foeConflictExitTime
double egoDistToConflictLane
void storeEncountersExceedingMaxLength()
Closes encounters, whose duration exceeds the maximal encounter length. If it is classified as confli...
static std::set< MSDevice_SSM *, ComparatorNumericalIdLess > * myInstances
All currently existing SSM devices.
@ ENCOUNTER_TYPE_MERGING_LEADER
ENCOUNTER_TYPE_MERGING_LEADER.
Encounter(const MSVehicle *_ego, const MSVehicle *const _foe, double _begin, double extraTime)
Constructor.
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...
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_ONCOMING
@ ENCOUNTER_TYPE_FOLLOWING_LEADER
ENCOUNTER_TYPE_FOLLOWING_LEADER.
std::vector< double > myBRspan
All values for brake rate.
std::pair< const MSLane *, double > egoConflictEntryCrossSection
std::size_t size() const
Returns the number of trajectory points stored.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void determinePET(EncounterApproachInfo &eInfo) const
Discriminates between different encounter types and correspondingly determines the PET for those case...
static bool getMeasuresAndThresholds(const SUMOVehicle &v, std::string deviceID, std::map< std::string, double > &thresholds)
std::vector< double > DRACspan
All values for DRAC.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder leaves a lane.
static bool requestsTrajectories(const SUMOVehicle &v)
std::priority_queue< Encounter *, std::vector< Encounter * >, Encounter::compare > EncounterQueue
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...
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.
double myExtraTime
Extra time in seconds to be logged after a conflict is over.
double value
value of the corresponding SSM
double egoEstimatedConflictExitTime
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
static void findSurroundingVehicles(const MSVehicle &veh, double range, FoeInfoMap &foeCollector)
Returns all vehicles, which are within the given range of the given vehicle.
@ ENCOUNTER_TYPE_NOCONFLICT_AHEAD
ENCOUNTER_TYPE_NOCONFLICT_AHEAD.
double time
time point of the conflict
@ ENCOUNTER_TYPE_CROSSING
ENCOUNTER_TYPE_CROSSING.
std::vector< double > egoDistsToConflict
Evolution of the ego vehicle's distance to the conflict point.
static std::string getOutputFilename(const SUMOVehicle &v, std::string deviceID)
An encounter is an episode involving two vehicles, which are closer to each other than some specified...
double egoEstimatedConflictEntryTime
static bool useGeoCoords(const SUMOVehicle &v)
double getRemainingExtraTime() const
returns the remaining extra time
std::pair< double, double > pet
double foeConflictExitDist
ConflictPointInfo stores some information on a specific conflict point (used to store information on ...
double myOldestActiveEncounterBegin
begin time of the oldest active encounter
@ ENCOUNTER_TYPE_MERGING_PASSED
ENCOUNTER_TYPE_FOLLOWING_PASSED.
EncounterQueue myPastConflicts
Past encounters that where qualified as conflicts and are not yet flushed to the output file.
std::vector< double > mySGAPspan
All values for space gap.
Trajectory foeTrajectory
Trajectory of the foe vehicle.
@ ENCOUNTER_TYPE_ON_ADJACENT_LANES
ENCOUNTER_TYPE_ON_ADJACENT_LANES.
const MSLane * findFoeConflictLane(const MSVehicle *foe, const MSLane *egoConflictLane, double &distToConflictLane) const
Computes the conflict lane for the foe.
std::map< const MSVehicle *, FoeInfo * > FoeInfoMap
@ ENCOUNTER_TYPE_MERGING_FOLLOWER
ENCOUNTER_TYPE_MERGING_FOLLOWER.
static double computeDRAC(double gap, double followerSpeed, double leaderSpeed)
Computes the DRAC (deceleration to avoid a collision) for a lead/follow situation as defined,...
@ ENCOUNTER_TYPE_FOLLOWING
ENCOUNTER_TYPE_FOLLOWING.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder enteres a lane.
double egoConflictEntryDist
double egoConflictEntryTime
Times when the ego vehicle entered/left the conflict area. Currently only applies for crossing situat...
double foeConflictEntryDist
ConflictPointInfo maxDRAC
void resetExtraTime(double value)
resets remainingExtraTime to the given value
static void estimateConflictTimes(EncounterApproachInfo &eInfo)
Estimates the time until conflict for the vehicles based on the distance to the conflict entry points...
void determineTTCandDRAC(EncounterApproachInfo &eInfo) const
Discriminates between different encounter types and correspondingly determines TTC and DRAC for those...
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.
Notification
Definition of a vehicle state.
bool myUseGeoCoords
Whether to use the original coordinate system for output.
@ ENCOUNTER_TYPE_FOE_LEFT_CONFLICT_AREA
ENCOUNTER_TYPE_FOE_LEFT_CONFLICT_AREA.
bool closingRequested
this flag is set by updateEncounter() or directly in processEncounters(), where encounters are closed...
std::pair< const MSLane *, double > foeConflictEntryCrossSection
static std::string encounterToString(EncounterType type)
static void determineConflictPoint(EncounterApproachInfo &eInfo)
Calculates the (x,y)-coordinate for the eventually predicted conflict point and stores the result in ...
A trajectory encloses a series of positions x and speeds v for one vehicle (the times are stored only...
void processEncounters(FoeInfoMap &foes, bool forceClose=false)
Finds encounters for which the foe vehicle has disappeared from range. remainingExtraTime is decrease...
EncounterType
Different types of encounters corresponding to relative positions of the vehicles....
@ ENCOUNTER_TYPE_MERGING_ADJACENT
ENCOUNTER_TYPE_MERGING_ADJACENT.
bool operator()(Encounter *e1, Encounter *e2)
Representation of a vehicle in the micro simulation.
Abstract in-vehicle device.