From 72f92d4dd906ac472ab50c20104e148df988afbe Mon Sep 17 00:00:00 2001 From: nathanlct Date: Sun, 28 Jul 2019 04:00:44 -0700 Subject: [PATCH] Fix bug of vehicles colliding --- examples/sumo/highway_ramps.py | 6 ++++-- flow/scenarios/highway_ramps.py | 30 ------------------------------ 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/examples/sumo/highway_ramps.py b/examples/sumo/highway_ramps.py index e21222f20..76ef21e11 100644 --- a/examples/sumo/highway_ramps.py +++ b/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, \ @@ -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, diff --git a/flow/scenarios/highway_ramps.py b/flow/scenarios/highway_ramps.py index 22dd37383..f11b98bc5 100644 --- a/flow/scenarios/highway_ramps.py +++ b/flow/scenarios/highway_ramps.py @@ -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 = [{