Skip to content

Commit

Permalink
Fix bug of vehicles colliding
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanlct committed Jul 28, 2019
1 parent 85564c1 commit 72f92d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
6 changes: 4 additions & 2 deletions examples/sumo/highway_ramps.py
@@ -1,7 +1,8 @@
"""Example of a highway section network with on/off ramps."""

from flow.core.params import SumoParams, EnvParams, \
NetParams, InitialConfig, InFlows, SumoCarFollowingParams
NetParams, InitialConfig, InFlows, SumoCarFollowingParams, \
SumoLaneChangeParams
from flow.core.params import VehicleParams
from flow.core.experiment import Experiment
from flow.scenarios.highway_ramps import HighwayRampsScenario, \
Expand Down Expand Up @@ -68,7 +69,8 @@ def highway_ramps_example(render=True):
}),
car_following_params=SumoCarFollowingParams(
speed_mode="obey_safe_speed",
))
),
lane_change_params=SumoLaneChangeParams(lane_change_mode=1621))

env_params = EnvParams(
additional_params=ADDITIONAL_ENV_PARAMS,
Expand Down
30 changes: 0 additions & 30 deletions flow/scenarios/highway_ramps.py
Expand Up @@ -215,36 +215,6 @@ def get_routes(start_node_pos):

return rts

def specify_connections(self, net_params):
"""See parent class."""
conn_dict = defaultdict(list)
for x in self.ramps_pos:
highway_id = self.highway_pos[x]
ramp_id = self.ramp_pos[x]
idx = "highway_{}".format(highway_id)
if ramp_id.startswith("on"):
for i in range(self.on_ramps_lanes):
conn_dict[idx] += [{"from": ramp_id,
"to": "highway_{}".format(highway_id),
"fromLane": str(i),
"toLane": "0"}]
else:
for i in range(self.highway_lanes):
for j in range(self.off_ramps_lanes):
conn_dict[idx] += [{"from": "highway_{}".format(
highway_id - 1),
"to": ramp_id,
"fromLane": str(i),
"toLane": str(j)}]
for i in range(self.highway_lanes):
conn_dict[idx] += [{"from": "highway_{}".format(
highway_id - 1),
"to": "highway_{}".format(highway_id),
"fromLane": str(i),
"toLane": str(i)}]

return conn_dict

def specify_types(self, net_params):
"""See parent class."""
types = [{
Expand Down

0 comments on commit 72f92d4

Please sign in to comment.