77 #include <mesosim/MESegment.h>
78 #include <mesosim/MELoop.h>
82 #ifdef CHECK_MEMORY_LEAKS
84 #endif // CHECK_MEMORY_LEAKS
87 #ifdef DEBUG_VEHICLE_GUI_SELECTION
94 #define BUS_STOP_OFFSET 0.5
125 return (myPos != state.
myPos ||
137 myPos(pos), mySpeed(speed) {}
145 : mySpeedAdaptationStarted(true), myConsiderSafeVelocity(true),
146 myConsiderMaxAcceleration(true), myConsiderMaxDeceleration(true),
147 myAmVTDControlled(false) {}
155 mySpeedAdaptationStarted =
true;
156 mySpeedTimeLine = speedTimeLine;
162 myLaneTimeLine = laneTimeLine;
169 myOriginalSpeed = speed;
171 while (mySpeedTimeLine.size() == 1 || (mySpeedTimeLine.size() > 1 && currentTime > mySpeedTimeLine[1].first)) {
172 mySpeedTimeLine.erase(mySpeedTimeLine.begin());
175 if (mySpeedTimeLine.size() < 2 || currentTime < mySpeedTimeLine[0].first) {
179 if (!mySpeedAdaptationStarted) {
180 mySpeedTimeLine[0].second = speed;
181 mySpeedAdaptationStarted =
true;
185 speed = mySpeedTimeLine[0].second - (mySpeedTimeLine[0].second - mySpeedTimeLine[1].second) * td;
186 if (myConsiderSafeVelocity) {
187 speed =
MIN2(speed, vSafe);
189 if (myConsiderMaxAcceleration) {
190 speed =
MIN2(speed, vMax);
192 if (myConsiderMaxDeceleration) {
193 speed =
MAX2(speed, vMin);
202 while (myLaneTimeLine.size() == 1 || (myLaneTimeLine.size() > 1 && currentTime > myLaneTimeLine[1].first)) {
203 myLaneTimeLine.erase(myLaneTimeLine.begin());
206 if (myLaneTimeLine.size() < 2 || currentTime < myLaneTimeLine[0].first) {
209 unsigned int destinationLaneIndex = myLaneTimeLine[1].second;
210 if ((
unsigned int)currentEdge.
getLanes().size() <= destinationLaneIndex) {
213 if (currentLaneIndex > destinationLaneIndex) {
215 }
else if (currentLaneIndex < destinationLaneIndex) {
225 myConsiderSafeVelocity = value;
231 myConsiderMaxAcceleration = value;
237 myConsiderMaxDeceleration = value;
245 if (myVTDRoute.size() != 0) {
249 if (myVTDPos > myVTDLane->getLength()) {
250 myVTDPos = myVTDLane->getLength();
252 myVTDLane->forceVehicleInsertion(v, myVTDPos);
254 myAmVTDControlled =
false;
268 (*i)->resetPartialOccupation(
this);
272 if ((*i).myLink != 0) {
273 (*i).myLink->removeApproaching(
this);
307 for (std::vector<SUMOVehicleParameter::Stop>::iterator i = pars->
stops.begin(); i != pars->
stops.end(); ++i) {
310 "' on lane '" + i->lane +
"' is not downstream the current route.");
313 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = route->
getStops().begin(); i != route->
getStops().end(); ++i) {
316 "' on lane '" + i->lane +
"' is not downstream the current route.");
319 const MSLane*
const depLane = (*myCurrEdge)->getDepartLane(*
this);
321 throw ProcessError(
"Invalid departlane definition for vehicle '" + pars->
id +
"'.");
325 "' is too high for the departure lane '" + depLane->
getID() +
"'.");
329 "' is too high for the vehicle type '" + type->
getID() +
"'.");
340 if ((*i).myLink != 0) {
341 (*i).myLink->removeApproaching(
this);
384 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end();) {
385 if (find(edges.begin(), edges.end(), &iter->lane->getEdge()) == edges.end()) {
388 iter->edge = find(edges.begin(), edges.end(), &iter->lane->getEdge());
444 if (!rem->first->notifyMove(*
this, oldPos + rem->second, newPos + rem->second, newSpeed)) {
446 if (myTraceMoveReminders) {
447 traceMoveReminder(
"notifyMove", rem->first, rem->second,
false);
453 if (myTraceMoveReminders) {
454 traceMoveReminder(
"notifyMove", rem->first, rem->second,
true);
469 rem->second += oldLaneLength;
471 if (myTraceMoveReminders) {
472 traceMoveReminder(
"adaptedPos", rem->first, rem->second,
true);
510 atan2(p1.
x() - p2.
x(), p2.
y() - p1.
y()) * 180. /
PI :
531 if (stop.
until != -1) {
532 stop.
until += untilOffset;
544 std::list<Stop>::iterator iter =
myStops.begin();
547 prevStopEdge =
myStops.back().edge;
548 prevStopPos =
myStops.back().endPos;
554 while (iter !=
myStops.end() && (iter->edge < stop.
edge ||
555 (iter->endPos < stop.
endPos && iter->edge == stop.
edge))) {
556 prevStopEdge = iter->edge;
557 prevStopPos = iter->endPos;
561 int index = stopPar.
index;
563 prevStopEdge = iter->edge;
564 prevStopPos = iter->endPos;
572 (prevStopEdge == stop.
edge && prevStopPos > stop.
endPos)) {
607 return currentVelocity;
618 for (std::vector<MSPerson*>::const_iterator i = persons.begin(); i != persons.end(); ++i) {
659 bool busStopsMustHaveSpace =
true;
664 busStopsMustHaveSpace =
false;
672 if (stop.
until >= 0) {
688 return currentVelocity;
702 #ifdef DEBUG_VEHICLE_GUI_SELECTION
708 for (DriveItemVector::iterator i = lfLinks.begin(); i != lfLinks.end(); ++i) {
709 if ((*i).myLink != 0) {
710 (*i).myLink->removeApproaching(
this);
734 assert(bestLaneConts.size() > 0);
735 #ifdef HAVE_INTERNAL_LANES
736 bool hadNonInternal =
false;
738 bool hadNonInternal =
true;
743 unsigned int view = 0;
753 std::pair<const MSVehicle*, SUMOReal> leaderInfo = std::make_pair(pred, gap);
759 adaptToLeader(leaderInfo, seen, lastLink, lane, v, vLinkPass);
770 v =
MIN2(v, stopSpeed);
777 MSLinkCont::const_iterator link =
myLane->
succLinkSec(*
this, view + 1, *lane, bestLaneConts);
816 (*link)->getViaLaneOrLane()->getParallelLane(-
getLaneChangeModel().getLaneChangeDirection()) == 0)) {
818 const SUMOReal va = seen / timeRemaining;
826 const bool setRequest = v > 0;
836 #ifdef HAVE_INTERNAL_LANES
839 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
842 if (leader->myLinkLeaders.count(
getID()) == 0) {
844 myLeaderForLink[*link] = leader->
getID();
845 myLinkLeaders.insert(leader->
getID());
850 v =
MAX2(v, vLinkWait);
862 if (!(*link)->havePriority() && stopDist > cfModel.
getMaxDecel()) {
868 + (seen - (v1 * v1 - arrivalSpeed * arrivalSpeed) * 0.5 / cfModel.
getMaxDecel()) / vLinkWait);
871 const SUMOReal accelTime = (vLinkPass - v) / accel;
872 const SUMOReal accelWay = accelTime * (vLinkPass + v) * 0.5;
884 arrivalSpeedBraking = arrivalSpeed;
889 arrivalSpeedBraking =
MIN2(arrivalSpeedBraking, arrivalSpeed);
890 arrivalTimeBraking =
MAX2(arrivalTime, t +
TIME2STEPS(seen / ((v + arrivalSpeedBraking) * 0.5)));
893 arrivalTime, arrivalSpeed,
894 arrivalTimeBraking, arrivalSpeedBraking,
897 #ifdef HAVE_INTERNAL_LANES
898 if ((*link)->getViaLane() == 0) {
899 hadNonInternal =
true;
905 if (!setRequest || ((v <= 0 || seen > dist) && hadNonInternal && seenNonInternal > vehicleLength * 2)) {
909 lane = (*link)->getViaLaneOrLane();
921 lastLink = &lfLinks.back();
930 if (leaderInfo.first != 0) {
933 if (leaderInfo.second >= 0) {
934 vsafeLeader = cfModel.
followSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCarFollowModel().getMaxDecel());
943 v =
MIN2(v, vsafeLeader);
944 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
951 #ifdef DEBUG_VEHICLE_GUI_SELECTION
968 DriveItemVector::iterator i;
969 bool braking =
false;
970 bool lastWasGreenCont =
false;
972 MSLink* link = (*i).myLink;
974 if (link != 0 && (*i).mySetRequest) {
980 vSafe = (*i).myVLinkWait;
982 lastWasGreenCont =
false;
987 const bool opened = yellow || link->
opened((*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(),
992 vSafe = (*i).myVLinkWait;
994 lastWasGreenCont =
false;
1002 vSafe = (*i).myVLinkPass;
1005 lastWasGreenCont =
false;
1006 vSafe = (*i).myVLinkWait;
1014 vSafe = (*i).myVLinkWait;
1062 std::vector<MSLane*> passedLanes;
1064 passedLanes.push_back(*i);
1066 if (passedLanes.size() == 0 || passedLanes.back() !=
myLane) {
1067 passedLanes.push_back(
myLane);
1082 MSLink* link = (*i).myLink;
1092 if (approachedLane !=
myLane && approachedLane != 0) {
1100 WRITE_WARNING(
"Vehicle '" +
getID() +
"' could not finish continuous lane change (turn lane) time=" +
1105 #ifdef HAVE_INTERNAL_LANES
1107 if (myLeaderForLink.find(link) != myLeaderForLink.end()) {
1108 myLinkLeaders.erase(myLeaderForLink[link]);
1109 myLeaderForLink.erase(link);
1118 passedLanes.push_back(approachedLane);
1124 (*i)->resetPartialOccupation(
this);
1144 std::vector<MSLane*>::reverse_iterator i = passedLanes.rbegin() + 1;
1145 while (leftLength > 0 && i != passedLanes.rend()) {
1147 leftLength -= (*i)->setPartialOccupation(
this, leftLength);
1164 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
1166 foundStopped =
true;
1167 const SUMOReal ret = (*i)->getPositionOnLane() - (*i)->getVehicleType().getLengthWithGap() - lengths;
1171 lengths += (*i)->getVehicleType().getLengthWithGap();
1180 #ifdef DEBUG_VEHICLE_GUI_SELECTION
1188 #ifdef HAVE_INTERNAL_LANES
1190 bool hadVehicle =
false;
1191 SUMOReal seenSpace = -lengthsInFront;
1193 bool foundStopped =
false;
1196 for (
unsigned int i = 0; i < lfLinks.size(); ++i) {
1199 if (item.
myLink == 0 || foundStopped) {
1205 const MSLane* approachedLane = item.
myLink->getViaLane();
1206 if (approachedLane != 0) {
1208 seenSpace = seenSpace - approachedLane->
getVehLenSum();
1230 foundStopped =
true;
1233 seenSpace += approachedLane->
getLength();
1247 foundStopped =
true;
1255 #ifdef DEBUG_VEHICLE_GUI_SELECTION
1261 for (
int i = (
int)(lfLinks.size() - 1); i > 0; --i) {
1267 bool allowsContinuation = item.
myLink == 0 || item.
myLink->
isCont() || !lfLinks[i].hadVehicle || opened;
1268 if (!opened && item.
myLink != 0) {
1272 allowsContinuation =
true;
1276 if (allowsContinuation) {
1282 int removalBegin = -1;
1283 for (
unsigned int i = 0; hadVehicle && i < lfLinks.size() && removalBegin < 0; ++i) {
1297 if (leftSpace < 0/* && item.myLink->willHaveBlockedFoe()*/) {
1304 if (leftSpace < -impatienceCorrection / 10. && item.myLink->isCrossing()) {
1312 while (removalBegin < (
int)(lfLinks.size())) {
1314 lfLinks[removalBegin].myVLinkPass = lfLinks[removalBegin].myVLinkWait;
1316 lfLinks[removalBegin].mySetRequest =
false;
1325 for (DriveItemVector::iterator i = lfLinks.begin(); i != lfLinks.end(); ++i) {
1326 if ((*i).myLink != 0) {
1330 (*i).myLink->setApproaching(
this, (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(),
1331 (*i).mySetRequest, (*i).myArrivalTimeBraking, (*i).myArrivalSpeedBraking,
getWaitingTime());
1340 if (rem->first->getLane() != 0 && rem->first->getLane() !=
getLane()) {
1342 if (myTraceMoveReminders) {
1343 traceMoveReminder(
"notifyEnter_skipped", rem->first, rem->second,
true);
1348 if (rem->first->notifyEnter(*
this, reason)) {
1350 if (myTraceMoveReminders) {
1351 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
1357 if (myTraceMoveReminders) {
1358 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
1388 if (!onTeleporting) {
1430 while (i != route.
begin() && leftLength > 0) {
1437 leftLength -= (lane)->setPartialOccupation(
this, leftLength);
1483 MSLane* clane = enteredLane;
1484 while (leftLength > 0) {
1490 leftLength -= (clane)->setPartialOccupation(
this, leftLength);
1498 if (rem->first->notifyLeave(*
this,
myState.
myPos + rem->second, reason)) {
1500 if (myTraceMoveReminders) {
1501 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
true);
1507 if (myTraceMoveReminders) {
1508 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
false);
1516 (*i)->resetPartialOccupation(
this);
1538 const std::vector<MSVehicle::LaneQ>&
1540 #ifdef DEBUG_VEHICLE_GUI_SELECTION
1547 if (startLane == 0) {
1550 assert(startLane != 0);
1556 std::vector<LaneQ>::iterator i;
1557 for (i = lanes.begin(); i != lanes.end(); ++i) {
1559 for (std::vector<MSLane*>::const_iterator j = (*i).bestContinuations.begin() + 1; j != (*i).bestContinuations.end(); ++j) {
1560 nextOccupation += (*j)->getVehLenSum();
1562 (*i).nextOccupation = nextOccupation;
1563 if ((*i).lane == startLane) {
1574 const MSEdge* nextStopEdge = 0;
1575 const MSLane* nextStopLane = 0;
1579 nextStopLane = nextStop.
lane;
1580 nextStopEdge = &nextStopLane->
getEdge();
1588 if (nextStopEdge != 0) {
1597 bool progress =
true;
1599 std::vector<LaneQ> currentLanes;
1600 const std::vector<MSLane*>* allowed = 0;
1601 const MSEdge* nextEdge = 0;
1603 nextEdge = *(ce + 1);
1606 const std::vector<MSLane*>& lanes = (*ce)->getLanes();
1607 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1614 q.
allowsContinuation = allowed == 0 || find(allowed->begin(), allowed->end(), cl) != allowed->end();
1615 currentLanes.push_back(q);
1618 if (nextStopEdge == *ce) {
1620 for (std::vector<LaneQ>::iterator q = currentLanes.begin(); q != currentLanes.end(); ++q) {
1621 if (nextStopLane != 0 && nextStopLane != (*q).lane) {
1622 (*q).allowsContinuation =
false;
1623 (*q).length = nextStopPos;
1630 seenLength += currentLanes[0].lane->getLength();
1632 progress &= (seen <= 4 || seenLength < 3000);
1633 progress &= seen <= 8;
1645 int bestThisIndex = 0;
1648 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
1649 if ((*j).length > bestLength) {
1650 bestLength = (*j).length;
1651 bestThisIndex = index;
1655 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
1656 if ((*j).length < bestLength) {
1657 (*j).bestLaneOffset = bestThisIndex - index;
1664 for (std::vector<std::vector<LaneQ> >::reverse_iterator i =
myBestLanes.rbegin() + 1; i !=
myBestLanes.rend(); ++i) {
1665 std::vector<LaneQ>& nextLanes = (*(i - 1));
1666 std::vector<LaneQ>& clanes = (*i);
1667 MSEdge& cE = clanes[0].lane->getEdge();
1671 for (std::vector<LaneQ>::iterator j = nextLanes.begin(); j != nextLanes.end(); ++j, ++index) {
1672 if ((*j).lane->isApproachedFrom(&cE) && bestConnectedLength < (*j).length) {
1673 bestConnectedLength = (*j).length;
1675 if (bestLength < (*j).length) {
1676 bestLength = (*j).length;
1679 if (bestConnectedLength > 0) {
1680 int bestThisIndex = 0;
1682 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
1683 LaneQ bestConnectedNext;
1684 bestConnectedNext.
length = -1;
1685 if ((*j).allowsContinuation) {
1686 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m) {
1687 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
1688 if (bestConnectedNext.
length < (*m).length || (bestConnectedNext.
length == (*m).length &&
abs(bestConnectedNext.
bestLaneOffset) >
abs((*m).bestLaneOffset))) {
1689 bestConnectedNext = *m;
1694 (*j).
length += bestLength;
1696 (*j).length += bestConnectedNext.
length;
1699 if (clanes[bestThisIndex].length < (*j).length || (clanes[bestThisIndex].length == (*j).length &&
abs(
abs(clanes[bestThisIndex].bestLaneOffset > (*j).bestLaneOffset)))) {
1700 bestThisIndex = index;
1706 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
1707 if ((*j).length < clanes[bestThisIndex].length || ((*j).length == clanes[bestThisIndex].length &&
abs((*j).bestLaneOffset) <
abs(clanes[bestThisIndex].bestLaneOffset))) {
1708 (*j).bestLaneOffset = bestThisIndex - index;
1710 (*j).bestLaneOffset = 0;
1716 int bestThisIndex = 0;
1717 int bestNextIndex = 0;
1718 int bestDistToNeeded = (
int) clanes.size();
1720 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
1721 if ((*j).allowsContinuation) {
1723 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m, ++nextIndex) {
1724 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
1725 if (bestDistToNeeded >
abs((*m).bestLaneOffset)) {
1726 bestDistToNeeded =
abs((*m).bestLaneOffset);
1727 bestThisIndex = index;
1728 bestNextIndex = nextIndex;
1734 clanes[bestThisIndex].length += nextLanes[bestNextIndex].length;
1735 copy(nextLanes[bestNextIndex].bestContinuations.begin(), nextLanes[bestNextIndex].bestContinuations.end(), back_inserter(clanes[bestThisIndex].bestContinuations));
1737 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
1738 if ((*j).length < clanes[bestThisIndex].length || ((*j).length == clanes[bestThisIndex].length &&
abs((*j).bestLaneOffset) <
abs(clanes[bestThisIndex].bestLaneOffset))) {
1739 (*j).bestLaneOffset = bestThisIndex - index;
1741 (*j).bestLaneOffset = 0;
1750 std::vector<LaneQ>& currLanes = *
myBestLanes.begin();
1751 std::vector<LaneQ>::iterator i;
1752 for (i = currLanes.begin(); i != currLanes.end(); ++i) {
1754 for (std::vector<MSLane*>::const_iterator j = (*i).bestContinuations.begin() + 1; j != (*i).bestContinuations.end(); ++j) {
1755 nextOccupation += (*j)->getVehLenSum();
1757 (*i).nextOccupation = nextOccupation;
1758 if ((*i).lane == startLane) {
1766 const std::vector<MSLane*>&
1771 return (*myCurrentLaneInBestLanes).bestContinuations;
1775 const std::vector<MSLane*>&
1781 if ((*i).lane == l) {
1782 return (*i).bestContinuations;
1791 std::vector<MSLane*>& bestLaneConts = (*myCurrentLaneInBestLanes).bestContinuations;
1793 bestLaneConts.erase(bestLaneConts.begin() + 1, bestLaneConts.end());
1812 #ifdef DEBUG_VEHICLE_GUI_SELECTION
1817 if (
isOnRoad() && destEdge != NULL) {
1881 unsigned int numExpected = (
unsigned int)
myStops.front().awaitedPersons.size();
1882 if (numExpected != 0) {
1887 numExpected = (
unsigned int)
myStops.front().awaitedPersons.size();
1889 if (numExpected == 0) {
1915 switch ((*link)->getDirection()) {
1944 std::vector<MSLane*>::const_iterator laneP = std::find((*myCurrEdge)->getLanes().begin(), (*myCurrEdge)->getLanes().end(),
myLane);
1945 return (
unsigned int) std::distance((*myCurrEdge)->getLanes().begin(), laneP);
1960 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end(); iter++) {
1961 if (iter->lane == lane && fabs(iter->endPos - pos) <
POSITION_EPS) {
1962 if (duration == 0 && !iter->reached) {
1965 iter->duration = duration;
2024 std::vector<int> internals;
2036 unsigned int routeOffset;
2041 myDeparture -= offset;
void resetRoutePosition(unsigned int index)
bool signalSet(int which) const
Returns whether the given signal is on.
static SUMOReal computeCO(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted CO given the vehicle type and state (in mg/s)
The link is a partial left direction.
const std::string & getID() const
returns the person id
The link has green light, may pass.
virtual const std::vector< LaneQ > & getBestLanes(bool forceRebuild=false, MSLane *startLane=0) const
Returns the description of best lanes to use in order to continue the route.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
const MSVehicleType * myType
This Vehicle's type.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
SUMOReal getSpeedAfterMaxDecel(SUMOReal v) const
Returns the velocity after maximum deceleration.
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
bool isLinkEnd(MSLinkCont::const_iterator &i) const
SUMOReal getMaxSpeed() const
Get vehicle's maximum speed [m/s].
bool amVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
SUMOReal speed() const
Speed of this state.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void removePerson(MSPerson *p)
const SUMOReal SUMO_const_laneWidth
MSEdgeWeightsStorage * myEdgeWeights
MoveReminderCont myMoveReminders
Current lane's move reminder.
SUMOReal myArrivalPos
the position on the destination lane where the vehicle stops
static SUMOReal computeHC(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted HC given the vehicle type and state (in mg/s)
SUMOReal getHBEFA_HCEmissions() const
Returns HC emission of the current state.
const MSEdge * myLastBestLanesEdge
MSAbstractLaneChangeModel * myLaneChangeModel
bool myAmOnNet
Whether the vehicle is on the network (not parking, teleported, vaporized, or arrived) ...
SUMOReal getImpatience() const
Returns this vehicles impatience.
Position positionAtOffset(SUMOReal pos) const
Returns the position at the given length.
std::vector< std::vector< LaneQ > > myBestLanes
bool parking
whether the vehicle is removed from the net while stopping
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
State myState
This Vehicles driving state (pos and speed)
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
void endLaneChangeManeuver()
bool boardAnyWaiting(MSEdge *edge, MSVehicle *vehicle)
board any applicable persons Boards any people who wait on that edge for the given vehicle and remove...
const Position geometryPositionAtOffset(SUMOReal offset) const
DriveItemVector myLFLinkLanes
Container for used Links/visited Lanes during lookForward.
SUMOReal pos() const
Position of this state.
bool resumeFromStopping()
bool myAmRegisteredAsWaitingForPerson
Whether this vehicle is registered as waiting for a person (for deadlock-recognition) ...
SUMOTime duration
The stopping duration.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
void setBlinkerInformation()
SUMOReal getHBEFA_NOxEmissions() const
Returns NOx emission of the current state.
SUMOReal getLeaveSpeed() const
SUMOReal myAcceleration
The current acceleration before dawdling.
static bool dictionary(std::string id, MSLane *lane)
Inserts a MSLane into the static dictionary Returns true if the key id isn't already in the dictionar...
MSEdgeVector::const_iterator MSRouteIterator
SUMOReal getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
The vehicle arrived at a junction.
std::vector< std::pair< MSVehicle *, SUMOReal > > LinkLeaders
bool isVTDControlled() const
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
virtual SUMOReal followSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const =0
Computes the vehicle's safe speed (no dawdling)
This is an uncontrolled, minor link, has to stop.
SUMOReal getLength() const
Returns the lane's length.
SUMOReal departSpeed
(optional) The initial speed of the vehicle
virtual SUMOReal maxNextSpeed(SUMOReal speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge) ...
static MSDevice_Person * buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
The car-following model abstraction.
virtual MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, unsigned int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts) const
SUMOReal arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
The link is a 180 degree turn.
State(SUMOReal pos, SUMOReal speed)
Constructor.
std::vector< MSVehicle * > VehCont
Container for vehicles.
Notification
Definition of a vehicle state.
static SUMOReal rand()
Returns a random real number in [0, 1)
std::string time2string(SUMOTime t)
SUMOReal getLength() const
Get vehicle's length [m].
Changes the wished vehicle speed / lanes.
const MSEdgeVector & getEdges() const
bool reached
Information whether the stop has been reached.
bool replaceRouteEdges(const MSEdgeVector &edges, bool onInit=false)
Replaces the current route by the given edges.
State & operator=(const State &state)
Assignment operator.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const MSRoute & getRoute() const
Returns the current route.
vehicle doesn't want to change
unsigned int getPersonNumber() const
Returns the number of persons.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
const MSRoute * myRoute
This Vehicle's route.
unsigned int myNumberReroutes
The number of reroutings.
bool hasDeparted() const
Returns whether this vehicle has already departed.
The vehicle got vaporized.
void postProcessVTD(MSVehicle *v)
SUMOReal estimateLeaveSpeed(const MSLink *const link, const SUMOReal vLinkPass) const
estimate leaving speed when accelerating across a link
SUMOTime until
The time at which the vehicle may continue its journey.
SUMOReal mySpeed
the stored speed
Definition of vehicle stop (position and duration)
This is an uncontrolled, right-before-left link.
void removeWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
unsigned int personNumber
The number of persons in the vehicle.
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
Position getPosition(SUMOReal offset=0) const
Return current position (x/y, cartesian)
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
const SUMOVehicleParameter * myParameter
This Vehicle's parameter.
SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge *fromEdge, const MSEdge *toEdge) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
The base class for microscopic and mesoscopic vehicles.
bool myHaveToWaitOnNextLink
SUMOReal processNextStop(SUMOReal currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
A storage for edge travel times and efforts.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step (in s)
SUMOReal x() const
Returns the x-position.
This is an uncontrolled, all-way stop link.
SUMOReal length
The overall length which may be driven when using this lane without a lane change.
#define UNUSED_PARAMETER(x)
std::string getBusStopID(const MSLane *lane, const SUMOReal pos) const
Returns the bus stop close to the given position.
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
The link is a (hard) left direction.
#define WRITE_WARNING(msg)
SUMOReal getBeginLanePosition() const
Returns the begin position of this bus stop.
The car-following model and parameter.
bool triggered
whether an arriving person lets the vehicle continue
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
MSAbstractLaneChangeModel & getLaneChangeModel()
MSCFModel::VehicleVariables * myCFVariables
The per vehicle variables of the car following model.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
Right blinker lights are switched on.
std::vector< Stop > stops
List of the stops the vehicle will make.
SUMOReal getPartialOccupatorEnd() const
Returns the position of the in-lapping vehicle's end.
void enter(SUMOVehicle *what, SUMOReal beg, SUMOReal end)
Called if a vehicle enters this stop.
bool fixContinuations()
repair errors in bestLanes after changing between internal edges
void enterLaneAtInsertion(MSLane *enteredLane, SUMOReal pos, SUMOReal speed, MSMoveReminder::Notification notification)
Update when the vehicle enters a new lane in the emit step.
static SUMOReal computeNoise(SUMOEmissionClass c, double v, double a)
Returns the noise produced by the a vehicle of the given type at the given speed. ...
std::string busstop
(Optional) bus stop if one is assigned to the stop
SUMOReal influenceSpeed(SUMOTime currentTime, SUMOReal speed, SUMOReal vSafe, SUMOReal vMin, SUMOReal vMax)
Applies stored velocity information on the speed to use.
bool operator!=(const State &state)
Operator !=.
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
The vehicle changes lanes (micro only)
Position getPositionAtDistance(SUMOReal offset) const
MSLane * lane
The described lane.
void checkRewindLinkLanes(const SUMOReal lengthsInFront, DriveItemVector &lfLinks) const
SUMOReal getLength() const
return the length of the edge
Left blinker lights are switched on.
MSLane * getLogicalPredecessorLane() const
void continueLaneChangeManeuver(bool moved)
SUMOReal getHBEFA_COEmissions() const
Returns CO emission of the current state.
SUMOReal brakeGap(const SUMOReal speed) const
Returns the distance the vehicle needs to halt including driver's reaction time.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
SUMOReal startPos
The stopping position start.
The vehicle got a new route.
void workOnMoveReminders(SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Processes active move reminder.
vehicle want's to change to right lane
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification)
remove the vehicle from this lane
bool addTraciStop(MSLane *lane, SUMOReal pos, SUMOReal radius, SUMOTime duration, bool parking, bool triggered)
Encapsulated SAX-Attributes.
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
std::vector< const MSEdge * > MSEdgeVector
bool replaceRoute(const MSRoute *route, bool onInit=false)
Replaces the current route by the given one.
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, unsigned int > > &laneTimeLine)
Sets a new lane timeline.
ChangeRequest
Requests set via TraCI.
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the subpart of best lanes that describes the vehicle's current lane and their successors...
A point in 2D or 3D with translation and scaling methods.
SUMOReal endPos
The stopping position end.
MSLane * getLane() const
Returns the connected lane.
bool willPass(const MSEdge *const edge) const
Returns whether the vehicle wil pass the given edge.
void addPerson(MSPerson *person)
Add a passenger.
virtual SUMOReal getFloat(int id) const =0
Returns the SUMOReal-value of the named (by its enum-value) attribute.
static SUMOReal computeCO2(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted CO2 given the vehicle type and state (in mg/s)
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const MSLane * lane
The lane to stop at.
static SUMOReal gap(SUMOReal predPos, SUMOReal predLength, SUMOReal pos)
Uses the given values to compute the brutto-gap.
bool triggered
whether an arriving person lets the vehicle continue
std::list< Stop > myStops
The vehicle's list of stops.
SUMOReal getVehLenSum() const
Returns the sum of lengths of vehicles which were on the lane during the last step.
bool contains(const MSEdge *const edge) const
bool isStopped() const
Returns whether the vehicle is at a stop.
std::pair< MSVehicle *, SUMOReal > getLastVehicleInformation() const
Returns the last vehicle which is still on the lane.
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
void adaptLeaveSpeed(const SUMOReal v)
MSLane * myLane
The lane the vehicle is on.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Influencer * myInfluencer
An instance of a velicty/lane influencing instance; built in "getInfluencer".
std::vector< LaneQ >::iterator myCurrentLaneInBestLanes
SUMOReal getSpaceTillLastStanding(const MSLane *l, bool &foundStopped) const
SUMOTime duration
The stopping duration.
MSVehicle()
invalidated default constructor
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
The link is a (hard) right direction.
SUMOReal getHBEFA_PMxEmissions() const
Returns PMx emission of the current state.
virtual SUMOReal stopSpeed(const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap2pred) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) ...
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
ChangeRequest checkForLaneChanges(SUMOTime currentTime, const MSEdge ¤tEdge, unsigned int currentLaneIndex)
SUMOReal estimateSpeedAfterDistance(const SUMOReal dist, const SUMOReal v, const SUMOReal accel) const
A structure representing the best lanes for continuing the route.
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
const std::vector< MSPerson * > & getPersons() const
Returns the list of persons using this vehicle.
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
MSBusStop * getBusStop(const std::string &id) const
Returns the named bus stop.
virtual MSVehicle * getLastVehicle() const
returns the last vehicle
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuouss lane change.
bool addStop(const SUMOVehicleParameter::Stop &stopPar, SUMOTime untilOffset=0)
Adds a stop.
SUMOTime myWaitingTime
The time the vehicle waits (is not faster than 0.1m/s) in seconds.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
The link is a partial right direction.
virtual SUMOReal getHeadwayTime() const
Get the driver's reaction time [s].
void addReference() const
increments the reference counter for the route
bool isParking() const
Returns whether the vehicle is parking.
SUMOReal getLaneChangeCompletion() const
return whether the vehicle passed the midpoint of a continuous lane change maneuver ...
bool allowsContinuation
Whether this lane allows to continue the drive.
SUMOReal getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
Container that holds the vehicles driving state (position+speed).
void unregisterOneWaitingForPerson()
decreases the count of vehicles waiting for a person to allow recogniztion of person related deadlock...
void registerOneWaitingForPerson()
increases the count of vehicles waiting for a person to allow recogniztion of person related deadlock...
void saveState(OutputDevice &out)
Saves the states of a vehicle.
void planMoveInternal(const SUMOTime t, const MSVehicle *pred, DriveItemVector &lfLinks) const
SUMOReal getOriginalSpeed() const
Returns the originally longitudianl speed to use.
virtual SUMOReal moveHelper(MSVehicle *const veh, SUMOReal vPos) const
Applies interaction with stops and lane changing model influences.
std::string lane
The lane to stop at.
SUMOReal getHBEFA_FuelConsumption() const
Returns fuel consumption of the current state.
SUMOReal getLastFreePos(const SUMOVehicle &forVehicle) const
Returns the last free position on this stop.
MSEdgeWeightsStorage & _getWeightsStorage() const
void leaveLane(const MSMoveReminder::Notification reason)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
SUMOReal getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
unsigned int getVehicleNumber() const
Returns the number of vehicles on this lane.
virtual void requestLaneChange(MSVehicle::ChangeRequest request)
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_UNKNOWN) const
Get the allowed lanes to reach the destination-edge.
vehicle want's to change to left lane
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, SUMOReal > > &speedTimeLine)
Sets a new velocity timeline.
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Structure representing possible vehicle parameter.
virtual SUMOReal freeSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal seen, SUMOReal maxSpeed) const
Computes the vehicle's safe speed without a leader.
bool havePriority() const
Returns whether this link is a major link.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
virtual VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting...
virtual MSPersonControl & getPersonControl()
Returns the person control.
The link has yellow light, may pass.
void setConsiderMaxDeceleration(bool value)
Sets whether the maximum deceleration shall be regarded.
bool fixPosition()
repair errors in vehicle position after changing between internal edges
bool isLaneChangeMidpointPassed() const
return whether the vehicle passed the midpoint of a continuous lane change maneuver ...
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
int mySignals
State of things of the vehicle that can be on or off.
std::vector< MSLane * > bestContinuations
Consecutive lane that can be followed without a lane change (contribute to length and occupation) ...
SUMOReal interpolateLanePosToGeometryPos(SUMOReal lanePos) const
Definition of vehicle stop (position and duration)
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
SUMOReal y() const
Returns the y-position.
The link has red light (must brake)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
SUMOTime until
The time at which the vehicle may continue its journey.
void setConsiderSafeVelocity(bool value)
Sets whether the safe velocity shall be regarded.
int index
at which position in the stops list
void calculateArrivalPos()
(Re-)Calculates the arrival position from the vehicle parameters
static SUMOReal computeNOx(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted NOx given the vehicle type and state (in mg/s)
MSRouteIterator edge
The edge in the route to stop at.
SUMOReal getDistanceToPosition(SUMOReal destPos, const MSEdge *destEdge)
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
The arrival lane is given.
const std::string & getID() const
Returns the name of the vehicle type.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
void resetMoved()
reset the flag whether a vehicle already moved to false
static SUMOTime gTimeToGridlock
void adaptToLeader(const std::pair< const MSVehicle *, SUMOReal > leaderInfo, const SUMOReal seen, DriveProcessItem *const lastLink, const MSLane *const lane, SUMOReal &v, SUMOReal &vLinkPass) const
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to)
Informs all added listeners about a vehicle's state change.
bool isCrossing() const
Returns whether this link belongs to a junction where more than one edge is incoming.
SUMOReal myPos
the stored position
MSBusStop * busstop
(Optional) bus stop if one is assigned to the stop
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
std::vector< DriveProcessItem > DriveItemVector
static SUMOReal computeFuel(SUMOEmissionClass c, double v, double a)
Returns the amount of consumed fuel given the vehicle type and state (in ml/s)
void planMove(const SUMOTime t, const MSVehicle *pred, const SUMOReal lengthsInFront)
Compute safe velocities for the upcoming lanes based on positions and speeds from the last time step...
const PositionVector & getShape() const
Returns this lane's shape.
SUMOReal endPos
The stopping position end.
void move2side(SUMOReal amount)
vehicle want's to keep the current lane
LinkState getState() const
Returns the current state of the link.
bool hasValidRoute(std::string &msg) const
Validates the current route.
static SUMOReal computePMx(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted PMx given the vehicle type and state (in mg/s)
MSVehicle * getPartialOccupator() const
Returns the vehicle which laps into this lane.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
void switchOffSignal(int signal)
Switches the given signal off.
void switchOnSignal(int signal)
Switches the given signal on.
static std::vector< MSLane * > myEmptyLaneVector
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
MSRouteIterator myCurrEdge
Iterator to current route-edge.
virtual ~MSVehicle()
Destructor.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
The link has yellow light, has to brake anyway.
void release() const
deletes the route if there are no further references to it
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
MSLane * getLane() const
Returns the lane the vehicle is on.
void activateReminders(const MSMoveReminder::Notification reason)
"Activates" all current move reminder
The edge is an internal edge.
static SUMOTime gLaneChangeDuration
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
SUMOReal getHBEFA_CO2Emissions() const
Returns CO2 emission of the current state.
void addPerson(MSPerson *person)
Adds a passenger.
SUMOReal startPos
The stopping position start.
GUISelectedStorage gSelected
A global holder of selected objects.
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
Representation of a lane in the micro simulation.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
std::vector< MSDevice * > myDevices
The devices this vehicle has.
void adaptLaneEntering2MoveReminder(const MSLane &enteredLane)
Adapts the vehicle's entering of a new lane.
unsigned int size() const
Return the number of passengers.
A lane change model developed by D. Krajzewicz between 2004 and 2010.
bool opened(SUMOTime arrivalTime, SUMOReal arrivalSpeed, SUMOReal leaveSpeed, SUMOReal vehicleLength, SUMOReal impatience, SUMOReal decel, SUMOTime waitingTime, std::vector< const SUMOVehicle * > *collectFoes=0) const
Returns the information whether the link may be passed.
unsigned int getRoutePosition() const
Interface for lane-change models.
MSDevice_Person * myPersonDevice
The passengers this vehicle may have.
void setConsiderMaxAcceleration(bool value)
Sets whether the maximum acceleration shall be regarded.
SUMOTime myDeparture
The real departure time.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
std::string id
The vehicle's id.
bool parking
whether the vehicle is removed from the net while stopping
static const Position INVALID
The vehicle is being teleported.
int getLaneChangeDirection() const
return the direction of the current lane change maneuver
SUMOReal getAngle() const
Returns the vehicle's direction in degrees.
const std::string & getID() const
Returns the name of the vehicle.
unsigned int getLaneIndex() const