21 #ifndef MSDevice_SSM_h 22 #define MSDevice_SSM_h 159 std::pair<double, double>
PET;
248 static void getUpstreamVehicles(
const MSEdge* edge,
double pos,
double range,
double egoDistToConflictLane,
const MSLane*
const egoConflictLane, FoeInfoMap& foeCollector);
268 double newPos,
double newSpeed);
322 MSDevice_SSM(
SUMOVehicle& holder,
const std::string&
id, std::string outputFilename, std::vector<std::string> measures, std::vector<double> thresholds,
323 bool trajectories,
double frequency,
double range);
383 std::vector<double>& thresholds, std::vector<std::string>& measures);
void processEncounters(FoeInfoMap &foes)
Finds encounters for which the foe vehicle has disappeared from range and if an ended encounter is qu...
std::vector< double > timespan
time points corresponding to the trajectories
static const std::set< MSDevice * > & getInstances()
returns all currently existing SSM devices
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.
static bool getMeasuresAndThresholds(const SUMOVehicle &v, std::string deviceID, std::vector< double > &thresholds, std::vector< std::string > &measures)
void createEncounters(FoeInfoMap &foes)
Makes new encounters for all given vehicles (these should be the ones entering the device's range in ...
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder leaves a lane.
bool operator()(Encounter *e1, Encounter *e2)
A simple description of a position on a lane (crossing of a lane)
std::pair< double, double > maxDRAC
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.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_SSM-options.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
The base class for an intersection.
EncounterVector myActiveEncounters
const MSLane * findFoeConflictLane(const MSVehicle *foe, const MSLane *egoConflictLane, double &distToConflictLane)
Computes the conflict lane for the foe.
static double getLoggingFrequency(const SUMOVehicle &v)
Notification
Definition of a vehicle state.
void closeEncounter(Encounter *e)
Finalizes the encounter and calculates SSM values.
static double getDetectionRange(const SUMOVehicle &v)
std::vector< double > TTCspan
All values for TTC.
void updateEncounter(Encounter *e, FoeInfo *foeInfo)
Updates the encounter (adds a new trajectory point) and deletes the foeInfo.
void generateOutput() const
Finalizes output. Called on vehicle removal.
ENCOUNTER_TYPE_CROSSING_FOLLOWER.
static bool requestsTrajectories(const SUMOVehicle &v)
double egoDistToConflictLane
ENCOUNTER_TYPE_CROSSING_LEADER.
std::vector< double > DRACspan
All values for DRAC.
ENCOUNTER_TYPE_FOLLOWING_LEADER.
A road/street connecting two junctions.
int maxTrajectorySize
Corresponding maximal trajectory size in points, derived from myFrequency.
void add(double time, Position egoX, Position egoV, Position foeX, Position foeV)
add a new data point
ENCOUNTER_TYPE_MERGING_FOLLOWER.
Encounter(const MSVehicle *_ego, const MSVehicle *const _foe, double _begin)
Constructor.
void computeSSMs(Encounter *e)
double myFrequency
Maximal timespan duration for a single encounter.
static void getUpstreamVehicles(const MSEdge *edge, double pos, double range, double egoDistToConflictLane, const MSLane *const egoConflictLane, FoeInfoMap &foeCollector)
Collects all vehicles within range 'range' upstream of the position 'pos' on the edge 'edge' into foe...
Representation of a vehicle.
A point in 2D or 3D with translation and scaling methods.
A trajectory encloses a series of positions x and speeds v for one vehicle (the times are stored only...
bool myComputeTTC
Flags for switching on / off comutation of different SSMs, derived from myMeasures.
OutputDevice * myOutputFile
Output device.
void resetEncounters()
Closes all current Encounters and moves conflicts to myPastConflicts,.
ENCOUNTER_TYPE_FOLLOWING_FOLLOWER.
MSDevice_SSM(SUMOVehicle &holder, const std::string &id, std::string outputFilename, std::vector< std::string > measures, std::vector< double > thresholds, bool trajectories, double frequency, double range)
Constructor.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder enteres a lane.
bool qualifiesAsConflict(Encounter *e)
Tests if the SSM values exceed the threshold for qualification as conflict.
ENCOUNTER_TYPE_MERGING_LEADER.
void updateAndWriteOutput()
This is called once per time step in MSNet::writeOutput() and collects the surrounding vehicles...
ENCOUNTER_TYPE_FOLLOWING.
static std::string getOutputFilename(const SUMOVehicle &v, std::string deviceID)
std::vector< std::string > myMeasures
void flushConflicts(bool all=false)
Writes out all past conflicts that have begun earlier than time t-myFrequency (i.e. no active encounter can have an earlier begin)
Compares encounters regarding to their start time.
Abstract in-vehicle device.
std::vector< double > myThresholds
std::vector< Encounter * > EncounterVector
std::map< const MSVehicle *, FoeInfo * > FoeInfoMap
const MSLane * egoConflictLane
Trajectory egoTrajectory
Trajectory of the ego vehicle.
static std::set< MSDevice * > * instances
All currently existing SSM devices.
~MSDevice_SSM()
Destructor.
A storage for options typed value containers)
Encounter & operator=(const Encounter &)
Invalidated assignment operator.
ENCOUNTER_TYPE_NOCONFLICT.
Static storage of an output device and its base (abstract) implementation.
An encounter is an episode involving two vehicles, which are closer to each other than some specified...
std::pair< double, double > minTTC
std::pair< double, double > PET
void writeOutConflict(Encounter *e)
bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
Representation of a lane in the micro simulation.
const MSVehicle *const foe
EncounterQueue myPastConflicts
Past encounters that where qualified as conflicts and are not yet flushed to the output file...
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
Trajectory foeTrajectory
Trajectory of the foe vehicle.
static void findSurroundingVehicles(const MSVehicle &veh, double range, FoeInfoMap &foeCollector)
Returns all vehicles, which are within the given range of the given vehicle.
std::priority_queue< Encounter *, std::vector< Encounter * >, Encounter::compare > EncounterQueue
const std::string deviceName() const
return the name for this type of device