Skip to content

Commit

Permalink
fix #14358
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Feb 26, 2024
1 parent e58e6de commit 29285f8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/microsim/MSLane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ MSLane::insertVehicle(MSVehicle& veh) {
FALLTHROUGH;
case DepartPosDefinition::BASE:
case DepartPosDefinition::DEFAULT:
case DepartPosDefinition::SPLIT_FRONT:
default:
if (pars.departProcedure == DepartDefinition::SPLIT) {
pos = getLength();
Expand All @@ -699,7 +700,11 @@ MSLane::insertVehicle(MSVehicle& veh) {
for (AnyVehicleIterator it = anyVehiclesBegin(); it != end; ++it) {
const MSVehicle* cand = *it;
if (cand->isStopped() && cand->getNextStopParameter()->split == veh.getID()) {
pos = cand->getBackPositionOnLane() - veh.getVehicleType().getMinGap();
if (pars.departPosProcedure == DepartPosDefinition::SPLIT_FRONT) {
pos = cand->getPositionOnLane() + cand->getVehicleType().getMinGap() + veh.getLength();
} else {
pos = cand->getBackPositionOnLane() - veh.getVehicleType().getMinGap();
}
break;
}
}
Expand Down Expand Up @@ -1329,6 +1334,11 @@ MSLane::safeInsertionSpeed(const MSVehicle* veh, double seen, const MSLeaderInfo
gap -= (leader->getLength() + leader->getBrakeGap(true));
}
if (gap < 0) {
#ifdef DEBUG_INSERTION
if (DEBUG_COND2(veh)) {
std::cout << " leader=" << leader->getID() << " bPos=" << leader->getBackPositionOnLane(this) << " gap=" << gap << "\n";
}
#endif
if ((veh->getParameter().insertionChecks & (int)InsertionCheck::COLLISION) != 0) {
return INVALID_SPEED;
} else {
Expand Down
5 changes: 5 additions & 0 deletions src/microsim/MSVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,11 @@ MSVehicle::processNextStop(double currentVelocity) {
if (myContainerDevice != nullptr) {
myContainerDevice->transferAtSplitOrJoin(splitVeh);
}
if (splitVeh->getParameter().departPosProcedure == DepartPosDefinition::SPLIT_FRONT) {
const double backShift = splitVeh->getLength() + getVehicleType().getMinGap();
myState.myPos -= backShift;
myState.myBackPos -= backShift;
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/utils/vehicle/SUMOVehicleParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ SUMOVehicleParameter::parseDepartPos(const std::string& val, const std::string&
dpd = DepartPosDefinition::BASE;
} else if (val == "last") {
dpd = DepartPosDefinition::LAST;
} else if (val == "splitFront") {
dpd = DepartPosDefinition::SPLIT_FRONT;
} else if (val == "stop") {
dpd = DepartPosDefinition::STOP;
} else {
Expand Down Expand Up @@ -828,6 +830,9 @@ SUMOVehicleParameter::getDepartPos() const {
case DepartPosDefinition::BASE:
val = "base";
break;
case DepartPosDefinition::SPLIT_FRONT:
val = "splitFront";
break;
case DepartPosDefinition::STOP:
val = "stop";
break;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/vehicle/SUMOVehicleParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ enum class DepartPosDefinition {
RANDOM_FREE,
/// @brief The position may be chosen freely in a polygon defined by a taz
RANDOM_LOCATION,
/// @brief depart position for a split vehicle is in front of the continuing vehicle
SPLIT_FRONT,
/// @brief depart position is endPos of first stop
STOP
};
Expand Down

0 comments on commit 29285f8

Please sign in to comment.