Skip to content

Commit

Permalink
fix #1102
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/behr_mi/git/sumo_synched/trunk@26261 afbd958f-9f77-42d5-a016-97a22340ccf4
  • Loading branch information
namdre committed Sep 28, 2017
1 parent 216f232 commit 5b0369b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions sumo/src/microsim/MSFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ MSFrame::fillOptions() {
oc.doRegister("collision.check-junctions", new Option_Bool(false));
oc.addDescription("collision.check-junctions", "Processing", "Enables collisions checks on junctions");

oc.doRegister("collision.mingap-factor", new Option_Float(1.0));
oc.addDescription("collision.mingap-factor", "Processing", "Sets the fraction of minGap that must be maintained to avoid collision detection.");

oc.doRegister("max-num-vehicles", new Option_Integer(-1));
oc.addDescription("max-num-vehicles", "Processing", "Delay vehicle insertion to stay within the given maximum number");

Expand Down
6 changes: 4 additions & 2 deletions sumo/src/microsim/MSLane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ MSLane::DictType MSLane::myDict;
MSLane::CollisionAction MSLane::myCollisionAction(MSLane::COLLISION_ACTION_TELEPORT);
bool MSLane::myCheckJunctionCollisions(false);
SUMOTime MSLane::myCollisionStopTime(0);
double MSLane::myCollisionMinGapFactor(1.0);

// ===========================================================================
// internal class method definitions
Expand Down Expand Up @@ -1292,9 +1293,9 @@ MSLane::detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVe
std::swap(victim, collider);
}
const double colliderPos = colliderOpposite ? collider->getBackPositionOnLane(this) : collider->getPositionOnLane(this);
double gap = victim->getBackPositionOnLane(this) - colliderPos - collider->getVehicleType().getMinGap();
double gap = victim->getBackPositionOnLane(this) - colliderPos - myCollisionMinGapFactor * collider->getVehicleType().getMinGap();
if (bothOpposite) {
gap = -gap - 2 * collider->getVehicleType().getMinGap();
gap = -gap - 2 * myCollisionMinGapFactor * collider->getVehicleType().getMinGap();
}
#ifdef DEBUG_COLLISIONS
if (DEBUG_COND) std::cout << SIMTIME
Expand Down Expand Up @@ -3016,6 +3017,7 @@ MSLane::initCollisionOptions(const OptionsCont& oc) {
}
myCheckJunctionCollisions = oc.getBool("collision.check-junctions");
myCollisionStopTime = string2time(oc.getString("collision.stoptime"));
myCollisionMinGapFactor = oc.getFloat("collision.mingap-factor");
}


Expand Down
1 change: 1 addition & 0 deletions sumo/src/microsim/MSLane.h
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,7 @@ class MSLane : public Named, public Parameterised {
static CollisionAction myCollisionAction;
static bool myCheckJunctionCollisions;
static SUMOTime myCollisionStopTime;
static double myCollisionMinGapFactor;

/**
* @class vehicle_position_sorter
Expand Down
5 changes: 4 additions & 1 deletion sumo/tests/sumo/meta/help/output.sumo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SUMO Version dev-SVN-r25756
SUMO Version dev-SVN-r26256
Copyright (C) 2001-2017 DLR and contributors; http://sumo.dlr.de
A microscopic road traffic simulation.

Expand Down Expand Up @@ -125,6 +125,9 @@ Processing Options:
performing collision.action (except for
action 'none')
--collision.check-junctions Enables collisions checks on junctions
--collision.mingap-factor FLOAT Sets the fraction of minGap that must be
maintained to avoid collision
detection.
--max-num-vehicles INT Delay vehicle insertion to stay within
the given maximum number
--max-num-teleports INT Abort the simulation if the given
Expand Down
3 changes: 3 additions & 0 deletions sumo/tests/sumo/meta/write_template_commented_full/cfg.sumo
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@
<!-- Enables collisions checks on junctions -->
<collision.check-junctions value="false" type="BOOL"/>

<!-- Sets the fraction of minGap that must be maintained to avoid collision detection. -->
<collision.mingap-factor value="1" type="FLOAT"/>

<!-- Delay vehicle insertion to stay within the given maximum number -->
<max-num-vehicles value="-1" type="INT"/>

Expand Down
1 change: 1 addition & 0 deletions sumo/tests/sumo/meta/write_template_full/cfg.sumo
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<collision.action value="teleport" type="STR" help="How to deal with collisions: [none,warn,teleport,remove]"/>
<collision.stoptime value="0" type="TIME" help="Let vehicle stop for TIME before performing collision.action (except for action &apos;none&apos;)"/>
<collision.check-junctions value="false" type="BOOL" help="Enables collisions checks on junctions"/>
<collision.mingap-factor value="1" type="FLOAT" help="Sets the fraction of minGap that must be maintained to avoid collision detection."/>
<max-num-vehicles value="-1" type="INT" help="Delay vehicle insertion to stay within the given maximum number"/>
<max-num-teleports value="-1" type="INT" help="Abort the simulation if the given maximum number of teleports is exceeded"/>
<scale value="1" type="FLOAT" help="Scale demand by the given factor (by discarding or duplicating vehicles)"/>
Expand Down

0 comments on commit 5b0369b

Please sign in to comment.