From b3761aea668a6cacea7fbf9b9d04220a247a72ea Mon Sep 17 00:00:00 2001 From: Tucker Date: Fri, 14 Apr 2023 17:38:36 -0400 Subject: [PATCH 1/2] Shorten vehicle ids. --- CHANGELOG.md | 1 + envision/tests/test_data_formatter.py | 6 +++--- smarts/core/tests/test_trap_manager.py | 4 ++-- smarts/core/utils/tests/fixtures.py | 4 ++-- smarts/sstudio/types.py | 10 +++++----- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce744eddb4..e290e3463f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Copy and pasting the git commit messages is __NOT__ enough. - The trap manager, `TrapManager`, is now a subclass of `ActorCaptureManager`. - Considering lane-change time ranges between 3s and 6s, assuming a speed of 13.89m/s, the via sensor lane acquisition range was increased from 40m to 80m, for better driving ability. - Modified naming of benchmark used in NeurIPS 2022 from driving-smarts-competition-env to driving-smarts-v2022. +- Sstudio generated scenario vehicle traffic ids are now shortened. ### Deprecated ### Fixed - Fixed an issue where Argoverse scenarios with a `Mission` would not run properly. diff --git a/envision/tests/test_data_formatter.py b/envision/tests/test_data_formatter.py index 84ce8fa540..955dd9e00f 100644 --- a/envision/tests/test_data_formatter.py +++ b/envision/tests/test_data_formatter.py @@ -300,10 +300,10 @@ def sim_data(): [], [4], { - 0: "car-flow-route-west_0_0-east_0_max-7845114534199723832--7266489842092764092--0-0.0", + 0: "car-west_0_0-east_0_max-784511-552438-0-0.0", 1: None, - 2: "car-flow-route-west_1_0-east_1_max--852708111940723884--7266489842092764092--1-0.0", - 3: "car-flow-route-west_2_0-east_2_max--6324729949279915259--7266489842092764092--2-0.0", + 2: "car-west_1_0-east_1_max--85270-291315-1-0.0", + 3: "car-west_2_0-east_2_max--63247--53682-2-0.0", 4: "AGENT_1", }, [], diff --git a/smarts/core/tests/test_trap_manager.py b/smarts/core/tests/test_trap_manager.py index 3929002744..c82724a375 100644 --- a/smarts/core/tests/test_trap_manager.py +++ b/smarts/core/tests/test_trap_manager.py @@ -165,11 +165,11 @@ def smarts_two_agents(): def test_capture_vehicle(smarts: SMARTS, scenarios, traffic_sim): smarts.reset(next(scenarios)) if traffic_sim == "SMARTS": - vehicle_prefix = "actor-car" + vehicle_prefix = "car" vehicle_id = list(smarts.vehicle_index.agent_vehicle_ids())[0] assert vehicle_id.startswith(vehicle_prefix) else: - vehicle_prefix = "car-flow-route-west_1_0-east_1_max" + vehicle_prefix = "car-west_1_0-east_1_max" vehicle_id = list(smarts.vehicle_index.agent_vehicle_ids())[0] assert vehicle_id.startswith(vehicle_prefix) assert smarts.elapsed_sim_time < 1 diff --git a/smarts/core/utils/tests/fixtures.py b/smarts/core/utils/tests/fixtures.py index 69f562ad0a..0eb560b340 100644 --- a/smarts/core/utils/tests/fixtures.py +++ b/smarts/core/utils/tests/fixtures.py @@ -101,7 +101,7 @@ def large_observation(): under_this_agent_control=True, neighborhood_vehicle_states=[ VehicleObservation( - id="car-flow-route-west_0_0-east_0_max-7845114534199723832--7266489842092764092--0-0.0", + id="car-west_0_0-east_0_max-784511-726648-0-0.0", position=(-1.33354215, -3.2, 0.0), bounding_box=Dimensions(length=3.68, width=1.47, height=1.4), heading=Heading(-1.5707963267948966), @@ -112,7 +112,7 @@ def large_observation(): lane_position=RefLinePoint(-1.33354215, 0.0, 0.0), ), VehicleObservation( - id="car-flow-route-west_1_0-east_1_max--852708111940723884--7266489842092764092--1-0.0", + id="car-west_1_0-east_1_max--85270-726648-1-0.0", position=(-1.47159011, 0.0, 0.0), bounding_box=Dimensions(length=3.68, width=1.47, height=1.4), heading=Heading(-1.5707963267948966), diff --git a/smarts/sstudio/types.py b/smarts/sstudio/types.py index c7f0e9cac1..66063cf2cf 100644 --- a/smarts/sstudio/types.py +++ b/smarts/sstudio/types.py @@ -306,7 +306,7 @@ def __hash__(self) -> int: @property def id(self) -> str: """The identifier tag of the traffic actor.""" - return "actor-{}-{}".format(self.name, hash(self)) + return "{}-{}".format(self.name, str(hash(self))[:6]) @dataclass(frozen=True) @@ -420,10 +420,10 @@ class Route: @property def id(self) -> str: """The unique id of this route.""" - return "route-{}-{}-{}-".format( + return "{}-{}-{}".format( "_".join(map(str, self.begin)), "_".join(map(str, self.end)), - pickle_hash_int(self), + str(hash(self))[:6], ) @property @@ -485,9 +485,9 @@ class Flow: @property def id(self) -> str: """The unique id of this flow.""" - return "flow-{}-{}-".format( + return "{}-{}".format( self.route.id, - str(pickle_hash_int(sorted(self.actors.items(), key=lambda a: a[0].name))), + str(hash(self))[:6], ) def __hash__(self): From 7424cbfb8d8c9a1f2e9cb7083a8eb03406333e01 Mon Sep 17 00:00:00 2001 From: Tucker Date: Fri, 14 Apr 2023 23:19:12 -0400 Subject: [PATCH 2/2] Fix last test. --- smarts/sstudio/tests/baseline.rou.xml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/smarts/sstudio/tests/baseline.rou.xml b/smarts/sstudio/tests/baseline.rou.xml index fe8f176f69..e571acafa3 100644 --- a/smarts/sstudio/tests/baseline.rou.xml +++ b/smarts/sstudio/tests/baseline.rou.xml @@ -1,16 +1,15 @@ - - - + + - - + + - + - +