diff --git a/demo/ball/ball_bounces.py b/demo/ball/ball_bounces.py index 0206cd5bf6474b9081839ef9cd53c21b2d162e39..97f1290cfdfae46e7de9f495c6964f6c7945fc49 100644 --- a/demo/ball/ball_bounces.py +++ b/demo/ball/ball_bounces.py @@ -35,7 +35,7 @@ class State: pass -def controller(ego: State): +def decisionLogic(ego: State): '''Computes the possible mode transitions''' output = copy.deepcopy(ego) '''TODO: Ego and output variable names should be flexible but diff --git a/demo/dryvr_demo/origin_agent.py b/demo/dryvr_demo/origin_agent.py index e3a595844cadbfc1673c4ff1327d419a68873570..57f33b060369916e352915fd8c051f84a46ecc91 100644 --- a/demo/dryvr_demo/origin_agent.py +++ b/demo/dryvr_demo/origin_agent.py @@ -22,7 +22,7 @@ class vanderpol_agent(BaseAgent): y_dot = (1-x**2)*y - x return [x_dot, y_dot] - def TC_simulate(self, mode: List[str], initialCondition, time_bound, time_step, lane_map: LaneMap = None) -> np.ndarray: + def TC_simulate(self, mode: List[str], initialCondition, time_bound, time_step, track_map: LaneMap = None) -> np.ndarray: time_bound = float(time_bound) number_points = int(np.ceil(time_bound/time_step)) t = [round(i*time_step, 10) for i in range(0, number_points)] @@ -64,7 +64,7 @@ class thermo_agent(BaseAgent): raise ValueError(f'Invalid mode: {mode}') return rate - def TC_simulate(self, mode: List[str], initialCondition, time_bound, time_step, lane_map: LaneMap = None) -> np.ndarray: + def TC_simulate(self, mode: List[str], initialCondition, time_bound, time_step, track_map: LaneMap = None) -> np.ndarray: time_bound = float(time_bound) number_points = int(np.ceil(time_bound/time_step)) t = [round(i*time_step, 10) for i in range(0, number_points)] @@ -137,7 +137,7 @@ class craft_agent(BaseAgent): else: raise ValueError - def TC_simulate(self, mode: List[str], initialCondition, time_bound, time_step, lane_map: LaneMap = None) -> np.ndarray: + def TC_simulate(self, mode: List[str], initialCondition, time_bound, time_step, track_map: LaneMap = None) -> np.ndarray: time_bound = float(time_bound) number_points = int(np.ceil(time_bound/time_step)) t = [round(i*time_step, 10) for i in range(0, number_points)] diff --git a/demo/dryvr_demo/rendezvous_controller.py b/demo/dryvr_demo/rendezvous_controller.py index a17f690ef53d5acfb7ae7977004088f86a9f5c11..ff979316c252828cdc2fc823df9a48f8bc7bda95 100644 --- a/demo/dryvr_demo/rendezvous_controller.py +++ b/demo/dryvr_demo/rendezvous_controller.py @@ -21,7 +21,7 @@ class State: pass -def controller(ego: State): +def decisionLogic(ego: State): output = copy.deepcopy(ego) if ego.craft_mode == CraftMode.ProxA: if ego.yp >= -100 and ego.xp+ego.yp >= -141.1 and ego.xp >= -100 and ego.yp-ego.xp <= 141.1 and ego.yp <= 100 and ego.xp+ego.yp <= 141.1 and ego.xp <= 100 and ego.yp-ego.xp >= -141.1: diff --git a/demo/dryvr_demo/thermo_controller.py b/demo/dryvr_demo/thermo_controller.py index 59af1db6e804d9ebd37a6ef240dc7d74d4e569e7..81cb7e5407dc2310d406fc86aaf3ce1d22b4344e 100644 --- a/demo/dryvr_demo/thermo_controller.py +++ b/demo/dryvr_demo/thermo_controller.py @@ -17,7 +17,7 @@ class State: pass -def controller(ego: State): +def decisionLogic(ego: State): output = copy.deepcopy(ego) if ego.thermo_mode == ThermoMode.ON: if ego.cycle_time >= 1.0 and ego.cycle_time < 1.1: diff --git a/demo/dryvr_demo/vanderpol_controller.py b/demo/dryvr_demo/vanderpol_controller.py index 5a6de9525f697868dfdb528ca662909e7cf45819..5d9799ec0f27b7a134eb4ae832c068d6bf051770 100644 --- a/demo/dryvr_demo/vanderpol_controller.py +++ b/demo/dryvr_demo/vanderpol_controller.py @@ -12,7 +12,7 @@ class State: def __init__(self, x, y, agent_mode: AgentMode): pass -def controller(ego: State): +def decisionLogic(ego: State): output = copy.deepcopy(ego) return output diff --git a/demo/tacas2023/exp1/quadrotor_agent.py b/demo/tacas2023/exp1/quadrotor_agent.py index 1956807673e1fd14cf23d3e111c783848b2db0df..0d92e3183ea80cd6326a58cf17fdffba37655d6f 100644 --- a/demo/tacas2023/exp1/quadrotor_agent.py +++ b/demo/tacas2023/exp1/quadrotor_agent.py @@ -8,7 +8,7 @@ import torch import math from verse.agents import BaseAgent from verse.map import LaneMap -from verse.map.lane_map_3d import LaneMap_3d +from verse.map.track_map_3d import LaneMap_3d class FFNNC(torch.nn.Module): diff --git a/demo/tacas2023/exp1/quadrotor_controller3.py b/demo/tacas2023/exp1/quadrotor_controller3.py index 3fc9c2aa607530a08d031ea649ef714d1da6ff5b..50516205bb4f55f47dbc37f9f835c04028791ad2 100644 --- a/demo/tacas2023/exp1/quadrotor_controller3.py +++ b/demo/tacas2023/exp1/quadrotor_controller3.py @@ -45,32 +45,32 @@ def is_close(ego, other): return res -def controller(ego: State, others: List[State], lane_map): +def decisionLogic(ego: State, others: List[State], track_map): next = copy.deepcopy(ego) if ego.craft_mode == CraftMode.Normal: if any((is_close(ego, other) and ego.track_mode == other.track_mode) for other in others): - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveUp): + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveUp): next.craft_mode = CraftMode.MoveUp - next.track_mode = lane_map.h( + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.MoveUp) - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveDown): + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveDown): next.craft_mode = CraftMode.MoveDown - next.track_mode = lane_map.h( + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.MoveDown) if ego.craft_mode == CraftMode.MoveUp: - if lane_map.altitude(ego.track_mode)-ego.z > -1 and lane_map.altitude(ego.track_mode)-ego.z < 1: + if track_map.altitude(ego.track_mode)-ego.z > -1 and track_map.altitude(ego.track_mode)-ego.z < 1: next.craft_mode = CraftMode.Normal - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): - next.track_mode = lane_map.h( + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.Normal) if ego.craft_mode == CraftMode.MoveDown: - if lane_map.altitude(ego.track_mode)-ego.z > -1 and lane_map.altitude(ego.track_mode)-ego.z < 1: + if track_map.altitude(ego.track_mode)-ego.z > -1 and track_map.altitude(ego.track_mode)-ego.z < 1: next.craft_mode = CraftMode.Normal - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): - next.track_mode = lane_map.h( + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.Normal) assert not any(safe_seperation(ego, other) for other in others), "Safe Seperation" diff --git a/demo/tacas2023/exp1/quadrotor_controller4.py b/demo/tacas2023/exp1/quadrotor_controller4.py index b40d4d9f6d2af1899ae92d6a98b43f66269fb8aa..419fe3247960e1790141e2f76b084ce9b3589d92 100644 --- a/demo/tacas2023/exp1/quadrotor_controller4.py +++ b/demo/tacas2023/exp1/quadrotor_controller4.py @@ -33,6 +33,6 @@ class State: pass -def controller(ego: State, others: List[State], lane_map): +def decisionLogic(ego: State, others: List[State], track_map): output = copy.deepcopy(ego) return output diff --git a/demo/tacas2023/exp10/quadrotor_agent.py b/demo/tacas2023/exp10/quadrotor_agent.py index 1956807673e1fd14cf23d3e111c783848b2db0df..0d92e3183ea80cd6326a58cf17fdffba37655d6f 100644 --- a/demo/tacas2023/exp10/quadrotor_agent.py +++ b/demo/tacas2023/exp10/quadrotor_agent.py @@ -8,7 +8,7 @@ import torch import math from verse.agents import BaseAgent from verse.map import LaneMap -from verse.map.lane_map_3d import LaneMap_3d +from verse.map.track_map_3d import LaneMap_3d class FFNNC(torch.nn.Module): diff --git a/demo/tacas2023/exp10/quadrotor_controller3.py b/demo/tacas2023/exp10/quadrotor_controller3.py index 9cc7820081c0b649f2457e487b2ada53a2f78a6a..f55d77d70afe14e1365b1961cec7f3b85e388e0e 100644 --- a/demo/tacas2023/exp10/quadrotor_controller3.py +++ b/demo/tacas2023/exp10/quadrotor_controller3.py @@ -46,32 +46,32 @@ def is_close(ego, other): return res -def controller(ego: State, others: List[State], lane_map): +def decisionLogic(ego: State, others: List[State], track_map): next = copy.deepcopy(ego) if ego.craft_mode == CraftMode.Normal: if any((is_close(ego, other) and ego.track_mode == other.track_mode) for other in others): - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveUp): + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveUp): next.craft_mode = CraftMode.MoveUp - next.track_mode = lane_map.h( + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.MoveUp) - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveDown): + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveDown): next.craft_mode = CraftMode.MoveDown - next.track_mode = lane_map.h( + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.MoveDown) if ego.craft_mode == CraftMode.MoveUp: - if lane_map.altitude(ego.track_mode)-ego.z > -1 and lane_map.altitude(ego.track_mode)-ego.z < 1: + if track_map.altitude(ego.track_mode)-ego.z > -1 and track_map.altitude(ego.track_mode)-ego.z < 1: next.craft_mode = CraftMode.Normal - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): - next.track_mode = lane_map.h( + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.Normal) if ego.craft_mode == CraftMode.MoveDown: - if lane_map.altitude(ego.track_mode)-ego.z > -1 and lane_map.altitude(ego.track_mode)-ego.z < 1: + if track_map.altitude(ego.track_mode)-ego.z > -1 and track_map.altitude(ego.track_mode)-ego.z < 1: next.craft_mode = CraftMode.Normal - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): - next.track_mode = lane_map.h( + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.Normal) assert not any(ego.x-other.x < 1 and ego.x-other.x >-1 and \ diff --git a/demo/tacas2023/exp10/quadrotor_controller4.py b/demo/tacas2023/exp10/quadrotor_controller4.py index b40d4d9f6d2af1899ae92d6a98b43f66269fb8aa..419fe3247960e1790141e2f76b084ce9b3589d92 100644 --- a/demo/tacas2023/exp10/quadrotor_controller4.py +++ b/demo/tacas2023/exp10/quadrotor_controller4.py @@ -33,6 +33,6 @@ class State: pass -def controller(ego: State, others: List[State], lane_map): +def decisionLogic(ego: State, others: List[State], track_map): output = copy.deepcopy(ego) return output diff --git a/demo/tacas2023/exp11/decision_logic/inc-expr-fsw4.py b/demo/tacas2023/exp11/decision_logic/inc-expr-fsw4.py index 5947ad25b0e10b60f03e458ac6267159a1acea90..399702b82a01fe59c5603404ff166e40484be4c4 100644 --- a/demo/tacas2023/exp11/decision_logic/inc-expr-fsw4.py +++ b/demo/tacas2023/exp11/decision_logic/inc-expr-fsw4.py @@ -40,48 +40,48 @@ class State: track_mode: TrackMode = TrackMode.T0 type: LaneObjectMode = LaneObjectMode.Vehicle -def car_front(ego, others, lane_map, thresh_far, thresh_close): - return any((lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > thresh_close \ - and lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < thresh_far \ +def car_front(ego, others, track_map, thresh_far, thresh_close): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > thresh_close \ + and track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < thresh_far \ and ego.track_mode == other.track_mode) for other in others) -def car_left(ego, others, lane_map): - return any((lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ - lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ - other.track_mode==lane_map.left_lane(ego.track_mode)) for other in others) +def car_left(ego, others, track_map): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ + track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ + other.track_mode==track_map.left_lane(ego.track_mode)) for other in others) -def car_right(ego, others, lane_map): - return any((lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ - lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ - other.track_mode==lane_map.right_lane(ego.track_mode)) for other in others) +def car_right(ego, others, track_map): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ + track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ + other.track_mode==track_map.right_lane(ego.track_mode)) for other in others) -def controller(ego:State, others:List[State], lane_map): +def decisionLogic(ego:State, others:List[State], track_map): output = copy.deepcopy(ego) if ego.agent_mode == AgentMode.Normal: - if car_front(ego, others, lane_map, 4.5, 3): + if car_front(ego, others, track_map, 4.5, 3): # Switch left if left lane is empty - if lane_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) and \ - not car_left(ego, others, lane_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) and \ + not car_left(ego, others, track_map): output.agent_mode = AgentMode.SwitchLeft - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) # Switch right if right lane is empty - if lane_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) and \ - not car_right(ego, others, lane_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) and \ + not car_right(ego, others, track_map): output.agent_mode = AgentMode.SwitchRight - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) # If switched left enough, return to normal mode if ego.agent_mode == AgentMode.SwitchLeft: - if lane_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) >= (lane_map.get_lane_width(ego.track_mode)-0.2): + if track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) >= (track_map.get_lane_width(ego.track_mode)-0.2): output.agent_mode = AgentMode.Normal - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) # If switched right enough,return to normal mode if ego.agent_mode == AgentMode.SwitchRight: - if lane_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) <= -(lane_map.get_lane_width(ego.track_mode)-0.2): + if track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) <= -(track_map.get_lane_width(ego.track_mode)-0.2): output.agent_mode = AgentMode.Normal - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) return output diff --git a/demo/tacas2023/exp11/decision_logic/inc-expr-fsw7.py b/demo/tacas2023/exp11/decision_logic/inc-expr-fsw7.py index ed5e4b4957035fc8a957014108a4a589ce46d8e4..216bc3e1de80d40bd23c1a7346715779fca0b4aa 100644 --- a/demo/tacas2023/exp11/decision_logic/inc-expr-fsw7.py +++ b/demo/tacas2023/exp11/decision_logic/inc-expr-fsw7.py @@ -40,48 +40,48 @@ class State: track_mode: TrackMode = TrackMode.T0 type: LaneObjectMode = LaneObjectMode.Vehicle -def car_front(ego, others, lane_map, thresh_far, thresh_close): - return any((lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > thresh_close \ - and lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < thresh_far \ +def car_front(ego, others, track_map, thresh_far, thresh_close): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > thresh_close \ + and track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < thresh_far \ and ego.track_mode == other.track_mode) for other in others) -def car_left(ego, others, lane_map): - return any((lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ - lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ - other.track_mode==lane_map.left_lane(ego.track_mode)) for other in others) +def car_left(ego, others, track_map): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ + track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ + other.track_mode==track_map.left_lane(ego.track_mode)) for other in others) -def car_right(ego, others, lane_map): - return any((lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ - lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ - other.track_mode==lane_map.right_lane(ego.track_mode)) for other in others) +def car_right(ego, others, track_map): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ + track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ + other.track_mode==track_map.right_lane(ego.track_mode)) for other in others) -def controller(ego:State, others:List[State], lane_map): +def decisionLogic(ego:State, others:List[State], track_map): output = copy.deepcopy(ego) if ego.agent_mode == AgentMode.Normal: - if car_front(ego, others, lane_map, 7, 3): + if car_front(ego, others, track_map, 7, 3): # Switch left if left lane is empty - if lane_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) and \ - not car_left(ego, others, lane_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) and \ + not car_left(ego, others, track_map): output.agent_mode = AgentMode.SwitchLeft - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) # Switch right if right lane is empty - if lane_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) and \ - not car_right(ego, others, lane_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) and \ + not car_right(ego, others, track_map): output.agent_mode = AgentMode.SwitchRight - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) # If switched left enough, return to normal mode if ego.agent_mode == AgentMode.SwitchLeft: - if lane_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) >= (lane_map.get_lane_width(ego.track_mode)-0.2): + if track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) >= (track_map.get_lane_width(ego.track_mode)-0.2): output.agent_mode = AgentMode.Normal - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) # If switched right enough,return to normal mode if ego.agent_mode == AgentMode.SwitchRight: - if lane_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) <= -(lane_map.get_lane_width(ego.track_mode)-0.2): + if track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) <= -(track_map.get_lane_width(ego.track_mode)-0.2): output.agent_mode = AgentMode.Normal - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) return output diff --git a/demo/tacas2023/exp11/decision_logic/inc-expr.py b/demo/tacas2023/exp11/decision_logic/inc-expr.py index 4787c47500b5dbf1c2a2f12d7a78444fbdb5c172..c70525e49149a34e41619a53ba1ad417718ce7bf 100644 --- a/demo/tacas2023/exp11/decision_logic/inc-expr.py +++ b/demo/tacas2023/exp11/decision_logic/inc-expr.py @@ -40,48 +40,48 @@ class State: track_mode: TrackMode = TrackMode.T0 type: LaneObjectMode = LaneObjectMode.Vehicle -def car_front(ego, others, lane_map, thresh_far, thresh_close): - return any((lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > thresh_close \ - and lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < thresh_far \ +def car_front(ego, others, track_map, thresh_far, thresh_close): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > thresh_close \ + and track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < thresh_far \ and ego.track_mode == other.track_mode) for other in others) -def car_left(ego, others, lane_map): - return any((lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ - lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ - other.track_mode==lane_map.left_lane(ego.track_mode)) for other in others) +def car_left(ego, others, track_map): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ + track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ + other.track_mode==track_map.left_lane(ego.track_mode)) for other in others) -def car_right(ego, others, lane_map): - return any((lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ - lane_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ - other.track_mode==lane_map.right_lane(ego.track_mode)) for other in others) +def car_right(ego, others, track_map): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ + track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ + other.track_mode==track_map.right_lane(ego.track_mode)) for other in others) -def controller(ego:State, others:List[State], lane_map): +def decisionLogic(ego:State, others:List[State], track_map): output = copy.deepcopy(ego) if ego.agent_mode == AgentMode.Normal: - if car_front(ego, others, lane_map, 5, 3): + if car_front(ego, others, track_map, 5, 3): # Switch left if left lane is empty - if lane_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) and \ - not car_left(ego, others, lane_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) and \ + not car_left(ego, others, track_map): output.agent_mode = AgentMode.SwitchLeft - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) # Switch right if right lane is empty - if lane_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) and \ - not car_right(ego, others, lane_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) and \ + not car_right(ego, others, track_map): output.agent_mode = AgentMode.SwitchRight - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) # If switched left enough, return to normal mode if ego.agent_mode == AgentMode.SwitchLeft: - if lane_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) >= (lane_map.get_lane_width(ego.track_mode)-0.2): + if track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) >= (track_map.get_lane_width(ego.track_mode)-0.2): output.agent_mode = AgentMode.Normal - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) # If switched right enough,return to normal mode if ego.agent_mode == AgentMode.SwitchRight: - if lane_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) <= -(lane_map.get_lane_width(ego.track_mode)-0.2): + if track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) <= -(track_map.get_lane_width(ego.track_mode)-0.2): output.agent_mode = AgentMode.Normal - output.track_mode = lane_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) return output diff --git a/demo/tacas2023/exp2/demo9.py b/demo/tacas2023/exp2/demo9.py index 19af198139a148030088b824377fbff79f87a155..a0b657662316bb6dea9179eefb1f983bd10e7f9f 100644 --- a/demo/tacas2023/exp2/demo9.py +++ b/demo/tacas2023/exp2/demo9.py @@ -21,7 +21,7 @@ class LaneObjectMode(Enum): Obstacle = auto() # Static (to road/lane) obstacles -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -43,10 +43,10 @@ class State: y: float theta: float v: float - agent_mode: VehicleMode - lane_mode: TrackMode + agent_mode: AgentMode + track_mode: TrackMode - def __init__(self, x, y, theta, v, agent_mode: VehicleMode, lane_mode: TrackMode): + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): pass @@ -69,9 +69,9 @@ if __name__ == "__main__": [[4-2.5, 2.8, 0, 1.0], [4.5-2.5, 3.2, 0, 1.0]], ], [ - (VehicleMode.Normal, TrackMode.T1), - (VehicleMode.Normal, TrackMode.T1), - (VehicleMode.Normal, TrackMode.T0), + (AgentMode.Normal, TrackMode.T1), + (AgentMode.Normal, TrackMode.T1), + (AgentMode.Normal, TrackMode.T0), ] ) diff --git a/demo/tacas2023/exp2/example_controller5.py b/demo/tacas2023/exp2/example_controller5.py index d969dc5115959c2b5db2a54f394395f93eb1c661..82a9e51674a9465488a56a33ae826ecc573b92d9 100644 --- a/demo/tacas2023/exp2/example_controller5.py +++ b/demo/tacas2023/exp2/example_controller5.py @@ -9,7 +9,7 @@ class LaneObjectMode(Enum): Signal = auto() # Traffic lights Obstacle = auto() # Static (to road/lane) obstacles -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -29,42 +29,42 @@ class State: y:float theta:float v:float - agent_mode:VehicleMode - lane_mode:TrackMode + agent_mode:AgentMode + track_mode:TrackMode - def __init__(self, x, y, theta, v, agent_mode: VehicleMode, lane_mode: TrackMode): + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): pass -def vehicle_front(ego, others, lane_map): - res = any((lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) > 3 \ - and lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) < 5 \ - and ego.lane_mode == other.lane_mode) for other in others) +def vehicle_front(ego, others, track_map): + res = any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > 3 \ + and track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 5 \ + and ego.track_mode == other.track_mode) for other in others) return res def vehicle_close(ego, others): res = any(ego.x-other.x<1.0 and ego.x-other.x>-1.0 and ego.y-other.y<1.0 and ego.y-other.y>-1.0 for other in others) return res -def controller(ego:State, others:List[State], lane_map): +def decisionLogic(ego:State, others:List[State], track_map): output = copy.deepcopy(ego) - if ego.agent_mode == VehicleMode.Normal: - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft): - output.agent_mode = VehicleMode.SwitchLeft - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft) - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight): - output.agent_mode = VehicleMode.SwitchRight - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight) - lat_dist = lane_map.get_lateral_distance(ego.lane_mode, [ego.x, ego.y]) - if ego.agent_mode == VehicleMode.SwitchLeft: + if ego.agent_mode == AgentMode.Normal: + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft): + output.agent_mode = AgentMode.SwitchLeft + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight): + output.agent_mode = AgentMode.SwitchRight + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) + lat_dist = track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) + if ego.agent_mode == AgentMode.SwitchLeft: if lat_dist >= 2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) - if ego.agent_mode == VehicleMode.SwitchRight: + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + if ego.agent_mode == AgentMode.SwitchRight: if lat_dist <= -2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) assert not vehicle_close(ego, others), "Seperation" return output diff --git a/demo/tacas2023/exp3/demo6.py b/demo/tacas2023/exp3/demo6.py index 8950e7109a0a83a23ae514be72f5aea78aa3ab39..a2ca3ff3d173841ed1a76a9e7b05a5489ee3b0ea 100644 --- a/demo/tacas2023/exp3/demo6.py +++ b/demo/tacas2023/exp3/demo6.py @@ -7,7 +7,7 @@ from enum import Enum, auto import plotly.graph_objects as go -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -61,13 +61,13 @@ if __name__ == "__main__": [[40, -6.1, 0, 0.5], [40, -5.9, 0, 0.5]], ], [ - (VehicleMode.Normal, TrackMode.T1), - (VehicleMode.Normal, TrackMode.T1), - (VehicleMode.Normal, TrackMode.T0), - (VehicleMode.Normal, TrackMode.T0), - (VehicleMode.Normal, TrackMode.T1), - (VehicleMode.Normal, TrackMode.T2), - (VehicleMode.Normal, TrackMode.T3), + (AgentMode.Normal, TrackMode.T1), + (AgentMode.Normal, TrackMode.T1), + (AgentMode.Normal, TrackMode.T0), + (AgentMode.Normal, TrackMode.T0), + (AgentMode.Normal, TrackMode.T1), + (AgentMode.Normal, TrackMode.T2), + (AgentMode.Normal, TrackMode.T3), ] ) diff --git a/demo/tacas2023/exp3/example_controller7.py b/demo/tacas2023/exp3/example_controller7.py index 613fba24f00f561e14836e00e5e24c7087ff986b..23941f1c074e5157d0675e6f226c411064c36ba9 100644 --- a/demo/tacas2023/exp3/example_controller7.py +++ b/demo/tacas2023/exp3/example_controller7.py @@ -2,7 +2,7 @@ from enum import Enum, auto import copy from typing import List -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -28,48 +28,48 @@ class State: y:float theta:float v:float - agent_mode:VehicleMode - lane_mode:TrackMode + agent_mode:AgentMode + track_mode:TrackMode - def __init__(self, x, y, theta, v, agent_mode: VehicleMode, lane_mode: TrackMode): + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): pass -def car_front(ego, others, lane_map): - return any((lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) > 3 \ - and lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) < 5 \ - and ego.lane_mode == other.lane_mode) for other in others) +def car_front(ego, others, track_map): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > 3 \ + and track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 5 \ + and ego.track_mode == other.track_mode) for other in others) -def car_left(ego, others, lane_map): - return any((lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) < 8 and \ - lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) >-3 and \ - other.lane_mode==lane_map.left_lane(ego.lane_mode)) for other in others) +def car_left(ego, others, track_map): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ + track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ + other.track_mode==track_map.left_lane(ego.track_mode)) for other in others) -def car_right(ego, others, lane_map): - return any((lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) < 8 and \ - lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) >-3 and \ - other.lane_mode==lane_map.right_lane(ego.lane_mode)) for other in others) +def car_right(ego, others, track_map): + return any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 8 and \ + track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) >-3 and \ + other.track_mode==track_map.right_lane(ego.track_mode)) for other in others) -def controller(ego:State, others:List[State], lane_map): +def decisionLogic(ego:State, others:List[State], track_map): output = copy.deepcopy(ego) - if ego.agent_mode == VehicleMode.Normal: - if car_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft) and \ - not car_left(ego, others, lane_map): - output.agent_mode = VehicleMode.SwitchLeft - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft) - if car_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight) and \ - not car_right(ego, others, lane_map): - output.agent_mode = VehicleMode.SwitchRight - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight) - if ego.agent_mode == VehicleMode.SwitchLeft: - if lane_map.get_lateral_distance(ego.lane_mode, [ego.x, ego.y]) >= 2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) - if ego.agent_mode == VehicleMode.SwitchRight: - if lane_map.get_lateral_distance(ego.lane_mode, [ego.x, ego.y]) <= -2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) + if ego.agent_mode == AgentMode.Normal: + if car_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) and \ + not car_left(ego, others, track_map): + output.agent_mode = AgentMode.SwitchLeft + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) + if car_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) and \ + not car_right(ego, others, track_map): + output.agent_mode = AgentMode.SwitchRight + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) + if ego.agent_mode == AgentMode.SwitchLeft: + if track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) >= 2.5: + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + if ego.agent_mode == AgentMode.SwitchRight: + if track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) <= -2.5: + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) return output diff --git a/demo/tacas2023/exp4/demo11.py b/demo/tacas2023/exp4/demo11.py index 1d5d4cc38fd8db5c970d68bb7f96bd187f2ab16f..301a3031d3d3e241549edd076a939c5de8ab5162 100644 --- a/demo/tacas2023/exp4/demo11.py +++ b/demo/tacas2023/exp4/demo11.py @@ -10,7 +10,7 @@ import plotly.graph_objects as go import matplotlib.pyplot as plt -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -46,9 +46,9 @@ if __name__ == "__main__": [[4-2.5, 2.8, 0, 1.0], [4.5-2.5, 3.2, 0, 1.0]], ], [ - (VehicleMode.Normal, TrackMode.T1), - (VehicleMode.Normal, TrackMode.T1), - (VehicleMode.Normal, TrackMode.T0), + (AgentMode.Normal, TrackMode.T1), + (AgentMode.Normal, TrackMode.T1), + (AgentMode.Normal, TrackMode.T0), ] ) scenario.set_sensor(NoisyVehicleSensor((0.5, 0.5), (0.5, 0.5))) @@ -76,9 +76,9 @@ if __name__ == "__main__": [[4-2.5, 2.8, 0, 1.0], [4.5-2.5, 3.2, 0, 1.0]], ], [ - (VehicleMode.Normal, TrackMode.T1), - (VehicleMode.Normal, TrackMode.T1), - (VehicleMode.Normal, TrackMode.T0), + (AgentMode.Normal, TrackMode.T1), + (AgentMode.Normal, TrackMode.T1), + (AgentMode.Normal, TrackMode.T0), ] ) diff --git a/demo/tacas2023/exp4/example_controller5.py b/demo/tacas2023/exp4/example_controller5.py index e40fd144abb7f98058b498c56ae0824a9fe1a219..07347d3a9526315088f42410a9cc2d12cf0accb8 100644 --- a/demo/tacas2023/exp4/example_controller5.py +++ b/demo/tacas2023/exp4/example_controller5.py @@ -9,7 +9,7 @@ class LaneObjectMode(Enum): Signal = auto() # Traffic lights Obstacle = auto() # Static (to road/lane) obstacles -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -29,42 +29,42 @@ class State: y:float theta:float v:float - agent_mode:VehicleMode - lane_mode:TrackMode + agent_mode:AgentMode + track_mode:TrackMode - def __init__(self, x, y, theta, v, agent_mode: VehicleMode, lane_mode: TrackMode): + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): pass -def vehicle_front(ego, others, lane_map): - res = any((lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) > 3 \ - and lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) < 5 \ - and ego.lane_mode == other.lane_mode) for other in others) +def vehicle_front(ego, others, track_map): + res = any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > 3 \ + and track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 5 \ + and ego.track_mode == other.track_mode) for other in others) return res def vehicle_close(ego, others): res = any(ego.x-other.x<1.0 and ego.x-other.x>-1.0 and ego.y-other.y<1.0 and ego.y-other.y>-1.0 for other in others) return res -def controller(ego:State, others:List[State], lane_map): +def decisionLogic(ego:State, others:List[State], track_map): output = copy.deepcopy(ego) - if ego.agent_mode == VehicleMode.Normal: - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft): - output.agent_mode = VehicleMode.SwitchLeft - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft) - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight): - output.agent_mode = VehicleMode.SwitchRight - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight) - lat_dist = lane_map.get_lateral_distance(ego.lane_mode, [ego.x, ego.y]) - if ego.agent_mode == VehicleMode.SwitchLeft: + if ego.agent_mode == AgentMode.Normal: + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft): + output.agent_mode = AgentMode.SwitchLeft + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight): + output.agent_mode = AgentMode.SwitchRight + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) + lat_dist = track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) + if ego.agent_mode == AgentMode.SwitchLeft: if lat_dist >= 2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) - if ego.agent_mode == VehicleMode.SwitchRight: + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + if ego.agent_mode == AgentMode.SwitchRight: if lat_dist <= -2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) assert not vehicle_close(ego, others) return output diff --git a/demo/tacas2023/exp4/noisy_sensor.py b/demo/tacas2023/exp4/noisy_sensor.py index 288e9c32d785ff0bfb8f1b6f92f9524337e92a99..5dd6eb3b25e94e9010c5e6ca82eae90e232ff80d 100644 --- a/demo/tacas2023/exp4/noisy_sensor.py +++ b/demo/tacas2023/exp4/noisy_sensor.py @@ -7,8 +7,8 @@ class NoisyVehicleSensor(BaseSensor): self.noise_x = noise_x self.noise_y = noise_y - def sense(self, scenario, agent, state_dict, lane_map): - cont, disc, len_dict = super().sense(scenario, agent, state_dict, lane_map) + def sense(self, scenario, agent, state_dict, track_map): + cont, disc, len_dict = super().sense(scenario, agent, state_dict, track_map) tmp = np.array(list(state_dict.values())[0][0]) if tmp.ndim<2: return cont, disc, len_dict diff --git a/demo/tacas2023/exp5/demo_opendrive2.py b/demo/tacas2023/exp5/demo_opendrive2.py index b6b19ab1d99d58658aa27ce8e7752ff38e75a2da..d6c060f7c57ab7b807ad1d7d193a93ca7cbf213f 100644 --- a/demo/tacas2023/exp5/demo_opendrive2.py +++ b/demo/tacas2023/exp5/demo_opendrive2.py @@ -15,7 +15,7 @@ class LaneObjectMode(Enum): Obstacle = auto() # Static (to road/lane) obstacles -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -52,9 +52,9 @@ if __name__ == "__main__": # [[106, 18.0, 0, 2.0], [106, 18.0, 0, 2.0]], ], [ - (VehicleMode.Normal, TrackMode.T1, ), - (VehicleMode.Normal, TrackMode.T1, ), - (VehicleMode.Normal, TrackMode.T2, ), + (AgentMode.Normal, TrackMode.T1, ), + (AgentMode.Normal, TrackMode.T1, ), + (AgentMode.Normal, TrackMode.T2, ), ] ) scenario.init_seg_length = 1 diff --git a/demo/tacas2023/exp5/example_controller5.py b/demo/tacas2023/exp5/example_controller5.py index 11b2e983e2abd5e5a908465cca67e46a764d39b7..846cda0fce0c5dd631c086c17f93a6df528e191a 100644 --- a/demo/tacas2023/exp5/example_controller5.py +++ b/demo/tacas2023/exp5/example_controller5.py @@ -9,7 +9,7 @@ class LaneObjectMode(Enum): Signal = auto() # Traffic lights Obstacle = auto() # Static (to road/lane) obstacles -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -29,42 +29,42 @@ class State: y:float theta:float v:float - agent_mode:VehicleMode - lane_mode:TrackMode + agent_mode:AgentMode + track_mode:TrackMode - def __init__(self, x, y, theta, v, agent_mode: VehicleMode, lane_mode: TrackMode): + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): pass -def vehicle_front(ego, others, lane_map): - res = any((lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) > 3 \ - and lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) < 5 \ - and ego.lane_mode == other.lane_mode) for other in others) +def vehicle_front(ego, others, track_map): + res = any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > 3 \ + and track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 5 \ + and ego.track_mode == other.track_mode) for other in others) return res def vehicle_close(ego, others): res = any(ego.x-other.x<1.0 and ego.x-other.x>-1.0 and ego.y-other.y<1.0 and ego.y-other.y>-1.0 for other in others) return res -def controller(ego:State, others:List[State], lane_map): +def decisionLogic(ego:State, others:List[State], track_map): output = copy.deepcopy(ego) - if ego.agent_mode == VehicleMode.Normal: - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft): - output.agent_mode = VehicleMode.SwitchLeft - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft) - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight): - output.agent_mode = VehicleMode.SwitchRight - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight) - lat_dist = lane_map.get_lateral_distance(ego.lane_mode, [ego.x, ego.y]) - if ego.agent_mode == VehicleMode.SwitchLeft: + if ego.agent_mode == AgentMode.Normal: + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft): + output.agent_mode = AgentMode.SwitchLeft + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight): + output.agent_mode = AgentMode.SwitchRight + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) + lat_dist = track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) + if ego.agent_mode == AgentMode.SwitchLeft: if lat_dist >= 2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) - if ego.agent_mode == VehicleMode.SwitchRight: + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + if ego.agent_mode == AgentMode.SwitchRight: if lat_dist <= -2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) # assert not vehicle_close(ego, others) return output diff --git a/demo/tacas2023/exp6/demo3.py b/demo/tacas2023/exp6/demo3.py index ce8c6dab84bdb3e675d75f341abe0ada493cae46..950135a5362c31826ae0001c88044ff6051ffb79 100644 --- a/demo/tacas2023/exp6/demo3.py +++ b/demo/tacas2023/exp6/demo3.py @@ -7,7 +7,7 @@ from verse.plotter.plotter2D import * import plotly.graph_objects as go -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -29,11 +29,11 @@ if __name__ == "__main__": scenario = Scenario() scenario.add_agent(CarAgent('car1', file_name=input_code_name, initial_state=[ - [0, -0.5, 0, 1.0], [0.01, 0.5, 0, 1.0]], initial_mode=(VehicleMode.Normal, TrackMode.T1))) + [0, -0.5, 0, 1.0], [0.01, 0.5, 0, 1.0]], initial_mode=(AgentMode.Normal, TrackMode.T1))) scenario.add_agent(NPCAgent('car2', initial_state=[ - [15, -0.3, 0, 0.5], [15, 0.3, 0, 0.5]], initial_mode=(VehicleMode.Normal, TrackMode.T1))) - # scenario.add_agent(NPCAgent('car3', initial_state=[[35, -3.3, 0, 0.5], [35, -2.7, 0, 0.5]], initial_mode=(VehicleMode.Normal, TrackMode.T2))) - # scenario.add_agent(NPCAgent('car4', initial_state=[[30, -0.5, 0, 0.5], [30, 0.5, 0, 0.5]], initial_mode=(VehicleMode.Normal, TrackMode.T1))) + [15, -0.3, 0, 0.5], [15, 0.3, 0, 0.5]], initial_mode=(AgentMode.Normal, TrackMode.T1))) + # scenario.add_agent(NPCAgent('car3', initial_state=[[35, -3.3, 0, 0.5], [35, -2.7, 0, 0.5]], initial_mode=(AgentMode.Normal, TrackMode.T2))) + # scenario.add_agent(NPCAgent('car4', initial_state=[[30, -0.5, 0, 0.5], [30, 0.5, 0, 0.5]], initial_mode=(AgentMode.Normal, TrackMode.T1))) tmp_map = SimpleMap3() scenario.set_map(tmp_map) # traces = scenario.simulate(70, 0.05) diff --git a/demo/tacas2023/exp6/example_controller4.py b/demo/tacas2023/exp6/example_controller4.py index 11b2e983e2abd5e5a908465cca67e46a764d39b7..846cda0fce0c5dd631c086c17f93a6df528e191a 100644 --- a/demo/tacas2023/exp6/example_controller4.py +++ b/demo/tacas2023/exp6/example_controller4.py @@ -9,7 +9,7 @@ class LaneObjectMode(Enum): Signal = auto() # Traffic lights Obstacle = auto() # Static (to road/lane) obstacles -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -29,42 +29,42 @@ class State: y:float theta:float v:float - agent_mode:VehicleMode - lane_mode:TrackMode + agent_mode:AgentMode + track_mode:TrackMode - def __init__(self, x, y, theta, v, agent_mode: VehicleMode, lane_mode: TrackMode): + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): pass -def vehicle_front(ego, others, lane_map): - res = any((lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) > 3 \ - and lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) < 5 \ - and ego.lane_mode == other.lane_mode) for other in others) +def vehicle_front(ego, others, track_map): + res = any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > 3 \ + and track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 5 \ + and ego.track_mode == other.track_mode) for other in others) return res def vehicle_close(ego, others): res = any(ego.x-other.x<1.0 and ego.x-other.x>-1.0 and ego.y-other.y<1.0 and ego.y-other.y>-1.0 for other in others) return res -def controller(ego:State, others:List[State], lane_map): +def decisionLogic(ego:State, others:List[State], track_map): output = copy.deepcopy(ego) - if ego.agent_mode == VehicleMode.Normal: - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft): - output.agent_mode = VehicleMode.SwitchLeft - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft) - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight): - output.agent_mode = VehicleMode.SwitchRight - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight) - lat_dist = lane_map.get_lateral_distance(ego.lane_mode, [ego.x, ego.y]) - if ego.agent_mode == VehicleMode.SwitchLeft: + if ego.agent_mode == AgentMode.Normal: + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft): + output.agent_mode = AgentMode.SwitchLeft + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight): + output.agent_mode = AgentMode.SwitchRight + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) + lat_dist = track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) + if ego.agent_mode == AgentMode.SwitchLeft: if lat_dist >= 2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) - if ego.agent_mode == VehicleMode.SwitchRight: + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + if ego.agent_mode == AgentMode.SwitchRight: if lat_dist <= -2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) # assert not vehicle_close(ego, others) return output diff --git a/demo/tacas2023/exp7/uncertain_agents.py b/demo/tacas2023/exp7/uncertain_agents.py index cc15440b95acd5626c9a2891d9672d3ee3b88c4d..8059963bbc1148fecf0e83f08dd57f7d8dda251a 100644 --- a/demo/tacas2023/exp7/uncertain_agents.py +++ b/demo/tacas2023/exp7/uncertain_agents.py @@ -4,7 +4,7 @@ import numpy as np from scipy.integrate import ode from verse.agents import BaseAgent -from verse.parser import ControllerIR +from verse.parser import controllerIR from scipy.optimize import minimize from sympy import Symbol, diff @@ -62,7 +62,7 @@ def computeD(exprs, symbol_x, symbol_w, x, w, x_hat, w_hat): class Agent1(BaseAgent): def __init__(self, id): self.id = id - self.controller = ControllerIR.empty() + self.controller = controllerIR.empty() def dynamics(self, x, args): w1, w2, dt = args @@ -90,7 +90,7 @@ class Agent1(BaseAgent): class Agent2(BaseAgent): def __init__(self, id): self.id = id - self.controller = ControllerIR.empty() + self.controller = controllerIR.empty() def dynamics(self, x, args): w1, w2, dt = args @@ -118,7 +118,7 @@ class Agent2(BaseAgent): class Agent3(BaseAgent): def __init__(self, id): self.id = id - self.controller = ControllerIR.empty() + self.controller = controllerIR.empty() def dynamics(self, x, args): w1, w2, dt = args @@ -132,7 +132,7 @@ class Agent3(BaseAgent): class Agent4(BaseAgent): def __init__(self, id): self.id = id - self.controller = ControllerIR.empty() + self.controller = controllerIR.empty() def dynamics(self, x, args): w1, dt = args @@ -164,7 +164,7 @@ class Agent5(BaseAgent): def __init__(self, id): # super().__init__(id, code, file_name) self.id = id - self.controller = ControllerIR.empty() + self.controller = controllerIR.empty() self.init_cont = None self.init_disc = None self.static_parameters = None @@ -213,7 +213,7 @@ class Agent6(BaseAgent): def __init__(self, id): # super().__init__(id, code, file_name) self.id = id - self.controller = ControllerIR.empty() + self.controller = controllerIR.empty() self.init_cont = None self.init_disc = None self.static_parameters = None diff --git a/demo/tacas2023/exp8/demo3.py b/demo/tacas2023/exp8/demo3.py index fe27b8e0755f6702dd37375115abec9a03d39aea..9b8195ee9a7bf9ac9a5866b7998bbefe5df3853d 100644 --- a/demo/tacas2023/exp8/demo3.py +++ b/demo/tacas2023/exp8/demo3.py @@ -7,7 +7,7 @@ from verse.plotter.plotter2D import * import plotly.graph_objects as go -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -29,11 +29,11 @@ if __name__ == "__main__": scenario = Scenario() scenario.add_agent(CarAgent('car1', file_name=input_code_name, initial_state=[ - [0, -0.5, 0, 1.0], [0.01, 0.5, 0, 1.0]], initial_mode=(VehicleMode.Normal, TrackMode.T1))) + [0, -0.5, 0, 1.0], [0.01, 0.5, 0, 1.0]], initial_mode=(AgentMode.Normal, TrackMode.T1))) scenario.add_agent(NPCAgent('car2', initial_state=[ - [10, -0.3, 0, 0.5], [10, 0.3, 0, 0.5]], initial_mode=(VehicleMode.Normal, TrackMode.T1))) - scenario.add_agent(NPCAgent('car3', initial_state=[[25, 2.7, 0, 0.5], [25, 3.3, 0, 0.5]], initial_mode=(VehicleMode.Normal, TrackMode.T0))) - # scenario.add_agent(NPCAgent('car4', initial_state=[[30, -0.5, 0, 0.5], [30, 0.5, 0, 0.5]], initial_mode=(VehicleMode.Normal, TrackMode.T1))) + [10, -0.3, 0, 0.5], [10, 0.3, 0, 0.5]], initial_mode=(AgentMode.Normal, TrackMode.T1))) + scenario.add_agent(NPCAgent('car3', initial_state=[[25, 2.7, 0, 0.5], [25, 3.3, 0, 0.5]], initial_mode=(AgentMode.Normal, TrackMode.T0))) + # scenario.add_agent(NPCAgent('car4', initial_state=[[30, -0.5, 0, 0.5], [30, 0.5, 0, 0.5]], initial_mode=(AgentMode.Normal, TrackMode.T1))) tmp_map = SimpleMap3() scenario.set_map(tmp_map) # traces = scenario.simulate(70, 0.05) diff --git a/demo/tacas2023/exp8/example_controller4.py b/demo/tacas2023/exp8/example_controller4.py index 5993198cd0f6d7f9455db90e274c5511c3a2ef97..aa1b1ef478c8bff089d4eb1a5605e777d8c563db 100644 --- a/demo/tacas2023/exp8/example_controller4.py +++ b/demo/tacas2023/exp8/example_controller4.py @@ -2,7 +2,7 @@ from enum import Enum, auto import copy from typing import List -from verse.map.lane_map import LaneMap +from verse.map.track_map import LaneMap class LaneObjectMode(Enum): Vehicle = auto() @@ -11,7 +11,7 @@ class LaneObjectMode(Enum): Signal = auto() # Traffic lights Obstacle = auto() # Static (to road/lane) obstacles -class VehicleMode(Enum): +class AgentMode(Enum): Normal = auto() SwitchLeft = auto() SwitchRight = auto() @@ -31,16 +31,16 @@ class State: y:float theta:float v:float - agent_mode:VehicleMode - lane_mode:TrackMode + agent_mode:AgentMode + track_mode:TrackMode - def __init__(self, x, y, theta, v, agent_mode: VehicleMode, lane_mode: TrackMode): + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): pass -def vehicle_front(ego, others, lane_map): - res = any((lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) > 3 \ - and lane_map.get_longitudinal_position(other.lane_mode, [other.x,other.y]) - lane_map.get_longitudinal_position(ego.lane_mode, [ego.x,ego.y]) < 5 \ - and ego.lane_mode == other.lane_mode) for other in others) +def vehicle_front(ego, others, track_map): + res = any((track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) > 3 \ + and track_map.get_longitudinal_position(other.track_mode, [other.x,other.y]) - track_map.get_longitudinal_position(ego.track_mode, [ego.x,ego.y]) < 5 \ + and ego.track_mode == other.track_mode) for other in others) return res def vehicle_close(ego, others): @@ -48,29 +48,29 @@ def vehicle_close(ego, others): return res def enter_unsafe_region(ego): - res = (ego.x > 30 and ego.x<40 and ego.lane_mode == TrackMode.T2) + res = (ego.x > 30 and ego.x<40 and ego.track_mode == TrackMode.T2) return res -def controller(ego:State, others:List[State], lane_map): +def decisionLogic(ego:State, others:List[State], track_map): output = copy.deepcopy(ego) - if ego.agent_mode == VehicleMode.Normal: - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft): - output.agent_mode = VehicleMode.SwitchLeft - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchLeft) - if vehicle_front(ego, others, lane_map): - if lane_map.h_exist(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight): - output.agent_mode = VehicleMode.SwitchRight - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.SwitchRight) - lat_dist = lane_map.get_lateral_distance(ego.lane_mode, [ego.x, ego.y]) - if ego.agent_mode == VehicleMode.SwitchLeft: + if ego.agent_mode == AgentMode.Normal: + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft): + output.agent_mode = AgentMode.SwitchLeft + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) + if vehicle_front(ego, others, track_map): + if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight): + output.agent_mode = AgentMode.SwitchRight + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) + lat_dist = track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y]) + if ego.agent_mode == AgentMode.SwitchLeft: if lat_dist >= 2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) - if ego.agent_mode == VehicleMode.SwitchRight: + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) + if ego.agent_mode == AgentMode.SwitchRight: if lat_dist <= -2.5: - output.agent_mode = VehicleMode.Normal - output.lane_mode = lane_map.h(ego.lane_mode, ego.agent_mode, VehicleMode.Normal) + output.agent_mode = AgentMode.Normal + output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) assert not enter_unsafe_region(ego), 'Unsafe Region' assert not vehicle_close(ego, others), 'Safe Seperation' diff --git a/demo/tacas2023/exp9/quadrotor_agent.py b/demo/tacas2023/exp9/quadrotor_agent.py index 1956807673e1fd14cf23d3e111c783848b2db0df..0d92e3183ea80cd6326a58cf17fdffba37655d6f 100644 --- a/demo/tacas2023/exp9/quadrotor_agent.py +++ b/demo/tacas2023/exp9/quadrotor_agent.py @@ -8,7 +8,7 @@ import torch import math from verse.agents import BaseAgent from verse.map import LaneMap -from verse.map.lane_map_3d import LaneMap_3d +from verse.map.track_map_3d import LaneMap_3d class FFNNC(torch.nn.Module): diff --git a/demo/tacas2023/exp9/quadrotor_controller3.py b/demo/tacas2023/exp9/quadrotor_controller3.py index b5dcf6e3d5393f09cc6ed49f5e09f2d1b4c5da02..1d6c500d021f95a99e0c21a2c5ef2efc70d70173 100644 --- a/demo/tacas2023/exp9/quadrotor_controller3.py +++ b/demo/tacas2023/exp9/quadrotor_controller3.py @@ -46,32 +46,32 @@ def is_close(ego, other): return res -def controller(ego: State, others: List[State], lane_map): +def decisionLogic(ego: State, others: List[State], track_map): next = copy.deepcopy(ego) if ego.craft_mode == CraftMode.Normal: if any((is_close(ego, other) and ego.track_mode == other.track_mode) for other in others): - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveUp): + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveUp): next.craft_mode = CraftMode.MoveUp - next.track_mode = lane_map.h( + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.MoveUp) - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveDown): + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.MoveDown): next.craft_mode = CraftMode.MoveDown - next.track_mode = lane_map.h( + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.MoveDown) if ego.craft_mode == CraftMode.MoveUp: - if lane_map.altitude(ego.track_mode)-ego.z > -1 and lane_map.altitude(ego.track_mode)-ego.z < 1: + if track_map.altitude(ego.track_mode)-ego.z > -1 and track_map.altitude(ego.track_mode)-ego.z < 1: next.craft_mode = CraftMode.Normal - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): - next.track_mode = lane_map.h( + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.Normal) if ego.craft_mode == CraftMode.MoveDown: - if lane_map.altitude(ego.track_mode)-ego.z > -1 and lane_map.altitude(ego.track_mode)-ego.z < 1: + if track_map.altitude(ego.track_mode)-ego.z > -1 and track_map.altitude(ego.track_mode)-ego.z < 1: next.craft_mode = CraftMode.Normal - if lane_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): - next.track_mode = lane_map.h( + if track_map.h_exist(ego.track_mode, ego.craft_mode, CraftMode.Normal): + next.track_mode = track_map.h( ego.track_mode, ego.craft_mode, CraftMode.Normal) assert not any(ego.x-other.x < 1 and ego.x-other.x >-1 and \ diff --git a/demo/tacas2023/exp9/quadrotor_controller4.py b/demo/tacas2023/exp9/quadrotor_controller4.py index b40d4d9f6d2af1899ae92d6a98b43f66269fb8aa..419fe3247960e1790141e2f76b084ce9b3589d92 100644 --- a/demo/tacas2023/exp9/quadrotor_controller4.py +++ b/demo/tacas2023/exp9/quadrotor_controller4.py @@ -33,6 +33,6 @@ class State: pass -def controller(ego: State, others: List[State], lane_map): +def decisionLogic(ego: State, others: List[State], track_map): output = copy.deepcopy(ego) return output diff --git a/verse/automaton/guard.py b/verse/automaton/guard.py index 022bdb968fbd89c17b07ddc463c09b73d1ff1acd..d51fa68bdd612be8424127f1e5dd59d291536d66 100644 --- a/verse/automaton/guard.py +++ b/verse/automaton/guard.py @@ -1,3 +1,4 @@ +from pprint import pp from typing import Any import pickle import ast @@ -112,7 +113,7 @@ class GuardExpressionAst: cur_solver.add(eval(guard_str, globals(), self.varDict)) # TODO use an object instead of `eval` a string return cur_solver, symbols_map - def evaluate_guard_cont(self, agent, continuous_variable_dict, lane_map): + def evaluate_guard_cont(self, agent, continuous_variable_dict, track_map): res = False is_contained = False @@ -249,7 +250,7 @@ class GuardExpressionAst: expr = expr.strip('\n') return expr - def evaluate_guard_hybrid(self, agent, discrete_variable_dict, continuous_variable_dict, lane_map:LaneMap): + def evaluate_guard_hybrid(self, agent, discrete_variable_dict, continuous_variable_dict, track_map:LaneMap): """ Handle guard atomics that contains both continuous and hybrid variables Especially, we want to handle function calls that need both continuous and @@ -261,21 +262,21 @@ class GuardExpressionAst: """ res = True for i, node in enumerate(self.ast_list): - tmp, self.ast_list[i] = self._evaluate_guard_hybrid(node, agent, discrete_variable_dict, continuous_variable_dict, lane_map) + tmp, self.ast_list[i] = self._evaluate_guard_hybrid(node, agent, discrete_variable_dict, continuous_variable_dict, track_map) res = res and tmp return res - def _evaluate_guard_hybrid(self, root, agent, disc_var_dict, cont_var_dict, lane_map:LaneMap): + def _evaluate_guard_hybrid(self, root, agent, disc_var_dict, cont_var_dict, track_map:LaneMap): if isinstance(root, ast.Compare): expr = unparse(root) - left, root.left = self._evaluate_guard_hybrid(root.left, agent, disc_var_dict, cont_var_dict, lane_map) - right, root.comparators[0] = self._evaluate_guard_hybrid(root.comparators[0], agent, disc_var_dict, cont_var_dict, lane_map) + left, root.left = self._evaluate_guard_hybrid(root.left, agent, disc_var_dict, cont_var_dict, track_map) + right, root.comparators[0] = self._evaluate_guard_hybrid(root.comparators[0], agent, disc_var_dict, cont_var_dict, track_map) return True, root elif isinstance(root, ast.BoolOp): if isinstance(root.op, ast.And): res = True for i, val in enumerate(root.values): - tmp, root.values[i] = self._evaluate_guard_hybrid(val, agent, disc_var_dict, cont_var_dict, lane_map) + tmp, root.values[i] = self._evaluate_guard_hybrid(val, agent, disc_var_dict, cont_var_dict, track_map) res = res and tmp if not res: break @@ -283,17 +284,17 @@ class GuardExpressionAst: elif isinstance(root.op, ast.Or): res = False for val in root.values: - tmp,val = self._evaluate_guard_hybrid(val, agent, disc_var_dict, cont_var_dict, lane_map) + tmp,val = self._evaluate_guard_hybrid(val, agent, disc_var_dict, cont_var_dict, track_map) res = res or tmp return res, root elif isinstance(root, ast.BinOp): - left, root.left = self._evaluate_guard_hybrid(root.left, agent, disc_var_dict, cont_var_dict, lane_map) - right, root.right = self._evaluate_guard_hybrid(root.right, agent, disc_var_dict, cont_var_dict, lane_map) + left, root.left = self._evaluate_guard_hybrid(root.left, agent, disc_var_dict, cont_var_dict, track_map) + right, root.right = self._evaluate_guard_hybrid(root.right, agent, disc_var_dict, cont_var_dict, track_map) return True, root elif isinstance(root, ast.Call): if isinstance(root.func, ast.Attribute): func = root.func - if func.value.id == 'lane_map': + if 'map' in func.value.id: if func.attr == 'get_lateral_distance': # Get function arguments arg0_node = root.args[0] @@ -320,8 +321,8 @@ class GuardExpressionAst: vehicle_pos = (arg1_lower, arg1_upper) # Get corresponding lane segments with respect to the set of vehicle pos - lane_seg1 = lane_map.get_lane_segment(vehicle_lane, arg1_lower) - lane_seg2 = lane_map.get_lane_segment(vehicle_lane, arg1_upper) + lane_seg1 = track_map.get_lane_segment(vehicle_lane, arg1_lower) + lane_seg2 = track_map.get_lane_segment(vehicle_lane, arg1_upper) # Compute the set of possible lateral values with respect to all possible segments lateral_set1 = self._handle_lateral_set(lane_seg1, np.array(vehicle_pos)) @@ -364,8 +365,8 @@ class GuardExpressionAst: vehicle_pos = (arg1_lower, arg1_upper) # Get corresponding lane segments with respect to the set of vehicle pos - lane_seg1 = lane_map.get_lane_segment(vehicle_lane, arg1_lower) - lane_seg2 = lane_map.get_lane_segment(vehicle_lane, arg1_upper) + lane_seg1 = track_map.get_lane_segment(vehicle_lane, arg1_lower) + lane_seg2 = track_map.get_lane_segment(vehicle_lane, arg1_upper) # Compute the set of possible longitudinal values with respect to all possible segments longitudinal_set1 = self._handle_longitudinal_set(lane_seg1, np.array(vehicle_pos)) @@ -395,9 +396,9 @@ class GuardExpressionAst: return True, root elif isinstance(root, ast.UnaryOp): if isinstance(root.op, ast.USub): - res, root.operand = self._evaluate_guard_hybrid(root.operand, agent, disc_var_dict, cont_var_dict, lane_map) + res, root.operand = self._evaluate_guard_hybrid(root.operand, agent, disc_var_dict, cont_var_dict, track_map) elif isinstance(root.op, ast.Not): - res, root.operand = self._evaluate_guard_hybrid(root.operand, agent, disc_var_dict, cont_var_dict, lane_map) + res, root.operand = self._evaluate_guard_hybrid(root.operand, agent, disc_var_dict, cont_var_dict, track_map) if not res: root.operand = ast.parse('False').body[0].value return True, ast.parse('True').body[0].value @@ -487,19 +488,19 @@ class GuardExpressionAst: else: raise ValueError(f'Lane segment with type {lane_seg.type} is not supported') - def evaluate_guard_disc(self, agent, discrete_variable_dict, continuous_variable_dict, lane_map): + def evaluate_guard_disc(self, agent, discrete_variable_dict, continuous_variable_dict, track_map): """ Evaluate guard that involves only discrete variables. """ res = True for i, node in enumerate(self.ast_list): - tmp, self.ast_list[i] = self._evaluate_guard_disc(node, agent, discrete_variable_dict, continuous_variable_dict, lane_map) + tmp, self.ast_list[i] = self._evaluate_guard_disc(node, agent, discrete_variable_dict, continuous_variable_dict, track_map) res = res and tmp if not res: break return res - def _evaluate_guard_disc(self, root, agent:BaseAgent, disc_var_dict, cont_var_dict, lane_map): + def _evaluate_guard_disc(self, root, agent:BaseAgent, disc_var_dict, cont_var_dict, track_map): """ Recursively called function to evaluate guard with only discrete variables The function will evaluate all guards with discrete variables and replace the nodes with discrete guards by @@ -511,8 +512,8 @@ class GuardExpressionAst: """ if isinstance(root, ast.Compare): expr = unparse(root) - left, root.left = self._evaluate_guard_disc(root.left, agent, disc_var_dict, cont_var_dict, lane_map) - right, root.comparators[0] = self._evaluate_guard_disc(root.comparators[0], agent, disc_var_dict, cont_var_dict, lane_map) + left, root.left = self._evaluate_guard_disc(root.left, agent, disc_var_dict, cont_var_dict, track_map) + right, root.comparators[0] = self._evaluate_guard_disc(root.comparators[0], agent, disc_var_dict, cont_var_dict, track_map) if isinstance(left, bool) or isinstance(right, bool): return True, root if isinstance(root.ops[0], ast.GtE): @@ -538,7 +539,7 @@ class GuardExpressionAst: if isinstance(root.op, ast.And): res = True for i,val in enumerate(root.values): - tmp,root.values[i] = self._evaluate_guard_disc(val, agent, disc_var_dict, cont_var_dict, lane_map) + tmp,root.values[i] = self._evaluate_guard_disc(val, agent, disc_var_dict, cont_var_dict, track_map) res = res and tmp if not res: root = ast.Constant(value=False, kind=None) @@ -547,13 +548,13 @@ class GuardExpressionAst: elif isinstance(root.op, ast.Or): res = False for i, val in enumerate(root.values): - tmp,root.values[i] = self._evaluate_guard_disc(val, agent, disc_var_dict, cont_var_dict, lane_map) + tmp,root.values[i] = self._evaluate_guard_disc(val, agent, disc_var_dict, cont_var_dict, track_map) res = res or tmp return res, root elif isinstance(root, ast.BinOp): # Check left and right in the binop and replace all attributes involving discrete variables - left, root.left = self._evaluate_guard_disc(root.left, agent, disc_var_dict, cont_var_dict, lane_map) - right, root.right = self._evaluate_guard_disc(root.right, agent, disc_var_dict, cont_var_dict, lane_map) + left, root.left = self._evaluate_guard_disc(root.left, agent, disc_var_dict, cont_var_dict, track_map) + right, root.right = self._evaluate_guard_disc(root.right, agent, disc_var_dict, cont_var_dict, track_map) return True, root elif isinstance(root, ast.Call): expr = unparse(root) @@ -606,9 +607,9 @@ class GuardExpressionAst: return root.value, root elif isinstance(root, ast.UnaryOp): if isinstance(root.op, ast.USub): - res, root.operand = self._evaluate_guard_disc(root.operand, agent, disc_var_dict, cont_var_dict, lane_map) + res, root.operand = self._evaluate_guard_disc(root.operand, agent, disc_var_dict, cont_var_dict, track_map) elif isinstance(root.op, ast.Not): - res, root.operand = self._evaluate_guard_disc(root.operand, agent, disc_var_dict, cont_var_dict, lane_map) + res, root.operand = self._evaluate_guard_disc(root.operand, agent, disc_var_dict, cont_var_dict, track_map) if not res: root.operand = ast.parse('False').body[0].value return True, ast.parse('True').body[0].value @@ -631,19 +632,19 @@ class GuardExpressionAst: else: raise ValueError(f'Node type {root} from {unparse(root)} is not supported') - def evaluate_guard(self, agent, continuous_variable_dict, discrete_variable_dict, lane_map): + def evaluate_guard(self, agent, continuous_variable_dict, discrete_variable_dict, track_map): res = True for i, node in enumerate(self.ast_list): - tmp = self._evaluate_guard(node, agent, continuous_variable_dict, discrete_variable_dict, lane_map) + tmp = self._evaluate_guard(node, agent, continuous_variable_dict, discrete_variable_dict, track_map) res = tmp and res if not res: break return res - def _evaluate_guard(self, root, agent, cnts_var_dict, disc_var_dict, lane_map): + def _evaluate_guard(self, root, agent, cnts_var_dict, disc_var_dict, track_map): if isinstance(root, ast.Compare): - left = self._evaluate_guard(root.left, agent, cnts_var_dict, disc_var_dict, lane_map) - right = self._evaluate_guard(root.comparators[0], agent, cnts_var_dict, disc_var_dict, lane_map) + left = self._evaluate_guard(root.left, agent, cnts_var_dict, disc_var_dict, track_map) + right = self._evaluate_guard(root.comparators[0], agent, cnts_var_dict, disc_var_dict, track_map) if isinstance(root.ops[0], ast.GtE): return left>=right elif isinstance(root.ops[0], ast.Gt): @@ -663,7 +664,7 @@ class GuardExpressionAst: if isinstance(root.op, ast.And): res = True for val in root.values: - tmp = self._evaluate_guard(val, agent, cnts_var_dict, disc_var_dict, lane_map) + tmp = self._evaluate_guard(val, agent, cnts_var_dict, disc_var_dict, track_map) res = res and tmp if not res: break @@ -671,14 +672,14 @@ class GuardExpressionAst: elif isinstance(root.op, ast.Or): res = False for val in root.values: - tmp = self._evaluate_guard(val, agent, cnts_var_dict, disc_var_dict, lane_map) + tmp = self._evaluate_guard(val, agent, cnts_var_dict, disc_var_dict, track_map) res = res or tmp if res: break return res elif isinstance(root, ast.BinOp): - left = self._evaluate_guard(root.left, agent, cnts_var_dict, disc_var_dict, lane_map) - right = self._evaluate_guard(root.right, agent, cnts_var_dict, disc_var_dict, lane_map) + left = self._evaluate_guard(root.left, agent, cnts_var_dict, disc_var_dict, track_map) + right = self._evaluate_guard(root.right, agent, cnts_var_dict, disc_var_dict, track_map) if isinstance(root.op, ast.Sub): return left - right elif isinstance(root.op, ast.Add): @@ -731,7 +732,7 @@ class GuardExpressionAst: elif isinstance(root, ast.Constant): return root.value elif isinstance(root, ast.UnaryOp): - val = self._evaluate_guard(root.operand, agent, cnts_var_dict, disc_var_dict, lane_map) + val = self._evaluate_guard(root.operand, agent, cnts_var_dict, disc_var_dict, track_map) if isinstance(root.op, ast.USub): return -val if isinstance(root.op, ast.Not): @@ -1021,4 +1022,4 @@ if __name__ == "__main__": tmp = GuardExpressionAst(guard_list) # tmp.evaluate_guard() # tmp.construct_tree_from_str('(other_x-ego_x<20) and other_x-ego_x>10 and other_vehicle_lane==ego_vehicle_lane') - print("stop") \ No newline at end of file + print("stop") diff --git a/verse/scenario/scenario.py b/verse/scenario/scenario.py index 02d8fec93e498e73f0796a8824a2c7e8f538df29..252e061ba682d5a219f4015dbf74e7623da21f9f 100644 --- a/verse/scenario/scenario.py +++ b/verse/scenario/scenario.py @@ -26,7 +26,7 @@ EGO, OTHERS = "ego", "others" def red(s): return "\x1b[31m" + s + "\x1b[0m" -def pack_env(agent: BaseAgent, ego_ty_name: str, cont: Dict[str, float], disc: Dict[str, str], lane_map): +def pack_env(agent: BaseAgent, ego_ty_name: str, cont: Dict[str, float], disc: Dict[str, str], track_map): state_ty = None #namedtuple(ego_ty_name, agent.controller.state_defs[ego_ty_name].all_vars()) packed: DefaultDict[str, Any] = defaultdict(dict) # packed = {} @@ -38,7 +38,7 @@ def pack_env(agent: BaseAgent, ego_ty_name: str, cont: Dict[str, float], disc: D state_ty = namedtuple(ego_ty_name, ego_keys) for arg in agent.controller.args: if "map" in arg.name: - packed[arg.name] = lane_map + packed[arg.name] = track_map elif arg.name != EGO: other = arg.name if other in packed: @@ -149,12 +149,12 @@ class Scenario: def set_sensor(self, sensor): self.sensor = sensor - def set_map(self, lane_map: LaneMap): - self.map = lane_map + def set_map(self, track_map: LaneMap): + self.map = track_map # Update the lane mode field in the agent for agent_id in self.agent_dict: agent = self.agent_dict[agent_id] - self.update_agent_lane_mode(agent, lane_map) + self.update_agent_lane_mode(agent, track_map) def add_agent(self, agent: BaseAgent): if self.map is not None: @@ -177,8 +177,8 @@ class Scenario: # TODO-PARSER: update this function - def update_agent_lane_mode(self, agent: BaseAgent, lane_map: LaneMap): - for lane_id in lane_map.lane_dict: + def update_agent_lane_mode(self, agent: BaseAgent, track_map: LaneMap): + for lane_id in track_map.lane_dict: if 'TrackMode' in agent.controller.mode_defs and lane_id not in agent.controller.mode_defs['TrackMode'].modes: agent.controller.mode_defs['TrackMode'].modes.append(lane_id) # mode_vals = list(agent.controller.modes.values()) @@ -297,7 +297,7 @@ class Scenario: return tree def apply_reset(self, agent: BaseAgent, reset_list, all_agent_state) -> Tuple[str, np.ndarray]: - lane_map = self.map + track_map = self.map dest = [] rect = [] @@ -406,7 +406,7 @@ class Scenario: # disc_var_dict[unrolled_variable] = disc_var_dict[variable][unrolled_variable_index] def get_transition_simulate_new(self, cache: Dict[str, CachedSegment], paths: PathDiffs, node: AnalysisTreeNode) -> Tuple[Optional[Dict[str, List[str]]], Optional[Dict[str, List[Tuple[str, List[str], List[float]]]]], int]: - lane_map = self.map + track_map = self.map trace_length = len(list(node.trace.values())[0]) # For each agent @@ -491,15 +491,15 @@ class Scenario: dest_mode = node.get_mode(agent_idx, dest) dest_track = node.get_track(agent_idx, dest) # pp(("dbg", src_track, src_mode, dest, dest_mode, dest_track)) - # pp((lane_map.h(src_track, src_mode, dest_mode))) - if dest_track == lane_map.h(src_track, src_mode, dest_mode): + # pp((track_map.h(src_track, src_mode, dest_mode))) + if dest_track == track_map.h(src_track, src_mode, dest_mode): transitions[agent_idx].append((agent_idx, dest, next_init, paths)) # print("transitions", transitions) break return None, dict(transitions), idx def get_transition_verify_new(self, cache: Dict[str, CachedRTTrans], paths: PathDiffs, node: AnalysisTreeNode) -> Tuple[Optional[Dict[str, List[str]]], Optional[Dict[str, List[Tuple[str, List[str], List[float]]]]]]: - lane_map = self.map + track_map = self.map # For each agent agent_guard_dict = defaultdict(list) @@ -696,7 +696,7 @@ class Scenario: src_track = node.get_track(agent, node.mode[agent]) dest_mode = node.get_mode(agent, dest) dest_track = node.get_track(agent, dest) - if dest_track == lane_map.h(src_track, src_mode, dest_mode): + if dest_track == track_map.h(src_track, src_mode, dest_mode): possible_transitions.append(transition) # Return result return None, possible_transitions