62 #define INVALID std::numeric_limits<double>::max() 65 #define DEFAULT_RANGE 50.0 71 #define AVAILABLE_SSMS "TTC DRAC PET" 72 #define DEFAULT_THRESHOLD_TTC 3. // in [s.], events get logged if below threshold 73 #define DEFAULT_THRESHOLD_DRAC 4. // in [m/s^2], events get logged if above threshold 74 #define DEFAULT_THRESHOLD_PET 2. // in seconds, events get logged if below threshold 75 #define DEFAULT_EXTRA_TIME 5. // in seconds, events get logged for extra time even if encounter is over 87 out <<
"NOCONFLICT_AHEAD";
93 out <<
"FOLLOWING_FOLLOWER";
96 out <<
"FOLLOWING_LEADER";
99 out <<
"ON_ADJACENT_LANES";
105 out <<
"MERGING_LEADER";
108 out <<
"MERGING_FOLLOWER";
111 out <<
"MERGING_ADJACENT";
117 out <<
"CROSSING_LEADER";
120 out <<
"CROSSING_FOLLOWER";
123 out <<
"EGO_ENTERED_CONFLICT_AREA";
126 out <<
"FOE_ENTERED_CONFLICT_AREA";
129 out <<
"BOTH_ENTERED_CONFLICT_AREA";
132 out <<
"EGO_LEFT_CONFLICT_AREA";
135 out <<
"FOE_LEFT_CONFLICT_AREA";
138 out <<
"BOTH_LEFT_CONFLICT_AREA";
141 out <<
"FOLLOWING_PASSED";
144 out <<
"MERGING_PASSED";
151 out <<
"unknown type (" << int(type) <<
")";
164 const std::set<MSDevice*>&
173 for (std::set<MSDevice*>::iterator ii =
instances->begin(); ii !=
instances->end(); ++ii) {
188 oc.
addDescription(
"device.ssm.measures",
"SSM Device",
"Specifies which measures will be logged (as a space seperated sequence of IDs in ('TTC', 'DRAC', 'PET')).");
190 oc.
addDescription(
"device.ssm.thresholds",
"SSM Device",
"Specifies thresholds corresponding to the specified measures (see documentation and watch the order!). Only events exceeding the thresholds will be logged.");
192 oc.
addDescription(
"device.ssm.trajectories",
"SSM Device",
"Specifies whether trajectories will be logged (if false, only the extremal values and times are reported, this is the default).");
194 oc.
addDescription(
"device.ssm.range",
"SSM Device",
"Specifies the detection range in meters (default is " +
toString(
DEFAULT_RANGE) +
"m.). For vehicles below this distance from the equipped vehicle, SSM values are traced.");
196 oc.
addDescription(
"device.ssm.extratime",
"SSM Device",
"Specifies the time in seconds to be logged after a conflict is over (default is " +
toString(
DEFAULT_EXTRA_TIME) +
"secs.). Required >0 if PET is to be calculated for crossing conflicts.");
198 oc.
addDescription(
"device.ssm.geo",
"SSM Device",
"Whether to use coordinates of the original reference system in output (default is false).");
205 WRITE_WARNING(
"SSM Device for vehicle '" + v.
getID() +
"' will not be built. (SSMs not supported in MESO)");
209 std::string deviceID =
"ssm_" + v.
getID();
214 std::map<std::string, double> thresholds;
237 into.push_back(device);
246 egoID(_ego->
getID()),
247 foeID(_foe->
getID()),
250 remainingExtraTime(extraTime),
258 closingRequested(false) {
260 std::cout <<
"\n" <<
SIMTIME <<
" Constructing encounter of '" 267 std::cout <<
"\n" <<
SIMTIME <<
" Destroying encounter of '" 268 <<
egoID <<
"' and '" <<
foeID <<
"' (begin was " <<
begin <<
")" << std::endl;
275 Position conflictPoint,
double egoDistToConflict,
double foeDistToConflict,
double ttc,
double drac, std::pair<double, double> pet) {
277 std::cout << time <<
" Adding data point for encounter of '" <<
egoID <<
"' and '" <<
foeID <<
"':\n" 278 <<
"type=" << type <<
", egoDistToConflict=" << (egoDistToConflict ==
INVALID ?
"NA" :
toString(egoDistToConflict))
279 <<
", foeDistToConflict=" << (foeDistToConflict ==
INVALID ?
"NA" :
toString(foeDistToConflict))
299 minTTC = std::make_pair(std::make_pair(time, ttc), conflictPoint);
304 maxDRAC = std::make_pair(std::make_pair(time, drac), conflictPoint);
308 PET = std::make_pair(pet, conflictPoint);
334 conflictPoint(
Position::invalidPosition()),
339 egoEstimatedConflictEntryTime(
INVALID),
340 foeEstimatedConflictEntryTime(
INVALID),
341 egoEstimatedConflictExitTime(
INVALID),
342 foeEstimatedConflictExitTime(
INVALID),
343 egoConflictAreaLength(
INVALID),
344 foeConflictAreaLength(
INVALID),
345 egoLeftConflict(false),
346 foeLeftConflict(false),
369 std::cout <<
"\n" <<
SIMTIME <<
" Device '" <<
getID() <<
"' update()\n" 379 if (foes.size() > 0) {
380 std::cout <<
"Scanned surroundings: Found potential foes:\n";
381 for (FoeInfoMap::const_iterator i = foes.begin(); i != foes.end(); ++i) {
382 std::cout << i->first->getID() <<
" ";
384 std::cout << std::endl;
386 std::cout <<
"Scanned surroundings: No potential conflict could be identified." << std::endl;
402 std::cout <<
"\n" <<
SIMTIME <<
" Device '" <<
getID() <<
"' createEncounters()" << std::endl;
403 std::cout <<
"New foes:\n";
404 for (FoeInfoMap::const_iterator vi = foes.begin(); vi != foes.end(); ++vi) {
405 std::cout << vi->first->getID() <<
"\n";
407 std::cout << std::endl;
410 for (FoeInfoMap::const_iterator foe = foes.begin(); foe != foes.end(); ++foe) {
411 std::pair<MSLane*, MSLane*> conflictLanes;
418 assert(myOldestActiveEncounterBegin <= e->begin);
434 std::cout <<
"\n" <<
SIMTIME <<
" Device '" <<
getID() <<
"' processEncounters()" << std::endl;
435 std::cout <<
"Currently present foes:\n";
436 for (FoeInfoMap::const_iterator vi = foes.begin(); vi != foes.end(); ++vi) {
437 std::cout << vi->first->getID() <<
"\n";
439 std::cout << std::endl;
455 if (foes.find(e->
foe) != foes.end()) {
471 double eBegin = e->
begin;
495 std::cout <<
SIMTIME <<
" qualifiesAsConflict() for encounter of vehicles '" 526 std::cout <<
SIMTIME <<
" closeEncounter() of vehicles '" 528 <<
"' (was ranked as " << (wasConflict ?
"conflict" :
"non-conflict") <<
")" << std::endl;
538 std::cout <<
SIMTIME <<
" updateEncounter() of vehicles '" 558 std::cout <<
SIMTIME <<
" Encounter of vehicles '" 560 <<
"' does not imply any conflict." << std::endl;
613 std::cout <<
SIMTIME <<
" determineConflictPoint()" << std::endl;
638 std::cout <<
"No conflict point associated with encounter type " << type << std::endl;
644 std::cout <<
" Conflict at " << eInfo.
conflictPoint << std::endl;
657 std::cout <<
SIMTIME <<
" estimateConflictTimes() for ego '" << e->
egoID <<
"' and foe '" << e->
foeID <<
"'\n" 658 <<
" encounter type: " << eInfo.
type <<
"\n" 671 std::cout <<
" encouter type " << type <<
" -> no entry/exit times to be calculated." 712 std::cout <<
" Potential conflict type: " << (type ==
ENCOUNTER_TYPE_CROSSING ?
"CROSSING" :
"MERGING") <<
"\n" 742 std::stringstream ss;
743 ss <<
"SSM device of vehicle '" << e->
egoID <<
"' detected collision with vehicle '" << e->
foeID <<
"'";
748 std::cout <<
" -> ego is estimated leader at conflict entry." 756 std::cout <<
" -> foe is estimated leader at conflict entry." 771 std::cout <<
SIMTIME <<
" computeSSMs() for vehicles '" 799 std::stringstream ss;
800 ss <<
"'" << type <<
"'";
801 WRITE_WARNING(
"Unknown or undetermined encounter type at computeSSMs(): " + ss.str());
805 std::cout <<
"computeSSMs() for encounter of vehicles '" << e->
egoID <<
"' and '" << e->
foeID <<
"':\n" 817 if (e->
size() == 0) {
821 std::pair<double, double>&
pet = eInfo.
pet;
824 std::cout <<
SIMTIME <<
" determinePET() for encounter of vehicles '" << e->
egoID <<
"' and '" << e->
foeID <<
"'" 841 std::cout <<
"PET for crossing encounter already calculated as " << e->
PET.second
885 std::cout <<
"Unexpected branch in determinePET: Both passed conflict area in the same step." 901 std::cout <<
"Calculated PET = " << pet.second <<
" (at t=" << pet.first <<
")" 907 std::cout <<
"PET unappropriate for merging and pre-crossing situations. No calculation performed." 925 std::cout <<
SIMTIME <<
" determineTTCandDRAC() for encounter of vehicles '" << e->
egoID <<
"' and '" << e->
foeID <<
"' (type = " << eInfo.
type <<
")" 952 std::cout <<
" Conflict times with constant speed extrapolation for merging situation:\n " 953 <<
" egoEntryTime=" << (egoEntryTime ==
INVALID ?
"NA" :
toString(egoEntryTime))
954 <<
", egoExitTime=" << (egoExitTime ==
INVALID ?
"NA" :
toString(egoExitTime))
955 <<
", foeEntryTime=" << (foeEntryTime ==
INVALID ?
"NA" :
toString(foeEntryTime))
956 <<
", foeExitTime=" << (foeExitTime ==
INVALID ?
"NA" :
toString(foeExitTime))
966 std::cout <<
" No TTC and DRAC computed as one vehicle is stopped." << std::endl;
969 double leaderEntryTime =
MIN2(egoEntryTime, foeEntryTime);
970 double followerEntryTime =
MAX2(egoEntryTime, foeEntryTime);
971 double leaderExitTime = leaderEntryTime == egoEntryTime ? egoExitTime : foeExitTime;
978 if (leaderExitTime >= followerEntryTime) {
980 ttc =
computeTTC(followerConflictDist, followerSpeed, 0.);
982 drac =
computeDRAC(followerConflictDist, followerSpeed, 0.);
985 std::cout <<
" Extrapolation predicts collision *at* merge point with TTC=" << ttc
986 <<
", drac=" << drac << std::endl;
992 double gapAfterMerge = followerConflictDist - leaderExitTime * followerSpeed;
993 assert(gapAfterMerge >= 0);
996 double ttcAfterMerge =
computeTTC(gapAfterMerge, followerSpeed, leaderSpeed);
997 ttc = ttcAfterMerge ==
INVALID ?
INVALID : leaderExitTime + ttcAfterMerge;
1000 double g0 = followerConflictDist - leaderConflictDist - leaderLength;
1002 double dv = leaderSpeed - followerSpeed;
1009 drac =
computeDRAC(g0, followerSpeed, leaderSpeed);
1016 std::cout <<
" Extrapolation does not predict any collision." << std::endl;
1018 std::cout <<
" Extrapolation predicts collision *after* merge point with TTC=" 1020 <<
", drac=" << (drac ==
INVALID ?
"NA" :
toString(drac)) << std::endl;
1052 std::stringstream ss;
1053 ss <<
"'" << type <<
"'";
1054 WRITE_WARNING(
"Underspecified or unknown encounter type in MSDevice_SSM::determineTTCandDRAC(): " + ss.str());
1071 std::cout <<
"computeTTC() with gap=" << gap <<
", followerSpeed=" << followerSpeed <<
", leaderSpeed=" << leaderSpeed
1077 double dv = followerSpeed - leaderSpeed;
1089 std::cout <<
"computeDRAC() with gap=" << gap <<
", followerSpeed=" << followerSpeed <<
", leaderSpeed=" << leaderSpeed
1095 double dv = followerSpeed - leaderSpeed;
1099 assert(followerSpeed > 0.);
1100 double timeHeadway = gap / followerSpeed;
1101 return dv / timeHeadway;
1107 std::cout <<
"computeDRAC() with d1=" << d1 <<
", d2=" << d2 <<
", v1=" << v1 <<
", v2=" << v2
1111 if (d1 <= 0. && d2 <= 0.) {
1117 drac =
MIN2(2 * (v1 - d1 / t2) / t2, 2 * (v2 - d2 / t1) / t1);
1118 }
else if (d1 > 0. && t2 !=
INVALID) {
1119 drac = 2 * (v1 - d1 / t2) / t2;
1120 }
else if (d2 > 0. && t1 !=
INVALID) {
1121 drac = 2 * (v2 - d2 / t1) / t1;
1130 return drac > 0 ? drac :
INVALID;
1139 std::cout <<
SIMTIME <<
" checkConflictEntryAndExit() for encounter of vehicles '" << e->
egoID <<
"' and '" << e->
foeID <<
"'" << std::endl;
1152 prevEgoConflictEntryDist =
MAX2(prevEgoConflictEntryDist, 0.);
1153 prevFoeConflictEntryDist =
MAX2(prevFoeConflictEntryDist, 0.);
1154 prevEgoConflictExitDist =
MAX2(prevEgoConflictExitDist, 0.);
1155 prevFoeConflictExitDist =
MAX2(prevFoeConflictExitDist, 0.);
1225 std::cout <<
SIMTIME <<
" updatePassedEncounter() for vehicles '" 1234 std::cout <<
" Foe is out of range. Counting down extra time." 1251 std::cout <<
" This encounter wasn't classified as a potential conflict lately." << std::endl;
1259 std::cout <<
" Closing encounter." << std::endl;
1269 std::cout <<
" Encounter was previously classified as a follow/lead situation." << std::endl;
1278 std::cout <<
" Encounter was previously classified as a merging situation." << std::endl;
1293 std::cout <<
" Encounter was previously classified as a crossing situation of type " << lastPotentialConflictType <<
"." << std::endl;
1324 if ((!egoEnteredConflict) && !foeEnteredConflict) {
1328 eInfo.
type = lastPotentialConflictType;
1329 }
else if (egoEnteredConflict && !foeEnteredConflict) {
1331 }
else if ((!egoEnteredConflict) && foeEnteredConflict) {
1337 if ((!egoLeftConflict) && !foeLeftConflict) {
1341 }
else if (egoLeftConflict && !foeLeftConflict) {
1345 }
else if ((!egoLeftConflict) && foeLeftConflict) {
1361 std::cout <<
" Updated classification: " << eInfo.
type << std::endl;
1370 std::cout <<
"classifyEncounter() called." << std::endl;
1392 std::cout <<
" Ongoing crossing conflict will be traced by passedEncounter()." << std::endl;
1407 double foeDistToConflictLane;
1411 std::cout <<
"egoConflictLane: '" << (egoConflictLane == 0 ?
"NULL" : egoConflictLane->
getID()) <<
"'\n" 1412 <<
"foeConflictLane: '" << (foeConflictLane == 0 ?
"NULL" : foeConflictLane->
getID()) <<
"'" 1413 <<
"\nEgo's distance to conflict lane: " << egoDistToConflictLane
1414 <<
"\nFoe's distance to conflict lane: " << foeDistToConflictLane
1429 if (foeConflictLane == 0) {
1433 std::cout <<
"-> Encounter type: No conflict." << std::endl;
1435 }
else if (!egoConflictLane->isInternal()) {
1437 if (egoConflictLane == egoLane) {
1439 if (foeLane == egoLane) {
1449 std::cout <<
"-> Encounter type: Lead/follow-situation on non-internal lane '" << egoLane->
getID() <<
"'" << std::endl;
1456 std::cout <<
"-> Encounter type: " << type << std::endl;
1460 assert(egoDistToConflictLane <= 0);
1462 if (foeConflictLane == egoLane) {
1467 std::cout <<
"-> Encounter type: Ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' leads foe '" 1468 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1476 std::cout <<
"-> Encounter type: " << type << std::endl;
1485 assert(&(foeLane->
getEdge()) == &(egoConflictLane->getEdge()));
1486 assert(foeDistToConflictLane <= 0);
1487 if (foeLane == egoConflictLane) {
1491 std::cout <<
"-> Encounter type: Ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' follows foe '" 1492 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1500 std::cout <<
"-> Encounter type: " << type << std::endl;
1508 MSLink* egoEntryLink = egoConflictLane->getEntryLink();
1510 if (&(egoEntryLink->getViaLane()->getEdge()) == &(foeEntryLink->
getViaLane()->
getEdge())) {
1511 if (egoEntryLink != foeEntryLink) {
1515 std::cout <<
"-> Encounter type: " << type << std::endl;
1519 if (egoLane == egoConflictLane && foeLane != foeConflictLane) {
1524 std::cout <<
"-> Encounter type: Ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' leads foe '" 1525 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1529 }
else if (egoLane != egoConflictLane && foeLane == foeConflictLane) {
1534 std::cout <<
"-> Encounter type: Ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' follows foe '" 1535 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1543 assert(egoLane == egoConflictLane);
1544 assert(foeLane == foeConflictLane);
1545 if (egoLane == foeLane) {
1551 std::cout <<
"-> Encounter type: Ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' leads foe '" 1552 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1560 std::cout <<
"-> Encounter type: Ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' follows foe '" 1561 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1569 std::cout <<
" Lead/follow situation on consecutive internal lanes." << std::endl;
1571 MSLane* lane = egoEntryLink->getViaLane();
1573 #pragma warning(push) 1574 #pragma warning(disable: 4127) // do not warn about constant conditional expression 1578 #pragma warning(pop) 1582 if (egoLane == lane) {
1587 while (lane != foeLane) {
1593 egoConflictLane = lane;
1595 std::cout <<
"-> Encounter type: Ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' follows foe '" 1596 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1601 }
else if (foeLane == lane) {
1606 while (lane != egoLane) {
1612 foeConflictLane = lane;
1614 std::cout <<
"-> Encounter type: Ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' leads foe '" 1615 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1626 std::cout <<
"-> Encounter type: Lead/follow-situation on connection from '" << egoEntryLink->getLaneBefore()->getID()
1627 <<
"' to '" << egoEntryLink->getLane()->getID() <<
"'" << std::endl;
1634 const std::vector<MSLink*>& egoFoeLinks = egoEntryLink->getFoeLinks();
1635 const std::vector<MSLink*>& foeFoeLinks = foeEntryLink->
getFoeLinks();
1637 bool crossOrMerge = (find(egoFoeLinks.begin(), egoFoeLinks.end(), foeEntryLink) != egoFoeLinks.end()
1638 || find(foeFoeLinks.begin(), foeFoeLinks.end(), egoEntryLink) != foeFoeLinks.end());
1639 if (!crossOrMerge) {
1649 std::cout <<
"-> Encounter type: No conflict." << std::endl;
1652 }
else if (&(foeEntryLink->
getLane()->
getEdge()) == &(egoEntryLink->getLane()->getEdge())) {
1653 if (foeEntryLink->
getLane() == egoEntryLink->getLane()) {
1658 std::cout <<
"-> Encounter type: Merging situation of ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' and foe '" 1659 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1667 std::cout <<
"-> Encounter type: No conflict: " << type << std::endl;
1673 assert(egoConflictLane->isInternal());
1674 assert(foeConflictLane->
getEdge().
getToJunction() == egoConflictLane->getEdge().getToJunction());
1681 egoConflictLane = egoConflictLane->getFirstInternalInConnection(offset);
1682 egoDistToConflictLane -= offset;
1684 foeDistToConflictLane -= offset;
1688 double egoDistToConflictFromJunctionEntry =
INVALID;
1689 double foeInternalLaneLengthsBeforeCrossing = 0.;
1690 while (foeConflictLane != 0 && foeConflictLane->
isInternal()) {
1691 egoDistToConflictFromJunctionEntry = egoEntryLink->getLengthsBeforeCrossing(foeConflictLane);
1692 if (egoDistToConflictFromJunctionEntry !=
INVALID) {
1697 foeInternalLaneLengthsBeforeCrossing += foeConflictLane->
getLength();
1700 assert(foeConflictLane != 0 && foeConflictLane->
isInternal());
1702 assert(egoDistToConflictFromJunctionEntry !=
INVALID);
1705 double foeDistToConflictFromJunctionEntry =
INVALID;
1706 double egoInternalLaneLengthsBeforeCrossing = 0.;
1707 foeDistToConflictFromJunctionEntry =
INVALID;
1708 while (egoConflictLane != 0 && egoConflictLane->isInternal()) {
1710 if (foeDistToConflictFromJunctionEntry !=
INVALID) {
1715 egoInternalLaneLengthsBeforeCrossing += egoConflictLane->getLength();
1717 egoConflictLane = egoConflictLane->getCanonicalSuccessorLane();
1718 assert(egoConflictLane != 0 && egoConflictLane->isInternal());
1720 assert(foeDistToConflictFromJunctionEntry !=
INVALID);
1724 eInfo.
egoConflictEntryCrossSection = std::make_pair(egoConflictLane, egoDistToConflictFromJunctionEntry - egoInternalLaneLengthsBeforeCrossing);
1725 eInfo.
foeConflictEntryCrossSection = std::make_pair(foeConflictLane, foeDistToConflictFromJunctionEntry - foeInternalLaneLengthsBeforeCrossing);
1731 Position egoEntryPos = egoEntryLink->getViaLane()->getShape().front();
1732 Position egoExitPos = egoEntryLink->getCorrespondingExitLink()->getInternalLaneBefore()->getShape().back();
1742 assert(angle <= 2 *
M_PI);
1746 assert(angle >= -
M_PI);
1747 assert(angle <=
M_PI);
1749 double crossingOrientation = (angle < 0) - (angle > 0);
1762 std::cout <<
" Determined exact conflict distances for crossing conflict." 1763 <<
"\n crossingOrientation=" << crossingOrientation
1766 <<
", relativeAngle=" << angle
1767 <<
" (foe from " << (crossingOrientation > 0 ?
"right)" :
"left)")
1768 <<
"\n resulting offset for conflict entry distance:" 1771 <<
"\n resulting entry distances:" 1786 std::cout <<
"real egoConflictLane: '" << (egoConflictLane == 0 ?
"NULL" : egoConflictLane->getID()) <<
"'\n" 1787 <<
"real foeConflictLane: '" << (foeConflictLane == 0 ?
"NULL" : foeConflictLane->
getID()) <<
"'\n" 1788 <<
"-> Encounter type: Crossing situation of ego '" << e->
ego->
getID() <<
"' on lane '" << egoLane->
getID() <<
"' and foe '" 1789 << e->
foe->
getID() <<
"' on lane '" << foeLane->
getID() <<
"'" 1804 std::cout <<
SIMTIME <<
" findFoeConflictLane() for foe '" 1806 <<
"' (with egoConflictLane=" << (egoConflictLane == 0 ?
"NULL" : egoConflictLane->
getID())
1813 assert(foeLane->
isInternal() || *laneIter == foeLane);
1819 if (conflictJunction != 0) {
1820 std::cout <<
"Potential conflict on junction '" << conflictJunction->
getID()
1832 if (*laneIter == 0) {
1833 while (foeLane != 0 && foeLane->
isInternal()) {
1834 distToConflictLane += foeLane->
getLength();
1835 foeLane = foeLane->
getLinkCont()[0]->getViaLane();
1838 assert(laneIter == foeBestLanesEnd || *laneIter != 0);
1842 while (laneIter != foeBestLanesEnd && distToConflictLane <=
myRange) {
1844 assert(*laneIter == foeLane || foeLane == 0);
1845 foeLane = *laneIter;
1849 std::cout <<
"Found conflict lane for foe: '" << foeLane->
getID() <<
"'" << std::endl;
1855 distToConflictLane += foeLane->
getLength();
1859 if (laneIter == foeBestLanesEnd) {
1862 MSLane* nextNonInternalLane = *laneIter;
1869 std::cout <<
"Found conflict lane for foe: '" << foeLane->
getID() <<
"'" << std::endl;
1876 foeLane = nextNonInternalLane;
1885 std::cout <<
"\n" <<
SIMTIME <<
" Device '" <<
getID() <<
"' flushConflicts()" << std::endl;
1913 std::cout <<
SIMTIME <<
" writeOutConflict() of vehicles '" 1915 <<
"'" << std::endl;
1979 std::string res =
"";
1980 for (std::vector<double>::const_iterator i = v.begin(); i != v.end(); ++i) {
1981 res += (i == v.begin() ?
"" : sep) + (*i == NA ?
"NA" :
toString(*i));
1991 bool trajectories,
double range,
double extraTime,
bool useGeoCoords) :
2019 std::vector<std::string> measures;
2020 std::vector<double> threshVals;
2022 measures.push_back(i->first);
2023 threshVals.push_back(i->second);
2025 std::cout <<
"Initialized ssm device '" <<
id <<
"' with " 2029 <<
", myRange=" <<
myRange <<
", output file=" << outputFilename <<
", extra time=" <<
myExtraTime <<
"\n";
2047 #ifdef DEBUG_SSM_NOTIFICATIONS 2048 std::cout <<
"device '" <<
getID() <<
"' notifyEnter: reason=" << reason <<
" currentEdge=" << veh.
getLane()->
getEdge().
getID() <<
"\n";
2059 #ifdef DEBUG_SSM_NOTIFICATIONS 2060 std::cout <<
"device '" <<
getID() <<
"' notifyLeave: reason=" << reason <<
" currentEdge=" << veh.
getLane()->
getEdge().
getID() <<
"\n";
2070 double ,
double newSpeed) {
2071 #ifdef DEBUG_SSM_NOTIFICATIONS 2072 std::cout <<
"device '" <<
getID() <<
"' notifyMove: newSpeed=" << newSpeed <<
"\n";
2082 #ifdef DEBUG_SSM_SURROUNDING 2083 std::cout <<
SIMTIME <<
" Looking for surrounding vehicles for ego vehicle '" << veh.
getID()
2102 assert(*edgeIter != 0);
2106 std::vector<MSLane*>::const_iterator laneIter = egoBestLanes.begin();
2110 assert(lane->
isInternal() || lane == *laneIter);
2113 const MSLane* nextNonInternalLane = 0;
2121 double remainingDownstreamRange = range;
2123 double distToConflictLane = -pos;
2125 std::set<const MSJunction*> seenJunctions;
2133 #ifdef DEBUG_SSM_SURROUNDING 2134 std::cout <<
SIMTIME <<
" Vehicle '" << veh.
getID() <<
"' is on internal edge " << edge->
getID() <<
"'.\n" 2135 <<
"Previous edge of its route: '" << (*edgeIter)->getID() <<
"'" << std::endl;
2143 seenJunctions.insert(junction);
2149 for (ConstMSEdgeVector::const_iterator ei = incoming.begin(); ei != incoming.end(); ++ei) {
2150 if ((*ei)->isInternal()) {
2164 remainingDownstreamRange -= link->getInternalLengthsAfter();
2165 distToConflictLane += lane->
getLength() + link->getInternalLengthsAfter();
2169 lane = *(++laneIter);
2182 while (remainingDownstreamRange > 0.) {
2183 #ifdef DEBUG_SSM_SURROUNDING 2184 std::cout <<
SIMTIME <<
" Scanning downstream for vehicle '" << veh.
getID() <<
"' on lane '" << veh.
getLane()->
getID() <<
"', position=" << pos <<
".\n" 2185 <<
"Considering edge '" << edge->
getID() <<
"' Remaining downstream range = " << remainingDownstreamRange
2186 <<
"\nbestLanes=" <<
toString(egoBestLanes) <<
"\n" 2191 assert(pos == 0 || lane == veh.
getLane());
2192 if (pos + remainingDownstreamRange < lane->getLength()) {
2194 getUpstreamVehicles(edge, pos + remainingDownstreamRange, remainingDownstreamRange, distToConflictLane, lane, foeCollector, seenJunctions);
2202 remainingDownstreamRange -= lane->getLength() - pos;
2203 distToConflictLane += lane->getLength();
2208 assert(laneIter == egoBestLanes.end() || *laneIter != 0);
2211 if (laneIter != egoBestLanes.end()) {
2213 const MSJunction* junction = lane->getEdge().getToJunction();
2216 nextNonInternalLane = *laneIter;
2217 MSLink* link = lane->getLinkTo(nextNonInternalLane);
2223 if (seenJunctions.count(junction) == 0) {
2226 seenJunctions.insert(junction);
2229 for (ConstMSEdgeVector::const_iterator ei = incoming.begin(); ei != incoming.end(); ++ei) {
2233 getUpstreamVehicles(*ei, (*ei)->getLength(), range, distToConflictLane, lane, foeCollector, seenJunctions);
2237 remainingDownstreamRange -= linkLength;
2238 distToConflictLane += linkLength;
2239 #ifdef DEBUG_SSM_SURROUNDING 2240 std::cout <<
" Downstream Scan for vehicle '" << veh.
getID() <<
"' proceeded over junction '" << junction->
getID()
2241 <<
"',\n linkLength=" << linkLength <<
", remainingDownstreamRange=" << remainingDownstreamRange
2246 lane = nextNonInternalLane;
2247 edge = &(lane->getEdge());
2249 #ifdef DEBUG_SSM_SURROUNDING 2250 std::cout <<
" Downstream Scan for vehicle '" << veh.
getID() <<
"' stops at junction '" << junction->
getID()
2251 <<
"', which has already been scanned." 2263 foeCollector.erase(&veh);
2268 #ifdef DEBUG_SSM_SURROUNDING 2269 std::cout <<
SIMTIME <<
" getUpstreamVehicles() for edge '" << edge->
getID() <<
"'" 2270 <<
" pos = " << pos <<
" range = " << range
2271 <<
"\nFound vehicles:" 2278 const std::vector<MSLane*>& lanes = edge->
getLanes();
2280 for (std::vector<MSLane*>::const_iterator li = lanes.begin(); li != lanes.end(); ++li) {
2283 for (MSLane::VehCont::const_iterator vi = vehicles.begin(); vi != vehicles.end(); ++vi) {
2287 std::cout << veh->
getID() <<
"\n";
2292 foeCollector[veh] = c;
2299 std::cout << std::endl;
2315 if (seenJunctions.count(junction) == 0) {
2323 seenJunctions.insert(junction);
2327 for (ConstMSEdgeVector::const_iterator ei = incoming.begin(); ei != incoming.end(); ++ei) {
2328 if ((*ei)->isInternal()) {
2331 const MSEdge* inEdge = *ei;
2332 assert(inEdge != 0);
2334 if (distOnJunction >= range) {
2338 getUpstreamVehicles(inEdge, inEdge->
getLength(), range - distOnJunction, egoDistToConflictLane, egoConflictLane, foeCollector, seenJunctions);
2341 #ifdef DEBUG_SSM_SURROUNDING 2342 std::cout <<
" Downstream Scan for stops at junction '" << junction->
getID()
2343 <<
"', which has already been scanned." 2351 #ifdef DEBUG_SSM_SURROUNDING 2352 std::cout <<
SIMTIME <<
" getVehiclesOnJunction() for junction '" << junction->
getID() <<
"'" 2353 <<
"\nFound vehicles:" 2358 for (std::vector<MSLane*>::const_iterator li = lanes.begin(); li != lanes.end(); ++li) {
2364 for (MSLane::VehCont::const_iterator vi = vehicles.begin(); vi != vehicles.end(); ++vi) {
2368 foeCollector[*vi] = c;
2369 #ifdef DEBUG_SSM_SURROUNDING 2370 for (MSLane::VehCont::const_iterator vi = vehicles.begin(); vi != vehicles.end(); ++vi) {
2371 std::cout << (*vi)->getID() <<
"\n";
2387 for (MSLane::VehCont::const_iterator vi = vehicles2.begin(); vi != vehicles2.end(); ++vi) {
2391 foeCollector[*vi] = c;
2392 #ifdef DEBUG_SSM_SURROUNDING 2393 for (MSLane::VehCont::const_iterator vi = vehicles2.begin(); vi != vehicles2.end(); ++vi) {
2394 std::cout << (*vi)->getID() <<
"\n";
2402 #ifdef DEBUG_SSM_SURROUNDING 2403 std::cout << std::endl;
2421 std::string file = deviceID +
".xml";
2435 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device.ssm.file'. Using default of '" << file <<
"'\n";
2443 bool useGeo =
false;
2457 useGeo = oc.
getBool(
"device.ssm.geo");
2459 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device.ssm.geo'. Using default of '" << useGeo <<
"'\n";
2483 range = oc.
getFloat(
"device.ssm.range");
2485 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device.ssm.range'. Using default of '" << range <<
"'\n";
2509 extraTime = oc.
getFloat(
"device.ssm.extratime");
2511 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device.ssm.extratime'. Using default of '" << extraTime <<
"'\n";
2514 if (extraTime < 0.) {
2516 WRITE_WARNING(
"Negative (or no) value encountered for vehicle parameter 'device.ssm.extratime' in vehicle '" + v.
getID() +
"' using default value " +
toString(extraTime) +
" instead");
2525 bool trajectories =
false;
2539 trajectories = oc.
getBool(
"device.ssm.trajectories");
2541 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device.ssm.trajectories'. Using default of '" << trajectories <<
"'\n";
2544 return trajectories;
2553 std::string measures_str =
"";
2567 measures_str = oc.
getString(
"device.ssm.measures");
2568 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device.ssm.measures'. Using default of '" << measures_str <<
"'\n";
2572 if (measures_str ==
"") {
2573 WRITE_WARNING(
"No measures specified for ssm device of vehicle '" + v.
getID() +
"'. Registering all available SSMs.");
2577 std::vector<std::string> available = st.
getVector();
2579 std::vector<std::string> measures = st.
getVector();
2580 for (std::vector<std::string>::const_iterator i = measures.begin(); i != measures.end(); ++i) {
2581 if (std::find(available.begin(), available.end(), *i) == available.end()) {
2583 WRITE_ERROR(
"SSM identifier '" + *i +
"' is not supported. Aborting construction of SSM device '" + deviceID +
"'.");
2589 std::string thresholds_str =
"";
2603 thresholds_str = oc.
getString(
"device.ssm.thresholds");
2605 std::cout <<
"vehicle '" << v.
getID() <<
"' does not supply vehicle parameter 'device.ssm.thresholds'. Using default of '" << thresholds_str <<
"'\n";
2611 if (thresholds_str !=
"") {
2613 while (count < (
int)measures.size() && st.
hasNext()) {
2615 thresholds.insert(std::make_pair(measures[count], thresh));
2618 if (thresholds.size() < measures.size() || st.
hasNext()) {
2619 WRITE_ERROR(
"Given list of thresholds ('" + thresholds_str +
"') is not of the same size as the list of measures ('" + measures_str +
"').\nPlease specify exactly one threshold for each measure.");
2624 for (std::vector<std::string>::const_iterator i = measures.begin(); i != measures.end(); ++i) {
2627 }
else if (*i ==
"DRAC") {
2629 }
else if (*i ==
"PET") {
2632 WRITE_ERROR(
"Unknown SSM identifier '" + (*i) +
"'. Aborting construction of ssm device.");
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
double getInternalFollowingLengthTo(const MSEdge *followerAfterInternal) const
returns the length of all internal edges on the junction until reaching the non-internal edge followe...
double foeConflictAreaLength
bool myUseGeoCoords
Whether to use the original coordinate system for output.
double getLength() const
return the length of the edge
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
static void determineConflictPoint(EncounterApproachInfo &eInfo)
Calculates the (x,y)-coordinate for the eventually predicted conflict point and stores the result in ...
void determinePET(EncounterApproachInfo &eInfo) const
Discriminates between different encounter types and correspondingly determines the PET for those case...
std::pair< const MSLane *, double > egoConflictEntryCrossSection
ENCOUNTER_TYPE_MERGING_ADJACENT.
MSEdge & getEdge() const
Returns the lane's edge.
static const std::set< MSDevice * > & getInstances()
returns all currently existing SSM devices
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
static void getVehiclesOnJunction(const MSJunction *, double egoDistToConflictLane, const MSLane *const egoConflictLane, FoeInfoMap &foeCollector)
Collects all vehicles on the junction into foeCollector.
double getWidth() const
Returns the lane's width.
Representation of a vehicle in the micro simulation.
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
void createEncounters(FoeInfoMap &foes)
Makes new encounters for all given vehicles (these should be the ones entering the device's range in ...
std::pair< std::pair< double, double >, Position > maxDRAC
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder leaves a lane.
std::pair< std::pair< double, double >, Position > minTTC
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
Position getVelocityVector() const
Returns the vehicle's direction in radians.
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.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
PositionVector conflictPointSpan
Predicted location of the conflict: In case of MERGING and CROSSING: entry point to conflict area for...
static bool _2bool(const E *const data)
converts a 0-terminated char-type array into the boolean value described by it
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...
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
const std::vector< MSLink * > & getFoeLinks() const
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_SSM-options.
SUMOVehicle & myHolder
The vehicle that stores the device.
int gPrecision
the precision for floating point outputs
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
double egoConflictEntryTime
Times when the ego vehicle entered/left the conflict area. Currently only applies for crossing situat...
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
The base class for an intersection.
MSLane * getViaLane() const
Returns the following inner lane.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
EncounterVector myActiveEncounters
double foeEstimatedConflictExitTime
Notification
Definition of a vehicle state.
std::vector< std::pair< std::pair< const MSLane *, double >, double > > foePETCrossSections
std::size_t size() const
Returns the number of trajectory points stored.
ENCOUNTER_TYPE_FOLLOWING_PASSED.
double getLength() const
Returns the lane's length.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
void closeEncounter(Encounter *e)
Finalizes the encounter and calculates SSM values.
double getPositionOnLane() const
Get the vehicle's position along the lane.
static double getDetectionRange(const SUMOVehicle &v)
ENCOUNTER_TYPE_COLLISION.
static void toGeo(Position &x)
convert SUMO-positions to geo coordinates (in place)
std::vector< double > TTCspan
All values for TTC.
ENCOUNTER_TYPE_EGO_ENTERED_CONFLICT_AREA.
std::vector< const MSEdge * > ConstMSEdgeVector
#define DEFAULT_THRESHOLD_PET
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
double foeEstimatedConflictEntryTime
double getLength() const
Returns the vehicle's length.
void updateEncounter(Encounter *e, FoeInfo *foeInfo)
Updates the encounter (adds a new trajectory point) and deletes the foeInfo.
void resetExtraTime(double value)
resets remainingExtraTime to the given value
double egoConflictEntryDist
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.
#define UNUSED_PARAMETER(x)
double egoConflictExitTime
ENCOUNTER_TYPE_BOTH_ENTERED_CONFLICT_AREA.
#define WRITE_WARNING(msg)
std::pair< const MSLane *, double > foeConflictEntryCrossSection
static OptionsCont & getOptions()
Retrieves the options.
static bool requestsTrajectories(const SUMOVehicle &v)
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Encounter(const MSVehicle *_ego, const MSVehicle *const _foe, double _begin, double extraTime)
Constructor.
double egoDistToConflictLane
ENCOUNTER_TYPE_CROSSING_LEADER.
EncounterType currentType
EncounterApproachInfo(Encounter *e)
std::vector< double > DRACspan
All values for DRAC.
std::vector< std::pair< std::pair< const MSLane *, double >, double > > egoPETCrossSections
Cross sections at which a PET shall be calculated for the corresponding vehicle.
ENCOUNTER_TYPE_FOLLOWING_LEADER.
double foeConflictExitTime
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static void getUpstreamVehicles(const MSEdge *edge, double pos, double range, double egoDistToConflictLane, const MSLane *const egoConflictLane, FoeInfoMap &foeCollector, std::set< const MSJunction * > seenJunctions)
Collects all vehicles within range 'range' upstream of the position 'pos' on the edge 'edge' into foe...
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
ENCOUNTER_TYPE_MERGING_FOLLOWER.
MSLane * getCanonicalSuccessorLane() const
static bool getMeasuresAndThresholds(const SUMOVehicle &v, std::string deviceID, std::map< std::string, double > &thresholds)
ENCOUNTER_TYPE_BOTH_LEFT_CONFLICT_AREA.
static bool useGeoCoords(const SUMOVehicle &v, std::string deviceID)
double egoConflictExitDist
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
virtual const std::vector< MSLane * > getInternalLanes() const
Returns all internal lanes on the junction.
const SUMOVTypeParameter & getParameter() const
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Position getPositionAlongBestLanes(double offset) const
Return the (x,y)-position, which the vehicle would reach if it continued along its best continuation ...
Representation of a vehicle.
double getRemainingExtraTime() const
returns the remaining extra time
static double computeDRAC(double gap, double followerSpeed, double leaderSpeed)
Computes the DRAC (deceleration to avoid a collision) for a lead/follow situation as defined...
MSLink * getCorrespondingExitLink() const
returns the corresponding exit link for entryLinks to a junction.
void processEncounters(FoeInfoMap &foes, bool forceClose=false)
Finds encounters for which the foe vehicle has disappeared from range. remainingExtraTime is decrease...
#define DEFAULT_THRESHOLD_DRAC
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
A point in 2D or 3D with translation and scaling methods.
bool myComputeTTC
Flags for switching on / off comutation of different SSMs, derived from myMeasures.
void determineTTCandDRAC(EncounterApproachInfo &eInfo) const
Discriminates between different encounter types and correspondingly determines TTC and DRAC for those...
MSLane * getLane() const
Returns the connected lane.
OutputDevice * myOutputFile
Output device.
ENCOUNTER_TYPE_FOE_LEFT_CONFLICT_AREA.
void resetEncounters()
Closes all current Encounters and moves conflicts to myPastConflicts,.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const MSLane * getFirstInternalInConnection(double &offset) const
Returns 0 if the lane is not internal. Otherwise the first part of the connection (sequence of intern...
double myRange
Detection range. For vehicles closer than this distance from the ego vehicle, SSMs are traced...
std::vector< double > egoDistsToConflict
Evolution of the ego vehicle's distance to the conflict point.
ENCOUNTER_TYPE_FOLLOWING_FOLLOWER.
void generateOutput() const
Finalizes output. Called on vehicle removal.
ENCOUNTER_TYPE_NOCONFLICT_AHEAD.
#define DEFAULT_EXTRA_TIME
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called whenever the holder enteres a lane.
double egoEstimatedConflictExitTime
void computeSSMs(EncounterApproachInfo &e) const
Compute current values of the logged SSMs (myMeasures) for the given encounter 'e' and update 'e' 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.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc)
Adds common command options that allow to assign devices to vehicles.
std::ostream & operator<<(std::ostream &out, MSDevice_SSM::EncounterType type)
Nicer output for EncounterType enum.
ENCOUNTER_TYPE_FOE_ENTERED_CONFLICT_AREA.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
void updateAndWriteOutput()
This is called once per time step in MSNet::writeOutput() and collects the surrounding vehicles...
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double myOldestActiveEncounterBegin
begin time of the oldest active encounter
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
ENCOUNTER_TYPE_FOLLOWING.
bool isInternal() const
return whether this edge is an internal edge
bool mySaveTrajectories
This determines whether the whole trajectories of the vehicles (position, speed, ssms) shall be saved...
static std::string getOutputFilename(const SUMOVehicle &v, std::string deviceID)
std::vector< MSVehicle * > VehCont
Container for vehicles.
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")
std::vector< double > foeDistsToConflict
Evolution of the foe vehicle's distance to the conflict point.
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 closingRequested
this flag is set by updateEncounter() or directly in processEncounters(), where encounters are closed...
std::vector< std::string > getVector()
Abstract in-vehicle device.
ENCOUNTER_TYPE_FOLLOWING_PASSED.
static double passingTime(const double lastPos, const double passedPos, const double currentPos, const double lastSpeed, const double currentSpeed)
Calculates the time at which the position passedPosition has been passed In case of a ballistic updat...
double getMaxSpeedOnLane() const
Returns the maximal speed for the vehicle on its current lane (including speed factor and deviation...
std::vector< Encounter * > EncounterVector
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, SUMOVehicle &v)
Determines whether a vehicle should get a certain device.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
double getPreviousSpeed() const
Returns the vehicle's speed before the previous time step.
double getLength() const
Get vehicle's length [m].
double getLengthsBeforeCrossing(const MSLane *foeLane) const
Returns the sum of the lengths along internal lanes following this link to the crossing with the give...
void countDownExtraTime(double amount)
decreases myRemaingExtraTime by given amount in seconds
double foeConflictEntryTime
Times when the foe vehicle entered/left the conflict area. Currently only applies for crossing situat...
std::map< const MSVehicle *, FoeInfo * > FoeInfoMap
const MSLane * egoConflictLane
Trajectory egoTrajectory
Trajectory of the ego vehicle.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
static std::set< MSDevice * > * instances
All currently existing SSM devices.
~MSDevice_SSM()
Destructor.
Structure to collect some info on the encounter needed during ssm calculation by various functions...
std::vector< double > timeSpan
time points corresponding to the trajectories
A storage for options typed value containers)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static double _2double(const E *const data)
converts a char-type array into the double value described by it
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
const MSLane * findFoeConflictLane(const MSVehicle *foe, const MSLane *egoConflictLane, double &distToConflictLane) const
Computes the conflict lane for the foe.
virtual const std::string & getID() const =0
Get the vehicle's ID.
ENCOUNTER_TYPE_EGO_LEFT_CONFLICT_AREA.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
std::pair< double, double > pet
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double egoEstimatedConflictEntryTime
std::map< std::string, double > myThresholds
double foeConflictExitDist
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
double getLastStepDist() const
Get the distance the vehicle covered in the previous timestep.
const PositionVector & getShape() const
Returns this lane's shape.
An encounter is an episode involving two vehicles, which are closer to each other than some specified...
bool closeTag()
Closes the most recently opened tag.
#define DEFAULT_THRESHOLD_TTC
const MSJunction * getFromJunction() const
double myExtraTime
Extra time in seconds to be logged after a conflict is over.
std::vector< int > typeSpan
Evolution of the encounter classification (.
double remainingExtraTime
Remaining extra time (decreases after an encounter ended)
ENCOUNTER_TYPE_ON_ADJACENT_LANES.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
const ConstMSEdgeVector & getIncoming() const
static void estimateConflictTimes(EncounterApproachInfo &eInfo)
Estimates the time until conflict for the vehicles based on the distance to the conflict entry points...
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
double foeConflictEntryDist
void writeOutConflict(Encounter *e)
MSLane * getLane() const
Returns the lane the vehicle is on.
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.
EncounterType classifyEncounter(const FoeInfo *foeInfo, EncounterApproachInfo &eInfo) const
Classifies the current type of the encounter provided some information on the opponents.
double estimateArrivalTime(double dist, double speed, double maxSpeed, double accel) const
Computes the time needed to travel a distance dist given an initial speed and constant acceleration...
std::pair< std::pair< double, double >, Position > PET
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
EncounterQueue myPastConflicts
Past encounters that where qualified as conflicts and are not yet flushed to the output file...
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
double egoConflictAreaLength
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.
const MSJunction * getToJunction() const
double getWidth() const
Returns the vehicle's width.
const std::string & getID() const
Returns the name of the vehicle.
double getSpeed() const
Returns the vehicle's current speed.
std::priority_queue< Encounter *, std::vector< Encounter * >, Encounter::compare > EncounterQueue
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