From c80eabb44637dc7f545011791c10d134dc44dd5f Mon Sep 17 00:00:00 2001 From: keyis2 <keyis2@illinois.edu> Date: Sat, 11 Jun 2022 17:23:20 -0500 Subject: [PATCH] marker --- demo/demo2.py | 16 +- dist/dryvr_plus_plus-0.1-py3.8.egg | Bin 0 -> 1292 bytes .../__init__.py | 0 .../example/__init__.py | 0 .../example/example_agent/__init__.py | 0 .../example/example_agent/car_agent.py | 0 .../example/example_agent/sign_agent.py | 0 .../example/example_map/__init__.py | 0 .../example/example_map/simple_map.py | 0 .../example/example_map/simple_map2.py | 0 .../example/example_sensor/__init__.py | 0 .../example/example_sensor/fake_sensor.py | 0 .../plotter/__init__.py | 0 .../plotter/parser.py | 0 .../plotter/plotter2D.py | 166 ++++++++++++++---- .../plotter/plotter3D.py | 0 .../scene_verifier/__init__.py | 0 .../scene_verifier/agents/__init__.py | 0 .../scene_verifier/agents/base_agent.py | 0 .../scene_verifier/analysis/__init__.py | 0 .../analysis/analysis_tree_node.py | 0 .../scene_verifier/analysis/simulator.py | 2 +- .../scene_verifier/analysis/verifier.py | 0 .../scene_verifier/automaton/__init__.py | 0 .../scene_verifier/automaton/guard.py | 0 .../automaton/hybrid_automaton.py | 0 .../automaton/hybrid_io_automaton.py | 0 .../scene_verifier/automaton/reset.py | 0 .../scene_verifier/code_parser/__init__.py | 0 .../code_parser/pythonparser.py | 0 .../scene_verifier/dryvr/__init__.py | 0 .../scene_verifier/dryvr/common/__init__.py | 0 .../scene_verifier/dryvr/common/config.py | 0 .../scene_verifier/dryvr/common/constant.py | 0 .../scene_verifier/dryvr/common/io.py | 0 .../scene_verifier/dryvr/common/utils.py | 0 .../scene_verifier/dryvr/core/__init__.py | 0 .../scene_verifier/dryvr/core/distance.py | 0 .../scene_verifier/dryvr/core/dryvrcore.py | 0 .../scene_verifier/dryvr/core/dryvrmain.py | 0 .../scene_verifier/dryvr/core/goalchecker.py | 0 .../scene_verifier/dryvr/core/graph.py | 0 .../scene_verifier/dryvr/core/guard.py | 0 .../scene_verifier/dryvr/core/initialset.py | 0 .../dryvr/core/initialsetstack.py | 0 .../scene_verifier/dryvr/core/reachtube.py | 0 .../scene_verifier/dryvr/core/reset.py | 0 .../dryvr/core/uniformchecker.py | 0 .../dryvr/discrepancy/Global_Disc.py | 0 .../dryvr/discrepancy/PW_Discrepancy.py | 0 .../dryvr/discrepancy/__init__.py | 0 .../scene_verifier/map/__init__.py | 0 .../scene_verifier/map/lane.py | 0 .../scene_verifier/map/lane_map.py | 0 .../scene_verifier/map/lane_segment.py | 0 .../scene_verifier/scenario/__init__.py | 0 .../scene_verifier/scenario/scenario.py | 0 .../scene_verifier/utils/__init__.py | 0 .../scene_verifier/utils/utils.py | 0 setup.py | 7 +- 60 files changed, 145 insertions(+), 46 deletions(-) create mode 100644 dist/dryvr_plus_plus-0.1-py3.8.egg rename {demo/dryvr_plus_plus => dryvr_plus_plus}/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/example/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/example/example_agent/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/example/example_agent/car_agent.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/example/example_agent/sign_agent.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/example/example_map/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/example/example_map/simple_map.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/example/example_map/simple_map2.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/example/example_sensor/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/example/example_sensor/fake_sensor.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/plotter/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/plotter/parser.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/plotter/plotter2D.py (88%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/plotter/plotter3D.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/agents/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/agents/base_agent.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/analysis/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/analysis/analysis_tree_node.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/analysis/simulator.py (98%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/analysis/verifier.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/automaton/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/automaton/guard.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/automaton/hybrid_automaton.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/automaton/hybrid_io_automaton.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/automaton/reset.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/code_parser/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/code_parser/pythonparser.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/common/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/common/config.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/common/constant.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/common/io.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/common/utils.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/distance.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/dryvrcore.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/dryvrmain.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/goalchecker.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/graph.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/guard.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/initialset.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/initialsetstack.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/reachtube.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/reset.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/core/uniformchecker.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/discrepancy/Global_Disc.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/discrepancy/PW_Discrepancy.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/dryvr/discrepancy/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/map/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/map/lane.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/map/lane_map.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/map/lane_segment.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/scenario/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/scenario/scenario.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/utils/__init__.py (100%) rename {demo/dryvr_plus_plus => dryvr_plus_plus}/scene_verifier/utils/utils.py (100%) diff --git a/demo/demo2.py b/demo/demo2.py index 574b38f1..b8eaf9b8 100644 --- a/demo/demo2.py +++ b/demo/demo2.py @@ -56,8 +56,8 @@ if __name__ == "__main__": ] ) # res_list = scenario.simulate_multi(40,1) - # traces = scenario.verify(15) - traces = scenario.simulate(40) + traces = scenario.verify(40) + # traces = scenario.simulate(40) # fig = plt.figure(2) # fig = plot_map(tmp_map, 'g', fig) @@ -73,14 +73,14 @@ if __name__ == "__main__": # fig = go.Figure() # fig = plotly_simulation_tree(traces, 'car1', 1, [2], 'b', fig) # fig.show() - fig = go.Figure() - fig = plotly_simulation_anime(traces, tmp_map, fig) - fig.show() - # fig = go.Figure() - # fig = plotly_reachtube_tree_v2(traces, 'car1', 1, [2], 'blue', fig) - # # fig = plotly_reachtube_tree_v2(traces, 'car2', 1, [2], 'red', fig) + # fig = plotly_simulation_anime(traces, tmp_map, fig) # fig.show() + + fig = go.Figure() + fig = plotly_reachtube_tree_v2(traces, 'car1', 1, [2], 'blue', fig) + fig = plotly_reachtube_tree_v2(traces, 'car2', 1, [2], 'red', fig) + fig.show() # fig = go.Figure() # fig = generate_reachtube_anime( # traces, 'car1', 1, [2], 'blue', fig, map=tmp_map) diff --git a/dist/dryvr_plus_plus-0.1-py3.8.egg b/dist/dryvr_plus_plus-0.1-py3.8.egg new file mode 100644 index 0000000000000000000000000000000000000000..cdd7c8753229a16431604862518b4f6f9d13a03d GIT binary patch literal 1292 zcmWIWW@Zs#U|`^2_z`^~WR;QL2NOmH1|cQ}20@^xtGm0dr=Od@et<WGF?XWB_hAQt zqwjx;6z2=w{-VU)b&*RfTDMo^i<#QvcL&lYznkwQxPSNTFz&A}5~n}>ID78*wCPVa zI`-deTl4rFhsGz*Pc6Ef8E@*+H^;G;@0cWP)aN03OYCjjfiv&SUtiSFY!06*`k~9s ztBG~_hmN?3sm=x2h8|CYD-PtHb~`ki>!i@l9~Cd=$4YKJ5p`hsvm_(mhkrZ7HCHIx z|J{|i_GZbOqAaIP4`%grpFAa(?HW0;f3kJ&xsUApYH3@P?|#*l<e%y;FVnF@;6y^I zrgrK24?Xjx{g*9dJ9WWe<}9{7tN5QDoh7qy?bXQR-q(w37uAHk?ygo&o~5|aCb|9& z-<M+3{(056-##+<`1-%gpR*e`&E0Zi+u>7Ug&P^4KAd^gu5O~_s?55XYci#8Ogi1S zsp0i%$A4@AC_(IU{)AcvFles;F(}~SK^*KK8szL6tXEP|!d+Ba^0D;lY2Sxhe!7~v z7qnMA@zPwSqur%{LQ|JbxN7Cgm%C<GX8!!ec<<e=d3AaJc7(G0ZfCRH&Gvd~$dm_R zQzk`Cm^FRUtm!e5^C!=o9@`UN8km)snHH$U7^?b{^`qs=)RmSBsSKzto6L6Ih#BZ2 zVEi-4BD*XlwIDSwB{eU(GCn6WFS{7z#K%l%y4@7z|MdcO9Rp%fWZgxng{7HAsbF2Y zeV%-W6?j~~@AF=3P!d%j5w%ckDhv0VMm>va#h2&&|6Mle4_PIsp~`i_zy1O*yM%6V zhs>YFQms;|0X(hBJG0oPtY|p($oO{Os@v+vvwh~TmAZLl=by#;vVX4mFO1%B*2X_2 zxa@d1qx$o2^ZJ<fy_%975wpr|yXK=?KL4ib?5(~kdz9h#rfGHemj6R@KeF$|klkOB zUl5;@T9%rF)!WG0P;yLFW`S;TVp=LVpct7%m~rPaplx8Vq!C2H69g>J1$d)sM^8Zz z%?u1n8k2!h2iK02p3qG|b~GraVPHw)Ut|-o#XGuD=+TZa${JXPz#W5}2+)l{b`2=x uVPHw)Z)77-;sKu-plE=BC5@mY4R;1CQUbhL*+5FzfN&Df%PF9A&j0{-Teo8X literal 0 HcmV?d00001 diff --git a/demo/dryvr_plus_plus/__init__.py b/dryvr_plus_plus/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/__init__.py rename to dryvr_plus_plus/__init__.py diff --git a/demo/dryvr_plus_plus/example/__init__.py b/dryvr_plus_plus/example/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/example/__init__.py rename to dryvr_plus_plus/example/__init__.py diff --git a/demo/dryvr_plus_plus/example/example_agent/__init__.py b/dryvr_plus_plus/example/example_agent/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/example/example_agent/__init__.py rename to dryvr_plus_plus/example/example_agent/__init__.py diff --git a/demo/dryvr_plus_plus/example/example_agent/car_agent.py b/dryvr_plus_plus/example/example_agent/car_agent.py similarity index 100% rename from demo/dryvr_plus_plus/example/example_agent/car_agent.py rename to dryvr_plus_plus/example/example_agent/car_agent.py diff --git a/demo/dryvr_plus_plus/example/example_agent/sign_agent.py b/dryvr_plus_plus/example/example_agent/sign_agent.py similarity index 100% rename from demo/dryvr_plus_plus/example/example_agent/sign_agent.py rename to dryvr_plus_plus/example/example_agent/sign_agent.py diff --git a/demo/dryvr_plus_plus/example/example_map/__init__.py b/dryvr_plus_plus/example/example_map/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/example/example_map/__init__.py rename to dryvr_plus_plus/example/example_map/__init__.py diff --git a/demo/dryvr_plus_plus/example/example_map/simple_map.py b/dryvr_plus_plus/example/example_map/simple_map.py similarity index 100% rename from demo/dryvr_plus_plus/example/example_map/simple_map.py rename to dryvr_plus_plus/example/example_map/simple_map.py diff --git a/demo/dryvr_plus_plus/example/example_map/simple_map2.py b/dryvr_plus_plus/example/example_map/simple_map2.py similarity index 100% rename from demo/dryvr_plus_plus/example/example_map/simple_map2.py rename to dryvr_plus_plus/example/example_map/simple_map2.py diff --git a/demo/dryvr_plus_plus/example/example_sensor/__init__.py b/dryvr_plus_plus/example/example_sensor/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/example/example_sensor/__init__.py rename to dryvr_plus_plus/example/example_sensor/__init__.py diff --git a/demo/dryvr_plus_plus/example/example_sensor/fake_sensor.py b/dryvr_plus_plus/example/example_sensor/fake_sensor.py similarity index 100% rename from demo/dryvr_plus_plus/example/example_sensor/fake_sensor.py rename to dryvr_plus_plus/example/example_sensor/fake_sensor.py diff --git a/demo/dryvr_plus_plus/plotter/__init__.py b/dryvr_plus_plus/plotter/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/plotter/__init__.py rename to dryvr_plus_plus/plotter/__init__.py diff --git a/demo/dryvr_plus_plus/plotter/parser.py b/dryvr_plus_plus/plotter/parser.py similarity index 100% rename from demo/dryvr_plus_plus/plotter/parser.py rename to dryvr_plus_plus/plotter/parser.py diff --git a/demo/dryvr_plus_plus/plotter/plotter2D.py b/dryvr_plus_plus/plotter/plotter2D.py similarity index 88% rename from demo/dryvr_plus_plus/plotter/plotter2D.py rename to dryvr_plus_plus/plotter/plotter2D.py index ae13f889..9e8fd27b 100644 --- a/demo/dryvr_plus_plus/plotter/plotter2D.py +++ b/dryvr_plus_plus/plotter/plotter2D.py @@ -4,6 +4,7 @@ This file consist main plotter code for DryVR reachtube output from __future__ import annotations from audioop import reverse +from re import A import matplotlib.patches as patches import matplotlib.pyplot as plt import numpy as np @@ -13,7 +14,10 @@ import plotly.graph_objects as go from typing import List from PIL import Image, ImageDraw import io +import operator from collections import OrderedDict + +from torch import layout from dryvr_plus_plus.scene_verifier.analysis.analysis_tree_node import AnalysisTreeNode colors = ['red', 'green', 'blue', 'yellow', 'black'] @@ -177,6 +181,7 @@ def generate_reachtube_anime(root, agent_id, x_dim: int = 0, y_dim_list: List[in "visible": True, "xanchor": "right" }, + "method": "update", "transition": {"duration": duration, "easing": "cubic-in-out"}, "pad": {"b": 10, "t": 50}, "len": 0.9, @@ -217,7 +222,7 @@ def generate_reachtube_anime(root, agent_id, x_dim: int = 0, y_dim_list: List[in "x": trace_x, "y": trace_y, "mode": "markers + text", - "text": [(round(trace_theta[i]/pi*180, 2), round(trace_v[i], 2)) for i in range(len(trace_theta))], + "text": [(round(trace_theta[i]/pi*180, 2), round(trace_v[i], 3)) for i in range(len(trace_theta))], "textposition": "bottom center", # "marker": { # "sizemode": "area", @@ -306,6 +311,7 @@ def plotly_reachtube_tree_v2(root, agent_id, x_dim: int = 0, y_dim_list: List[in bg_color = ['rgba(31,119,180,1)', 'rgba(255,127,14,0.2)', 'rgba(44,160,44,0.2)', 'rgba(214,39,40,0.2)', 'rgba(148,103,189,0.2)', 'rgba(140,86,75,0.2)', 'rgba(227,119,194,0.2)', 'rgba(127,127,127,0.2)', 'rgba(188,189,34,0.2)', 'rgba(23,190,207,0.2)'] queue = [root] + show_legend = False while queue != []: node = queue.pop(0) traces = node.trace @@ -347,26 +353,26 @@ def plotly_reachtube_tree_v2(root, agent_id, x_dim: int = 0, y_dim_list: List[in trace_y_even = np.array([trace[i][2] for i in range(1, max_id+1, 2)]) fig.add_trace(go.Scatter(x=trace_x_odd.tolist()+trace_x_odd[::-1].tolist(), y=trace_y_odd.tolist()+trace_y_even[::-1].tolist(), mode='lines', fill='toself', - fillcolor=bg_color[0], + fillcolor=color, line_color='rgba(255,255,255,0)', - showlegend=True + showlegend=show_legend )) fig.add_trace(go.Scatter(x=trace_x_even.tolist()+trace_x_even[::-1].tolist(), y=trace_y_odd.tolist()+trace_y_even[::-1].tolist(), mode='lines', fill='toself', - fillcolor=bg_color[0], + fillcolor=color, line_color='rgba(255,255,255,0)', - showlegend=True)) + showlegend=show_legend)) fig.add_trace(go.Scatter(x=trace_x_odd.tolist()+trace_x_even[::-1].tolist(), y=trace_y_odd.tolist()+trace_y_even[::-1].tolist(), mode='lines', fill='toself', - fillcolor=bg_color[0], + fillcolor=color, line_color='rgba(255,255,255,0)', - showlegend=True + showlegend=show_legend )) fig.add_trace(go.Scatter(x=trace_x_even.tolist()+trace_x_odd[::-1].tolist(), y=trace_y_odd.tolist()+trace_y_even[::-1].tolist(), mode='lines', fill='toself', - fillcolor=bg_color[0], + fillcolor=color, line_color='rgba(255,255,255,0)', - showlegend=True)) + showlegend=show_legend)) # fig.add_trace(go.Scatter(x=trace_x_odd.tolist(), y=trace_y_odd.tolist(), mode='lines', # # fill='toself', # # fillcolor=bg_color[0], @@ -495,9 +501,14 @@ def plotly_reachtube_tree_v2(root, agent_id, x_dim: int = 0, y_dim_list: List[in # fill='toself', # line=dict(dash="dot"), line_color="black", - text=[range(0, max_id+1)], - name='lines', - showlegend=False)) + marker={ + "sizemode": "area", + "sizeref": 200000, + "size": 2 + }, + text=[range(0, max_id+1)], + name='lines', + showlegend=False)) queue += node.child # fig.update_traces(line_dash="dash") return fig @@ -776,34 +787,44 @@ def plotly_simulation_anime(root, map=None, fig=None): # fig = plot_map(map, 'g', fig) timed_point_dict = {} stack = [root] + print("plot") + # print(root.mode) x_min, x_max = float('inf'), -float('inf') y_min, y_max = float('inf'), -float('inf') + segment_start = set() + # previous_mode = {} + # for agent_id in root.mode: + # previous_mode[agent_id] = [] + while stack != []: node = stack.pop() traces = node.trace for agent_id in traces: trace = np.array(traces[agent_id]) + segment_start.add(round(trace[0][0], 2)) for i in range(len(trace)): x_min = min(x_min, trace[i][1]) x_max = max(x_max, trace[i][1]) y_min = min(y_min, trace[i][2]) y_max = max(y_max, trace[i][2]) + # print(round(trace[i][0], 2)) if round(trace[i][0], 2) not in timed_point_dict: timed_point_dict[round(trace[i][0], 2)] = [ - trace[i][1:].tolist()] + {agent_id: trace[i][1:].tolist()}] else: init = False for record in timed_point_dict[round(trace[i][0], 2)]: - if record == trace[i][1:].tolist(): + if list(record.values())[0] == trace[i][1:].tolist(): init = True break if init == False: timed_point_dict[round(trace[i][0], 2)].append( - trace[i][1:].tolist()) + {agent_id: trace[i][1:].tolist()}) time = round(trace[i][0], 2) stack += node.child # fill in most of layout - # print(time) + print(segment_start) + # print(timed_point_dict.keys()) duration = int(600/time) fig_dict["layout"]["xaxis"] = { "range": [(x_min-10), (x_max+10)], @@ -859,12 +880,20 @@ def plotly_simulation_anime(root, map=None, fig=None): } # make data point_list = timed_point_dict[0] - # print(point_list) + x_list = [] + y_list = [] + text_list = [] + for data in point_list: + trace = list(data.values())[0] + # print(trace) + x_list.append(trace[0]) + y_list.append(trace[1]) + text_list.append((round(trace[3], 2), round(trace[2]/pi*180, 2))) data_dict = { - "x": [data[0] for data in point_list], - "y": [data[1] for data in point_list], + "x": x_list, + "y": y_list, "mode": "markers + text", - "text": [(round(data[3], 2), round(data[2]/pi*180, 2)) for data in point_list], + "text": text_list, "textposition": "bottom center", # "marker": { # "sizemode": "area", @@ -877,20 +906,30 @@ def plotly_simulation_anime(root, map=None, fig=None): # make frames for time_point in timed_point_dict: + # print(time_point) frame = {"data": [], "layout": { "annotations": []}, "name": str(time_point)} - # print(timed_point_dict[time_point]) + # print(timed_point_dict[time_point][0]) point_list = timed_point_dict[time_point] # point_list = list(OrderedDict.fromkeys(timed_point_dict[time_point])) - trace_x = [data[0] for data in point_list] - trace_y = [data[1] for data in point_list] - trace_theta = [data[2] for data in point_list] - trace_v = [data[3] for data in point_list] + # todokeyi + trace_x = [] + trace_y = [] + trace_theta = [] + trace_v = [] + for data in point_list: + trace = list(data.values())[0] + # print(trace) + trace_x.append(trace[0]) + trace_y.append(trace[1]) + trace_theta.append(trace[2]) + trace_v.append(trace[3]) data_dict = { "x": trace_x, "y": trace_y, "mode": "markers + text", - "text": [(round(trace_theta[i]/pi*180, 2), round(trace_v[i], 2)) for i in range(len(trace_theta))], + "text": [(round(trace_theta[i]/pi*180, 2), round(trace_v[i], 3)) for i in range(len(trace_theta))], + "textfont": dict(size=14, color="black"), "textposition": "bottom center", # "marker": { # "sizemode": "area", @@ -904,7 +943,7 @@ def plotly_simulation_anime(root, map=None, fig=None): ax = np.cos(trace_theta[i])*trace_v[i] ay = np.sin(trace_theta[i])*trace_v[i] # print(trace_x[i]+ax, trace_y[i]+ay) - annotations_dict = {"x": trace_x[i]+ax+0.1, "y": trace_y[i]+ay, + annotations_dict = {"x": trace_x[i]+ax, "y": trace_y[i]+ay, # "xshift": ax, "yshift": ay, "ax": trace_x[i], "ay": trace_y[i], "arrowwidth": 2, @@ -918,6 +957,25 @@ def plotly_simulation_anime(root, map=None, fig=None): "arrowcolor": "black"} frame["layout"]["annotations"].append(annotations_dict) + # if (time_point in segment_start) and (operator.ne(previous_mode[agent_id], node.mode[agent_id])): + # annotations_dict = {"x": trace_x[i], "y": trace_y[i], + # # "xshift": ax, "yshift": ay, + # # "ax": trace_x[i], "ay": trace_y[i], + # # "arrowwidth": 2, + # # "arrowside": 'end', + # "showarrow": False, + # # "arrowsize": 1, + # # "xref": 'x', "yref": 'y', + # # "axref": 'x', "ayref": 'y', + # "text": str(node.mode[agent_id][0]), + # # "arrowhead": 1, + # # "arrowcolor": "black" + # } + # frame["layout"]["annotations"].append(annotations_dict) + # print(frame["layout"]["annotations"]) + # i += 1 + # previous_mode[agent_id] = node.mode[agent_id] + fig_dict["frames"].append(frame) slider_step = {"args": [ [time_point], @@ -936,32 +994,72 @@ def plotly_simulation_anime(root, map=None, fig=None): fig = plotly_map(map, 'g', fig) i = 0 queue = [root] + previous_mode = {} + agent_list = [] + for agent_id in root.mode: + previous_mode[agent_id] = [] + agent_list.append(agent_id) + text_pos = 'middle center' while queue != []: node = queue.pop(0) traces = node.trace - print(node.mode) + # print(node.mode) # [[time,x,y,theta,v]...] + i = 0 for agent_id in traces: trace = np.array(traces[agent_id]) # print(trace) trace_y = trace[:, 2].tolist() trace_x = trace[:, 1].tolist() # theta = [i/pi*180 for i in trace[:, 3]] - color = 'green' - if agent_id == 'car2': - color = 'red' + i = agent_list.index(agent_id) + color = colors[i % 5] fig.add_trace(go.Scatter(x=trace[:, 1], y=trace[:, 2], mode='lines', line_color=color, - text=[(round(trace[i, 3]/pi*180, 2), round(trace[i, 4], 2)) + text=[(round(trace[i, 3]/pi*180, 2), round(trace[i, 4], 3)) for i in range(len(trace_y))], showlegend=False) # name='lines') ) - i += 1 + if previous_mode[agent_id] != node.mode[agent_id]: + theta = trace[0, 3] + veh_mode = node.mode[agent_id][0] + if veh_mode == 'Normal': + text_pos = 'middle center' + elif veh_mode == 'Brake': + if theta >= -pi/2 and theta <= pi/2: + text_pos = 'middle left' + else: + text_pos = 'middle right' + elif veh_mode == 'SwitchLeft': + if theta >= -pi/2 and theta <= pi/2: + text_pos = 'top center' + else: + text_pos = 'bottom center' + elif veh_mode == 'SwitchRight': + if theta >= -pi/2 and theta <= pi/2: + text_pos = 'bottom center' + else: + text_pos = 'top center' + fig.add_trace(go.Scatter(x=[trace[0, 1]], y=[trace[0, 2]], + mode='markers+text', + line_color='rgba(255,255,255,0.3)', + text=str(agent_id)+': ' + + str(node.mode[agent_id][0]), + textposition=text_pos, + textfont=dict( + # family="sans serif", + size=10, + color="grey"), + showlegend=False, + )) + # i += 1 + previous_mode[agent_id] = node.mode[agent_id] queue += node.child # fig.update_traces(mode='lines') - + # fig.update_annotations(textfont=dict(size=14, color="black")) + # print(fig.frames[0].layout["annotations"]) return fig # fig.show() diff --git a/demo/dryvr_plus_plus/plotter/plotter3D.py b/dryvr_plus_plus/plotter/plotter3D.py similarity index 100% rename from demo/dryvr_plus_plus/plotter/plotter3D.py rename to dryvr_plus_plus/plotter/plotter3D.py diff --git a/demo/dryvr_plus_plus/scene_verifier/__init__.py b/dryvr_plus_plus/scene_verifier/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/__init__.py rename to dryvr_plus_plus/scene_verifier/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/agents/__init__.py b/dryvr_plus_plus/scene_verifier/agents/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/agents/__init__.py rename to dryvr_plus_plus/scene_verifier/agents/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/agents/base_agent.py b/dryvr_plus_plus/scene_verifier/agents/base_agent.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/agents/base_agent.py rename to dryvr_plus_plus/scene_verifier/agents/base_agent.py diff --git a/demo/dryvr_plus_plus/scene_verifier/analysis/__init__.py b/dryvr_plus_plus/scene_verifier/analysis/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/analysis/__init__.py rename to dryvr_plus_plus/scene_verifier/analysis/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/analysis/analysis_tree_node.py b/dryvr_plus_plus/scene_verifier/analysis/analysis_tree_node.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/analysis/analysis_tree_node.py rename to dryvr_plus_plus/scene_verifier/analysis/analysis_tree_node.py diff --git a/demo/dryvr_plus_plus/scene_verifier/analysis/simulator.py b/dryvr_plus_plus/scene_verifier/analysis/simulator.py similarity index 98% rename from demo/dryvr_plus_plus/scene_verifier/analysis/simulator.py rename to dryvr_plus_plus/scene_verifier/analysis/simulator.py index 97514d88..dd6f03f8 100644 --- a/demo/dryvr_plus_plus/scene_verifier/analysis/simulator.py +++ b/dryvr_plus_plus/scene_verifier/analysis/simulator.py @@ -89,7 +89,7 @@ class Simulator: continue # next_node = AnalysisTreeNode(trace = {},init={},mode={},agent={}, child = [], start_time = 0) next_node_mode = copy.deepcopy(node.mode) - next_node_mode[transit_agent_idx] = dest_mode + next_node_mode[transit_agent_idx] = list(dest_mode) next_node_agent = node.agent next_node_start_time = list(truncated_trace.values())[0][0][0] next_node_init = {} diff --git a/demo/dryvr_plus_plus/scene_verifier/analysis/verifier.py b/dryvr_plus_plus/scene_verifier/analysis/verifier.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/analysis/verifier.py rename to dryvr_plus_plus/scene_verifier/analysis/verifier.py diff --git a/demo/dryvr_plus_plus/scene_verifier/automaton/__init__.py b/dryvr_plus_plus/scene_verifier/automaton/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/automaton/__init__.py rename to dryvr_plus_plus/scene_verifier/automaton/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/automaton/guard.py b/dryvr_plus_plus/scene_verifier/automaton/guard.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/automaton/guard.py rename to dryvr_plus_plus/scene_verifier/automaton/guard.py diff --git a/demo/dryvr_plus_plus/scene_verifier/automaton/hybrid_automaton.py b/dryvr_plus_plus/scene_verifier/automaton/hybrid_automaton.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/automaton/hybrid_automaton.py rename to dryvr_plus_plus/scene_verifier/automaton/hybrid_automaton.py diff --git a/demo/dryvr_plus_plus/scene_verifier/automaton/hybrid_io_automaton.py b/dryvr_plus_plus/scene_verifier/automaton/hybrid_io_automaton.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/automaton/hybrid_io_automaton.py rename to dryvr_plus_plus/scene_verifier/automaton/hybrid_io_automaton.py diff --git a/demo/dryvr_plus_plus/scene_verifier/automaton/reset.py b/dryvr_plus_plus/scene_verifier/automaton/reset.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/automaton/reset.py rename to dryvr_plus_plus/scene_verifier/automaton/reset.py diff --git a/demo/dryvr_plus_plus/scene_verifier/code_parser/__init__.py b/dryvr_plus_plus/scene_verifier/code_parser/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/code_parser/__init__.py rename to dryvr_plus_plus/scene_verifier/code_parser/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/code_parser/pythonparser.py b/dryvr_plus_plus/scene_verifier/code_parser/pythonparser.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/code_parser/pythonparser.py rename to dryvr_plus_plus/scene_verifier/code_parser/pythonparser.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/__init__.py b/dryvr_plus_plus/scene_verifier/dryvr/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/__init__.py rename to dryvr_plus_plus/scene_verifier/dryvr/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/common/__init__.py b/dryvr_plus_plus/scene_verifier/dryvr/common/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/common/__init__.py rename to dryvr_plus_plus/scene_verifier/dryvr/common/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/common/config.py b/dryvr_plus_plus/scene_verifier/dryvr/common/config.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/common/config.py rename to dryvr_plus_plus/scene_verifier/dryvr/common/config.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/common/constant.py b/dryvr_plus_plus/scene_verifier/dryvr/common/constant.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/common/constant.py rename to dryvr_plus_plus/scene_verifier/dryvr/common/constant.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/common/io.py b/dryvr_plus_plus/scene_verifier/dryvr/common/io.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/common/io.py rename to dryvr_plus_plus/scene_verifier/dryvr/common/io.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/common/utils.py b/dryvr_plus_plus/scene_verifier/dryvr/common/utils.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/common/utils.py rename to dryvr_plus_plus/scene_verifier/dryvr/common/utils.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/__init__.py b/dryvr_plus_plus/scene_verifier/dryvr/core/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/__init__.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/distance.py b/dryvr_plus_plus/scene_verifier/dryvr/core/distance.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/distance.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/distance.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/dryvrcore.py b/dryvr_plus_plus/scene_verifier/dryvr/core/dryvrcore.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/dryvrcore.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/dryvrcore.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/dryvrmain.py b/dryvr_plus_plus/scene_verifier/dryvr/core/dryvrmain.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/dryvrmain.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/dryvrmain.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/goalchecker.py b/dryvr_plus_plus/scene_verifier/dryvr/core/goalchecker.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/goalchecker.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/goalchecker.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/graph.py b/dryvr_plus_plus/scene_verifier/dryvr/core/graph.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/graph.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/graph.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/guard.py b/dryvr_plus_plus/scene_verifier/dryvr/core/guard.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/guard.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/guard.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/initialset.py b/dryvr_plus_plus/scene_verifier/dryvr/core/initialset.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/initialset.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/initialset.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/initialsetstack.py b/dryvr_plus_plus/scene_verifier/dryvr/core/initialsetstack.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/initialsetstack.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/initialsetstack.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/reachtube.py b/dryvr_plus_plus/scene_verifier/dryvr/core/reachtube.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/reachtube.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/reachtube.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/reset.py b/dryvr_plus_plus/scene_verifier/dryvr/core/reset.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/reset.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/reset.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/core/uniformchecker.py b/dryvr_plus_plus/scene_verifier/dryvr/core/uniformchecker.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/core/uniformchecker.py rename to dryvr_plus_plus/scene_verifier/dryvr/core/uniformchecker.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/discrepancy/Global_Disc.py b/dryvr_plus_plus/scene_verifier/dryvr/discrepancy/Global_Disc.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/discrepancy/Global_Disc.py rename to dryvr_plus_plus/scene_verifier/dryvr/discrepancy/Global_Disc.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/discrepancy/PW_Discrepancy.py b/dryvr_plus_plus/scene_verifier/dryvr/discrepancy/PW_Discrepancy.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/discrepancy/PW_Discrepancy.py rename to dryvr_plus_plus/scene_verifier/dryvr/discrepancy/PW_Discrepancy.py diff --git a/demo/dryvr_plus_plus/scene_verifier/dryvr/discrepancy/__init__.py b/dryvr_plus_plus/scene_verifier/dryvr/discrepancy/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/dryvr/discrepancy/__init__.py rename to dryvr_plus_plus/scene_verifier/dryvr/discrepancy/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/map/__init__.py b/dryvr_plus_plus/scene_verifier/map/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/map/__init__.py rename to dryvr_plus_plus/scene_verifier/map/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/map/lane.py b/dryvr_plus_plus/scene_verifier/map/lane.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/map/lane.py rename to dryvr_plus_plus/scene_verifier/map/lane.py diff --git a/demo/dryvr_plus_plus/scene_verifier/map/lane_map.py b/dryvr_plus_plus/scene_verifier/map/lane_map.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/map/lane_map.py rename to dryvr_plus_plus/scene_verifier/map/lane_map.py diff --git a/demo/dryvr_plus_plus/scene_verifier/map/lane_segment.py b/dryvr_plus_plus/scene_verifier/map/lane_segment.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/map/lane_segment.py rename to dryvr_plus_plus/scene_verifier/map/lane_segment.py diff --git a/demo/dryvr_plus_plus/scene_verifier/scenario/__init__.py b/dryvr_plus_plus/scene_verifier/scenario/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/scenario/__init__.py rename to dryvr_plus_plus/scene_verifier/scenario/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/scenario/scenario.py b/dryvr_plus_plus/scene_verifier/scenario/scenario.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/scenario/scenario.py rename to dryvr_plus_plus/scene_verifier/scenario/scenario.py diff --git a/demo/dryvr_plus_plus/scene_verifier/utils/__init__.py b/dryvr_plus_plus/scene_verifier/utils/__init__.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/utils/__init__.py rename to dryvr_plus_plus/scene_verifier/utils/__init__.py diff --git a/demo/dryvr_plus_plus/scene_verifier/utils/utils.py b/dryvr_plus_plus/scene_verifier/utils/utils.py similarity index 100% rename from demo/dryvr_plus_plus/scene_verifier/utils/utils.py rename to dryvr_plus_plus/scene_verifier/utils/utils.py diff --git a/setup.py b/setup.py index 221cc485..536556a8 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from setuptools import setup +from setuptools import setup, find_packages setup( name='dryvr_plus_plus', @@ -9,7 +9,7 @@ setup( maintainer='Yangge Li, Katherine Braught, Haoqing Zhu', maintainer_email='{li213, braught2, haoqing3}@illinois.edu', license='Apache-2.0', - packages=setuptools.find_packages(exclude=["tests", "demo"]), + packages=find_packages(exclude=["tests", "demo"]), python_requires='>=3.8', install_requires=[ "numpy~=1.22.1", @@ -24,6 +24,7 @@ setup( "treelib~=1.6.1", "z3-solver~=4.8.17.0", "igraph~=0.9.10", + "plotly~=5.8.0" ], classifiers=[ 'Development Status :: 2 - Pre-Alpha', @@ -32,4 +33,4 @@ setup( 'License :: OSI Approved :: Apache License 2.0', 'Programming Language :: Python :: 3.8', ] -) \ No newline at end of file +) -- GitLab