if veh_id not in self.cars_waiting_for_toll:
// Disable lane changes inside Toll Area
lc_mode = self.k.vehicle.get_lane_change_mode(veh_id)
self.cars_waiting_for_toll[veh_id] = {
"lane_change_mode": lc_mode,
}
self.traci_connection.vehicle.setLaneChangeMode(
veh_id, 512)
else:
if pos > 120:
After Change
lane = self.k.vehicle.get_lane(veh_id)
lane_change_mode = \
self.cars_waiting_for_toll[veh_id]["lane_change_mode"]
color = self.cars_waiting_for_toll[veh_id]["color"]self.traci_connection.vehicle.setColor(veh_id, color)
self.traci_connection.vehicle.setLaneChangeMode(
veh_id, lane_change_mode)
if lane not in FAST_TRACK_ON:
self.toll_wait_time[lane] = max(
0,
np.random.normal(
loc=MEAN_SECONDS_WAIT_AT_TOLL / self.sim_step,
scale=1 / self.sim_step))
else:
self.toll_wait_time[lane] = max(
0,
np.random.normal(
loc=MEAN_SECONDS_WAIT_AT_FAST_TRACK /
self.sim_step,
scale=1 / self.sim_step))
cars_that_have_left.append(veh_id)
for veh_id in cars_that_have_left:
self.cars_waiting_for_toll.__delitem__(veh_id)
traffic_light_states = ["G"] * NUM_TOLL_LANES
for lane in range(NUM_TOLL_LANES):
cars_in_lane = self.edge_dict[EDGE_BEFORE_TOLL][lane]
for car in cars_in_lane:
veh_id, pos = car
if pos > TOLL_BOOTH_AREA:
if veh_id not in self.cars_waiting_for_toll:
// Disable lane changes inside Toll Area
lc_mode = self.traci_connection.vehicle.\
getLaneChangeMode(veh_id)
color = self.traci_connection.vehicle.getColor(veh_id)self.cars_waiting_for_toll[veh_id] = {
"lane_change_mode": lc_mode,
"color": color
}
self.traci_connection.vehicle.setLaneChangeMode(
veh_id, 512)
self.traci_connection.vehicle.setColor(
veh_id, (255, 0, 255, 0))
else:
if pos > 120:
if self.toll_wait_time[lane] < 0:
traffic_light_states[lane] = "G"