Skip to content

Commit

Permalink
red violators now react to vehicles on the junction. refs #3148
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/behr_mi/git/sumo_synched/trunk@24620 afbd958f-9f77-42d5-a016-97a22340ccf4
  • Loading branch information
namdre committed Jun 9, 2017
1 parent 3c70858 commit c62b24b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 18 deletions.
24 changes: 21 additions & 3 deletions sumo/src/microsim/MSLink.cpp
Expand Up @@ -46,6 +46,7 @@
#include <microsim/pedestrians/MSPModel.h>

//#define MSLink_DEBUG_CROSSING_POINTS
//#define MSLink_DEBUG_OPENED

// ===========================================================================
// static member variables
Expand Down Expand Up @@ -297,8 +298,8 @@ MSLink::getLeaveTime(const SUMOTime arrivalTime, const double arrivalSpeed,
bool
MSLink::opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength,
double impatience, double decel, SUMOTime waitingTime, double posLat,
std::vector<const SUMOVehicle*>* collectFoes) const {
if (haveRed()) {
std::vector<const SUMOVehicle*>* collectFoes, bool ignoreRed) const {
if (haveRed() && !ignoreRed) {
return false;
}
if (myAmCont && MSGlobals::gUsingInternalLanes) {
Expand Down Expand Up @@ -344,6 +345,13 @@ MSLink::opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, dou
if ((myState == LINKSTATE_STOP || myState == LINKSTATE_ALLWAY_STOP) && waitingTime == 0) {
return false;
}

#ifdef MSLink_DEBUG_OPENED
if (gDebugFlag1) {
std::cout << SIMTIME << " opened link=" << getViaLaneOrLane()->getID() << " foeLinks=" << myFoeLinks.size() << "\n";
}
#endif

for (std::vector<MSLink*>::const_iterator i = myFoeLinks.begin(); i != myFoeLinks.end(); ++i) {
if (MSGlobals::gUseMesoSim) {
if ((*i)->haveRed()) {
Expand Down Expand Up @@ -383,6 +391,16 @@ MSLink::blockedAtTime(SUMOTime arrivalTime, SUMOTime leaveTime, double arrivalSp
bool
MSLink::blockedByFoe(const SUMOVehicle* veh, const ApproachingVehicleInformation& avi, SUMOTime arrivalTime, SUMOTime leaveTime, double arrivalSpeed, double leaveSpeed,
bool sameTargetLane, double impatience, double decel, SUMOTime waitingTime) const {
#ifdef MSLink_DEBUG_OPENED
if (gDebugFlag1) {
std::cout << " foe link=" << getViaLaneOrLane()->getID()
<< " foeVeh=" << veh->getID()
<< " req=" << avi.willPass
<< " aT=" << avi.arrivalTime
<< " lT=" << avi.leavingTime
<< "\n";
}
#endif
if (!avi.willPass) {
return false;
}
Expand Down Expand Up @@ -693,7 +711,7 @@ MSLink::getLeaderInfo(const MSVehicle* ego, double dist, std::vector<const MSPer
<< " isFrontOnLane=" << leader->isFrontOnLane(foeLane)
<< " isOpposite=" << isOpposite << "\n";
}
if (!cannotIgnore && !foeLane->getLinkCont()[0]->getApproaching(leader).willPass && leader->isFrontOnLane(foeLane) && !isOpposite) {
if (!cannotIgnore && !foeLane->getLinkCont()[0]->getApproaching(leader).willPass && leader->isFrontOnLane(foeLane) && !isOpposite && !leader->isStopped()) {
continue;
}
if (cannotIgnore || leader->getWaitingTime() < MSGlobals::gIgnoreJunctionBlocker) {
Expand Down
3 changes: 2 additions & 1 deletion sumo/src/microsim/MSLink.h
Expand Up @@ -209,7 +209,8 @@ class MSLink {
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength,
double impatience, double decel, SUMOTime waitingTime,
double posLat = 0,
std::vector<const SUMOVehicle*>* collectFoes = 0) const;
std::vector<const SUMOVehicle*>* collectFoes = 0,
bool ignoreRed = false) const;

/** @brief Returns the information whether this link is blocked
* Valid after the vehicles have set their requests
Expand Down
35 changes: 21 additions & 14 deletions sumo/src/microsim/MSVehicle.cpp
Expand Up @@ -1943,7 +1943,8 @@ MSVehicle::executeMove() {
MSLink* link = (*i).myLink;

#ifdef DEBUG_EXEC_MOVE
if (DEBUG_COND) std::cout
if (DEBUG_COND) {
std::cout
<< SIMTIME
<< " veh=" << getID()
<< " link=" << (link == 0 ? "NULL" : link->getViaLaneOrLane()->getID())
Expand All @@ -1952,6 +1953,8 @@ MSVehicle::executeMove() {
<< " vW=" << (*i).myVLinkWait
<< " d=" << (*i).myDistance
<< "\n";
gDebugFlag1 = true; // See MSLink_DEBUG_OPENED
}
#endif

// the vehicle must change the lane on one of the next lanes (XXX: refs to code further below???, Leo)
Expand All @@ -1962,7 +1965,8 @@ MSVehicle::executeMove() {
const bool yellow = link->haveYellow();
const bool canBrake = ((*i).myDistance > getCarFollowModel().brakeGap(myState.mySpeed, getCarFollowModel().getMaxDecel(), 0.)
||(MSGlobals::gSemiImplicitEulerUpdate && myState.mySpeed < ACCEL2SPEED(getCarFollowModel().getMaxDecel())));
if (yellow && canBrake && !ignoreRed(link, canBrake)) {
const bool ignoreRedLink = ignoreRed(link, canBrake);
if (yellow && canBrake && !ignoreRedLink) {
vSafe = (*i).myVLinkWait;
myHaveToWaitOnNextLink = true;
link->removeApproaching(this);
Expand All @@ -1980,8 +1984,8 @@ MSVehicle::executeMove() {
getVehicleType().getLength(), getImpatience(),
getCarFollowModel().getMaxDecel(),
getWaitingTime(), getLateralPositionOnLane(),
ls == LINKSTATE_ZIPPER ? &collectFoes : 0)
|| ignoreRed(link, canBrake));
ls == LINKSTATE_ZIPPER ? &collectFoes : 0,
ignoreRedLink));
if (opened && getLaneChangeModel().getShadowLane() != 0) {
MSLink* parallelLink = (*i).myLink->getParallelLink(getLaneChangeModel().getShadowDirection());
if (parallelLink != 0) {
Expand All @@ -1990,21 +1994,24 @@ MSVehicle::executeMove() {
opened = yellow || influencerPrio || (opened & parallelLink->opened((*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(),
getVehicleType().getLength(), getImpatience(),
getCarFollowModel().getMaxDecel(),
getWaitingTime(), shadowLatPos, 0));
getWaitingTime(), shadowLatPos, 0,
ignoreRedLink));
#ifdef DEBUG_EXEC_MOVE
if (DEBUG_COND) std::cout
<< SIMTIME
<< " veh=" << getID()
<< " shadowLane=" << getLaneChangeModel().getShadowLane()->getID()
<< " shadowDir=" << getLaneChangeModel().getShadowDirection()
<< " parallelLink=" << (parallelLink == 0 ? "NULL" : parallelLink->getViaLaneOrLane()->getID())
<< " opened=" << opened
<< "\n";
if (DEBUG_COND) {
std::cout << SIMTIME
<< " veh=" << getID()
<< " shadowLane=" << getLaneChangeModel().getShadowLane()->getID()
<< " shadowDir=" << getLaneChangeModel().getShadowDirection()
<< " parallelLink=" << (parallelLink == 0 ? "NULL" : parallelLink->getViaLaneOrLane()->getID())
<< " opened=" << opened
<< "\n";
gDebugFlag1 = false; // See MSLink_DEBUG_OPENED
}
#endif
}
}
// vehicles should decelerate when approaching a minor link
if (opened && !influencerPrio && !link->havePriority() && !link->lastWasContMajor() && !link->isCont() && !ignoreRed(link, canBrake)) {
if (opened && !influencerPrio && !link->havePriority() && !link->lastWasContMajor() && !link->isCont() && !ignoreRedLink) {
double visibilityDistance = link->getFoeVisibilityDistance();
double determinedFoePresence = i->myDistance <= visibilityDistance;
if (!determinedFoePresence) {
Expand Down

0 comments on commit c62b24b

Please sign in to comment.