From c34190a58e530563d5108a5555533225d119bc39 Mon Sep 17 00:00:00 2001 From: Tucker Date: Fri, 17 Mar 2023 17:14:09 -0400 Subject: [PATCH 1/9] Add initial solution for agent coloring. --- smarts/core/renderer.py | 39 ++++++++++++++++++++++++----- smarts/core/scenario.py | 20 +++++++++++++++ smarts/core/smarts.py | 1 - smarts/core/tests/test_renderers.py | 2 +- smarts/core/vehicle.py | 11 ++++---- smarts/core/vehicle_index.py | 6 +++-- smarts/sstudio/genscenario.py | 28 ++++++++++++++++++++- smarts/sstudio/types.py | 25 +++++++++++++++++- 8 files changed, 115 insertions(+), 17 deletions(-) diff --git a/smarts/core/renderer.py b/smarts/core/renderer.py index 7252fc7949..3fd13e9fdb 100644 --- a/smarts/core/renderer.py +++ b/smarts/core/renderer.py @@ -25,10 +25,12 @@ import importlib.resources as pkg_resources import logging import os +import re from enum import IntEnum from pathlib import Path +from re import Pattern from threading import Lock -from typing import NamedTuple +from typing import NamedTuple, Optional import gltf from direct.showbase.ShowBase import ShowBase @@ -196,6 +198,8 @@ def __init__(self, simid: str, debug_mode: DEBUG_MODE = DEBUG_MODE.ERROR): # Note: Each instance of the SMARTS simulation will have its own Renderer, # but all Renderer objects share the same ShowBaseInstance. self._showbase_instance: _ShowBaseInstance = _ShowBaseInstance() + self._interest_filter: Optional[Pattern] = None + self._interest_color: Optional[SceneColors] = None @property def id(self): @@ -304,7 +308,14 @@ def setup(self, scenario: Scenario): "Resolution", self._showbase_instance.getSize() ) self._dashed_lines_np = dashed_lines_np - + if scenario_metadata := scenario.metadata: + if interest_pattern := scenario_metadata.get( + "actor_of_interest_re_filter", None + ): + self._interest_filter = re.compile(interest_pattern) + self._interest_color = scenario_metadata.get( + "actor_of_interest_color", SceneColors.SocialAgent + ) self._is_setup = True def render(self): @@ -335,12 +346,28 @@ def destroy(self): def __del__(self): self.destroy() - def create_vehicle_node(self, glb_model: str, vid: str, color, pose: Pose): + def set_interest(self, interest_filter: Pattern, interest_color: SceneColors): + """Sets the color of all vehicles that have ids that match the given pattern. + + Args: + interest_filter (Pattern): The regular expression pattern to match. + interest_color (SceneColors): The color that the vehicle should show as. + """ + assert isinstance(interest_filter, Pattern) + self._interest_filter = interest_filter + self._interest_color = interest_color + + def create_vehicle_node( + self, glb_model: str, vid: str, color: SceneColors, pose: Pose + ): """Create a vehicle node.""" with pkg_resources.path(models, glb_model) as path: node_path = self._showbase_instance.loader.loadModel(str(path.absolute())) node_path.setName("vehicle-%s" % vid) - node_path.setColor(color) + if self._interest_filter is not None and self._interest_color is not None: + node_path.setColor(self._interest_color.value) + else: + node_path.setColor(color.value) pos, heading = pose.as_panda3d() node_path.setPosHpr(*pos, heading, 0, 0) node_path.hide(RenderMasks.DRIVABLE_AREA_HIDE) @@ -350,7 +377,7 @@ def begin_rendering_vehicle(self, vid: str, is_agent: bool): """Add the vehicle node to the scene graph""" vehicle_path = self._vehicle_nodes.get(vid, None) if not vehicle_path: - self._log.warning(f"Renderer ignoring invalid vehicle id: {vid}") + self._log.warning("Renderer ignoring invalid vehicle id: %s", vid) return # TAI: consider reparenting hijacked vehicles too? vehicle_path.reparentTo(self._vehicles_np if is_agent else self._root_np) @@ -359,7 +386,7 @@ def update_vehicle_node(self, vid: str, pose: Pose): """Move the specified vehicle node.""" vehicle_path = self._vehicle_nodes.get(vid, None) if not vehicle_path: - self._log.warning(f"Renderer ignoring invalid vehicle id: {vid}") + self._log.warning("Renderer ignoring invalid vehicle id: %s", vid) return pos, heading = pose.as_panda3d() vehicle_path.setPosHpr(*pos, heading, 0, 0) diff --git a/smarts/core/scenario.py b/smarts/core/scenario.py index b1079c8297..cf6591fc45 100644 --- a/smarts/core/scenario.py +++ b/smarts/core/scenario.py @@ -125,6 +125,7 @@ def __init__( self._traffic_specs = [os.path.join(traffic_path, route)] self._missions = missions or {} self._bubbles = Scenario._discover_bubbles(scenario_root) + self._metadata = Scenario._discover_metadata(scenario_root) self._social_agents = social_agents or {} self._surface_patches = surface_patches self._log_dir = self._resolve_log_dir(log_dir) @@ -547,6 +548,16 @@ def _discover_bubbles(scenario_root): bubbles = pickle.load(f) return bubbles + @staticmethod + def _discover_metadata(scenario_root): + path = os.path.join(scenario_root, "build", "scenario_metadata.pkl") + if not os.path.exists(path): + return dict() + + with open(path, "rb") as f: + metadata = pickle.load(f) + return metadata + def set_ego_missions(self, ego_missions: Dict[str, Mission]): """Replaces the ego missions within the scenario. Args: @@ -1053,3 +1064,12 @@ def traffic_history(self) -> Optional[TrafficHistory]: def scenario_hash(self) -> str: """A hash of the scenario.""" return self._scenario_hash + + @property + def metadata(self) -> Dict: + """Scenario metadata values. + + Returns: + Dict: The values. + """ + return self._metadata or {} diff --git a/smarts/core/smarts.py b/smarts/core/smarts.py index bb05836e47..9578d2b44a 100644 --- a/smarts/core/smarts.py +++ b/smarts/core/smarts.py @@ -1074,7 +1074,6 @@ def _pybullet_provider_sync(self, provider_state: ProviderState): vehicle_state=vehicle, actor_id=vehicle_id, vehicle_id=vehicle_id, - vehicle_config_type=vehicle.vehicle_config_type, ) if not vehicle.updated: diff --git a/smarts/core/tests/test_renderers.py b/smarts/core/tests/test_renderers.py index 82df2c7091..f03a121a7e 100644 --- a/smarts/core/tests/test_renderers.py +++ b/smarts/core/tests/test_renderers.py @@ -124,7 +124,7 @@ def test_renderer(self): heading_=Heading(math.pi * 0.91), ) self._rdr.create_vehicle_node( - "simple_car.glb", self._vid, SceneColors.SocialVehicle.value, pose + "simple_car.glb", self._vid, SceneColors.SocialVehicle, pose ) self._rdr.begin_rendering_vehicle(self._vid, is_agent=False) for s in range(self._num_steps): diff --git a/smarts/core/vehicle.py b/smarts/core/vehicle.py index 4a8cd923b8..d92f5d0ec5 100644 --- a/smarts/core/vehicle.py +++ b/smarts/core/vehicle.py @@ -442,12 +442,11 @@ def build_agent_vehicle( return vehicle @staticmethod - def build_social_vehicle( - sim, vehicle_id, vehicle_state, vehicle_config_type - ) -> "Vehicle": + def build_social_vehicle(sim, vehicle_id, vehicle_state: VehicleState) -> "Vehicle": """Create a new unassociated vehicle.""" dims = Dimensions.copy_with_defaults( - vehicle_state.dimensions, VEHICLE_CONFIGS[vehicle_config_type].dimensions + vehicle_state.dimensions, + VEHICLE_CONFIGS[vehicle_state.vehicle_config_type].dimensions, ) chassis = BoxChassis( pose=vehicle_state.pose, @@ -456,7 +455,9 @@ def build_social_vehicle( bullet_client=sim.bc, ) return Vehicle( - id=vehicle_id, chassis=chassis, vehicle_config_type=vehicle_config_type + id=vehicle_id, + chassis=chassis, + vehicle_config_type=vehicle_state.vehicle_config_type, ) @staticmethod diff --git a/smarts/core/vehicle_index.py b/smarts/core/vehicle_index.py index 32572045f4..9ea9d978cb 100644 --- a/smarts/core/vehicle_index.py +++ b/smarts/core/vehicle_index.py @@ -734,14 +734,16 @@ def _enfranchise_actor( @clear_cache def build_social_vehicle( - self, sim, vehicle_state, actor_id, vehicle_config_type, vehicle_id=None + self, sim, vehicle_state, actor_id, vehicle_id=None ) -> Vehicle: """Build an entirely new vehicle for a social agent.""" if vehicle_id is None: vehicle_id = gen_id() vehicle = Vehicle.build_social_vehicle( - sim, vehicle_id, vehicle_state, vehicle_config_type + sim, + vehicle_id, + vehicle_state, ) vehicle_id, actor_id = _2id(vehicle_id), _2id(actor_id) diff --git a/smarts/sstudio/genscenario.py b/smarts/sstudio/genscenario.py index 31d7287bf0..91b85fe01d 100644 --- a/smarts/sstudio/genscenario.py +++ b/smarts/sstudio/genscenario.py @@ -28,7 +28,7 @@ import os import pickle import sqlite3 -from dataclasses import replace +from dataclasses import asdict, replace from pathlib import Path from typing import Any, Dict, List, Optional, Sequence, Tuple, Union @@ -92,6 +92,9 @@ def _build_graph(scenario: types.Scenario, base_dir: str) -> Dict[str, Any]: artifact_path = os.path.join(base_dir, f"{dataset.name}.shf") graph["traffic_histories"].append(artifact_path) + if scenario.scenario_metadata: + graph["scenario_metadata"] = [os.path.join(base_dir, "scenario_metadata.json")] + return graph @@ -328,6 +331,16 @@ def gen_scenario( ) _update_artifacts(db_conn, artifact_paths, obj_hash) + # Scenario metadata + if _needs_build( + db_conn, scenario.traffic, artifact_paths, obj_hash, map_needs_rebuild + ): + with timeit("scenario metadata", logger.info): + gen_metadata( + scenario=output_dir, + scenario_metadata=scenario.scenario_metadata, + ) + def gen_map(scenario: str, map_spec: types.MapSpec, output_dir: Optional[str] = None): """Saves a map spec to file.""" @@ -658,3 +671,16 @@ def gen_traffic_histories( ) output_dir = os.path.join(scenario, "build") genhistories.import_dataset(hdsr, output_dir, map_bbox) + + +def gen_metadata(scenario: str, scenario_metadata: types.ScenarioMetadata): + """Generate the metadata for the scenario + + Args: + scenario (str):The scenario directory + scenario_metadata (types.ScenarioMetadata): _description_ + """ + _check_if_called_externally() + output_path = os.path.join(scenario, "build", "scenario_metadata.pkl") + with open(output_path, "wb") as f: + pickle.dump(asdict(scenario_metadata), f) diff --git a/smarts/sstudio/types.py b/smarts/sstudio/types.py index 7bc7d35f27..3f9c28ebe9 100644 --- a/smarts/sstudio/types.py +++ b/smarts/sstudio/types.py @@ -24,7 +24,17 @@ from dataclasses import dataclass, field from enum import IntEnum from sys import maxsize -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union +from typing import ( + Any, + Callable, + Dict, + FrozenSet, + List, + Optional, + Sequence, + Tuple, + Union, +) import numpy as np from shapely.affinity import rotate as shapely_rotate @@ -40,6 +50,7 @@ from shapely.ops import split, unary_union from smarts.core import gen_id +from smarts.core.colors import Colors, SceneColors from smarts.core.coordinates import RefLinePoint from smarts.core.default_map_builder import get_road_map from smarts.core.road_map import RoadMap @@ -1062,6 +1073,16 @@ class TrafficHistoryDataset: """A heading in radians to be used by default for vehicles if the headings are not present in the dataset and cannot be inferred from position changes (such as on the first time step).""" +@dataclass(frozen=True) +class ScenarioMetadata: + """Scenario data that does not have influence on simulation.""" + + actor_of_interest_re_filter: Optional[FrozenSet[str]] = None + """Vehicles with names that match this pattern are vehicles of interest.""" + actor_of_interest_color: SceneColors + """The color that the vehicles of interest should have.""" + + @dataclass(frozen=True) class Scenario: """The sstudio scenario representation.""" @@ -1087,3 +1108,5 @@ class Scenario: """Friction coefficient of patches of road surface.""" traffic_histories: Optional[Sequence[Union[TrafficHistoryDataset, str]]] = None """Traffic vehicles trajectory dataset to be replayed.""" + scenario_metadata: Optional[ScenarioMetadata] = None + """"Scenario data that does not have influence on simulation.""" From 604786731c6e5c8009c5d5f81ac3ffa5eb07307b Mon Sep 17 00:00:00 2001 From: Tucker Date: Fri, 17 Mar 2023 17:21:56 -0400 Subject: [PATCH 2/9] Fix positional after default. --- smarts/sstudio/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smarts/sstudio/types.py b/smarts/sstudio/types.py index 3f9c28ebe9..a86c13036e 100644 --- a/smarts/sstudio/types.py +++ b/smarts/sstudio/types.py @@ -1077,7 +1077,7 @@ class TrafficHistoryDataset: class ScenarioMetadata: """Scenario data that does not have influence on simulation.""" - actor_of_interest_re_filter: Optional[FrozenSet[str]] = None + actor_of_interest_re_filter: FrozenSet[str] """Vehicles with names that match this pattern are vehicles of interest.""" actor_of_interest_color: SceneColors """The color that the vehicles of interest should have.""" From 144c3c87ded49716dd3f0fd96e3479c82f7c8aff Mon Sep 17 00:00:00 2001 From: Tucker Date: Fri, 17 Mar 2023 17:33:41 -0400 Subject: [PATCH 3/9] Fix build requirement. --- smarts/sstudio/genscenario.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/smarts/sstudio/genscenario.py b/smarts/sstudio/genscenario.py index 91b85fe01d..2f7ffd2934 100644 --- a/smarts/sstudio/genscenario.py +++ b/smarts/sstudio/genscenario.py @@ -332,10 +332,12 @@ def gen_scenario( _update_artifacts(db_conn, artifact_paths, obj_hash) # Scenario metadata + artifact_paths = build_graph["scenario_metadata"] + obj_hash = pickle_hash(scenario.scenario_metadata, True) if _needs_build( db_conn, scenario.traffic, artifact_paths, obj_hash, map_needs_rebuild ): - with timeit("scenario metadata", logger.info): + with timeit("scenario_metadata", logger.info): gen_metadata( scenario=output_dir, scenario_metadata=scenario.scenario_metadata, From 511871d836679a6b013f0ed58e424f02ea845420 Mon Sep 17 00:00:00 2001 From: Tucker Date: Fri, 17 Mar 2023 17:47:42 -0400 Subject: [PATCH 4/9] Fix build further. --- smarts/sstudio/genscenario.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smarts/sstudio/genscenario.py b/smarts/sstudio/genscenario.py index 2f7ffd2934..fd3b1ec643 100644 --- a/smarts/sstudio/genscenario.py +++ b/smarts/sstudio/genscenario.py @@ -92,7 +92,7 @@ def _build_graph(scenario: types.Scenario, base_dir: str) -> Dict[str, Any]: artifact_path = os.path.join(base_dir, f"{dataset.name}.shf") graph["traffic_histories"].append(artifact_path) - if scenario.scenario_metadata: + if scenario.scenario_metadata is not None: graph["scenario_metadata"] = [os.path.join(base_dir, "scenario_metadata.json")] return graph @@ -335,7 +335,7 @@ def gen_scenario( artifact_paths = build_graph["scenario_metadata"] obj_hash = pickle_hash(scenario.scenario_metadata, True) if _needs_build( - db_conn, scenario.traffic, artifact_paths, obj_hash, map_needs_rebuild + db_conn, scenario.scenario_metadata, artifact_paths, obj_hash, map_needs_rebuild ): with timeit("scenario_metadata", logger.info): gen_metadata( From 82d65daf238212ce69a38f97652e5b2861555a32 Mon Sep 17 00:00:00 2001 From: Tucker Date: Fri, 17 Mar 2023 18:08:13 -0400 Subject: [PATCH 5/9] Ensure color is typed --- smarts/core/vehicle.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/smarts/core/vehicle.py b/smarts/core/vehicle.py index d92f5d0ec5..d2f7a333db 100644 --- a/smarts/core/vehicle.py +++ b/smarts/core/vehicle.py @@ -106,43 +106,43 @@ class VehicleConfig: VEHICLE_CONFIGS = { "passenger": VehicleConfig( vehicle_type="car", - color=SceneColors.SocialVehicle.value, + color=SceneColors.SocialVehicle, dimensions=Dimensions(length=3.68, width=1.47, height=1.4), glb_model="simple_car.glb", ), "bus": VehicleConfig( vehicle_type="bus", - color=SceneColors.SocialVehicle.value, + color=SceneColors.SocialVehicle, dimensions=Dimensions(length=7, width=2.25, height=3), glb_model="bus.glb", ), "coach": VehicleConfig( vehicle_type="coach", - color=SceneColors.SocialVehicle.value, + color=SceneColors.SocialVehicle, dimensions=Dimensions(length=8, width=2.4, height=3.5), glb_model="coach.glb", ), "truck": VehicleConfig( vehicle_type="truck", - color=SceneColors.SocialVehicle.value, + color=SceneColors.SocialVehicle, dimensions=Dimensions(length=5, width=1.91, height=1.89), glb_model="truck.glb", ), "trailer": VehicleConfig( vehicle_type="trailer", - color=SceneColors.SocialVehicle.value, + color=SceneColors.SocialVehicle, dimensions=Dimensions(length=10, width=2.5, height=4), glb_model="trailer.glb", ), "pedestrian": VehicleConfig( vehicle_type="pedestrian", - color=SceneColors.SocialVehicle.value, + color=SceneColors.SocialVehicle, dimensions=Dimensions(length=0.5, width=0.5, height=1.6), glb_model="pedestrian.glb", ), "motorcycle": VehicleConfig( vehicle_type="motorcycle", - color=SceneColors.SocialVehicle.value, + color=SceneColors.SocialVehicle, dimensions=Dimensions(length=2.5, width=1, height=1.4), glb_model="motorcycle.glb", ), @@ -252,7 +252,7 @@ def renderer(self): # type: ignore # self._chassis.speed = speed @property - def vehicle_color(self) -> Union[SceneColors, Tuple, None]: + def vehicle_color(self) -> Union[SceneColors, None]: """The color of this vehicle (generally used for rendering purposes.)""" self._assert_initialized() return self._color @@ -390,9 +390,7 @@ def build_agent_vehicle( else: start_pose = Pose.from_center(start.position, start.heading) - vehicle_color = ( - SceneColors.Agent.value if trainable else SceneColors.SocialAgent.value - ) + vehicle_color = SceneColors.Agent if trainable else SceneColors.SocialAgent if agent_interface.vehicle_type == "sedan": urdf_name = "vehicle" From cf32d786708649c391d68ce69f2ff353373699ac Mon Sep 17 00:00:00 2001 From: Tucker Date: Tue, 21 Mar 2023 09:25:06 -0400 Subject: [PATCH 6/9] Ensure coloring works as intended --- scenarios/sumo/intersections/4lane_t/scenario.py | 9 ++++++--- smarts/core/renderer.py | 16 ++++++++++------ smarts/sstudio/genscenario.py | 2 +- smarts/sstudio/types.py | 6 +++--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/scenarios/sumo/intersections/4lane_t/scenario.py b/scenarios/sumo/intersections/4lane_t/scenario.py index 075fd41ebb..b183f6a2c8 100644 --- a/scenarios/sumo/intersections/4lane_t/scenario.py +++ b/scenarios/sumo/intersections/4lane_t/scenario.py @@ -1,5 +1,6 @@ from pathlib import Path +from smarts.core.colors import Colors from smarts.sstudio import gen_scenario from smarts.sstudio import types as t @@ -21,7 +22,8 @@ rate=400, actors={t.TrafficActor("car"): 1}, ), - ] + ], + engine="SMARTS", ) agent_prefabs = "scenarios.sumo.intersections.4lane_t.agent_prefabs" @@ -61,12 +63,12 @@ bubbles = [ t.Bubble( zone=t.MapZone(start=("edge-west-WE", 0, 50), length=10, n_lanes=1), - margin=2, + margin=0, actor=zoo_agent_actor, ), t.Bubble( zone=t.PositionalZone(pos=(100, 100), size=(20, 20)), - margin=2, + margin=0, actor=motion_planner_actor, ), ] @@ -99,6 +101,7 @@ bubbles=bubbles, ego_missions=ego_missions, social_agent_missions=social_agent_missions, + scenario_metadata=t.ScenarioMetadata(r".*-1.*", Colors.Yellow), ), output_dir=Path(__file__).parent, ) diff --git a/smarts/core/renderer.py b/smarts/core/renderer.py index 3fd13e9fdb..613b02a389 100644 --- a/smarts/core/renderer.py +++ b/smarts/core/renderer.py @@ -30,7 +30,7 @@ from pathlib import Path from re import Pattern from threading import Lock -from typing import NamedTuple, Optional +from typing import NamedTuple, Optional, Union import gltf from direct.showbase.ShowBase import ShowBase @@ -56,7 +56,7 @@ ) from . import glsl, models -from .colors import SceneColors +from .colors import Colors, SceneColors from .coordinates import Pose from .masks import RenderMasks from .scenario import Scenario @@ -346,25 +346,29 @@ def destroy(self): def __del__(self): self.destroy() - def set_interest(self, interest_filter: Pattern, interest_color: SceneColors): + def set_interest(self, interest_filter: Pattern, interest_color: Colors): """Sets the color of all vehicles that have ids that match the given pattern. Args: interest_filter (Pattern): The regular expression pattern to match. - interest_color (SceneColors): The color that the vehicle should show as. + interest_color (Colors): The color that the vehicle should show as. """ assert isinstance(interest_filter, Pattern) self._interest_filter = interest_filter self._interest_color = interest_color def create_vehicle_node( - self, glb_model: str, vid: str, color: SceneColors, pose: Pose + self, glb_model: str, vid: str, color: Union[Colors, SceneColors], pose: Pose ): """Create a vehicle node.""" with pkg_resources.path(models, glb_model) as path: node_path = self._showbase_instance.loader.loadModel(str(path.absolute())) node_path.setName("vehicle-%s" % vid) - if self._interest_filter is not None and self._interest_color is not None: + if ( + self._interest_filter is not None + and self._interest_color is not None + and self._interest_filter.match(vid) + ): node_path.setColor(self._interest_color.value) else: node_path.setColor(color.value) diff --git a/smarts/sstudio/genscenario.py b/smarts/sstudio/genscenario.py index fd3b1ec643..3eb22fa470 100644 --- a/smarts/sstudio/genscenario.py +++ b/smarts/sstudio/genscenario.py @@ -93,7 +93,7 @@ def _build_graph(scenario: types.Scenario, base_dir: str) -> Dict[str, Any]: graph["traffic_histories"].append(artifact_path) if scenario.scenario_metadata is not None: - graph["scenario_metadata"] = [os.path.join(base_dir, "scenario_metadata.json")] + graph["scenario_metadata"] = [os.path.join(base_dir, "scenario_metadata.pkl")] return graph diff --git a/smarts/sstudio/types.py b/smarts/sstudio/types.py index a86c13036e..0c1768ae1b 100644 --- a/smarts/sstudio/types.py +++ b/smarts/sstudio/types.py @@ -50,7 +50,7 @@ from shapely.ops import split, unary_union from smarts.core import gen_id -from smarts.core.colors import Colors, SceneColors +from smarts.core.colors import Colors from smarts.core.coordinates import RefLinePoint from smarts.core.default_map_builder import get_road_map from smarts.core.road_map import RoadMap @@ -1077,9 +1077,9 @@ class TrafficHistoryDataset: class ScenarioMetadata: """Scenario data that does not have influence on simulation.""" - actor_of_interest_re_filter: FrozenSet[str] + actor_of_interest_re_filter: str """Vehicles with names that match this pattern are vehicles of interest.""" - actor_of_interest_color: SceneColors + actor_of_interest_color: Colors """The color that the vehicles of interest should have.""" From 7f8780fef61ea69161712ac11ea8bab5c70192df Mon Sep 17 00:00:00 2001 From: Tucker Date: Tue, 21 Mar 2023 10:38:53 -0400 Subject: [PATCH 7/9] Update color. --- smarts/core/renderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smarts/core/renderer.py b/smarts/core/renderer.py index 613b02a389..4f16a614f9 100644 --- a/smarts/core/renderer.py +++ b/smarts/core/renderer.py @@ -199,7 +199,7 @@ def __init__(self, simid: str, debug_mode: DEBUG_MODE = DEBUG_MODE.ERROR): # but all Renderer objects share the same ShowBaseInstance. self._showbase_instance: _ShowBaseInstance = _ShowBaseInstance() self._interest_filter: Optional[Pattern] = None - self._interest_color: Optional[SceneColors] = None + self._interest_color: Optional[Union[Colors, SceneColors]] = None @property def id(self): From 39dfde4903929fddd87630cf55d9aef92cf222d6 Mon Sep 17 00:00:00 2001 From: Tucker Date: Tue, 21 Mar 2023 17:20:48 -0400 Subject: [PATCH 8/9] Revert scenario changes. --- scenarios/sumo/intersections/4lane_t/scenario.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scenarios/sumo/intersections/4lane_t/scenario.py b/scenarios/sumo/intersections/4lane_t/scenario.py index b183f6a2c8..9bfd63e9e2 100644 --- a/scenarios/sumo/intersections/4lane_t/scenario.py +++ b/scenarios/sumo/intersections/4lane_t/scenario.py @@ -22,8 +22,7 @@ rate=400, actors={t.TrafficActor("car"): 1}, ), - ], - engine="SMARTS", + ] ) agent_prefabs = "scenarios.sumo.intersections.4lane_t.agent_prefabs" @@ -63,12 +62,12 @@ bubbles = [ t.Bubble( zone=t.MapZone(start=("edge-west-WE", 0, 50), length=10, n_lanes=1), - margin=0, + margin=2, actor=zoo_agent_actor, ), t.Bubble( zone=t.PositionalZone(pos=(100, 100), size=(20, 20)), - margin=0, + margin=2, actor=motion_planner_actor, ), ] From 001c0c96a974e9f8a2e49cc90c41595c6a22dedc Mon Sep 17 00:00:00 2001 From: Tucker Date: Wed, 22 Mar 2023 17:46:33 -0400 Subject: [PATCH 9/9] Update changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a45a6bc20..73a7b99e6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Copy and pasting the git commit messages is __NOT__ enough. ### Added - Added support for the [Argoverse 2 Motion Forecasting Dataset](https://www.argoverse.org/av2.html#forecasting-link) (see `scenarios/argoverse`) - Added `waymo_open_dataset` as a module at the SMARTS repo level, to be able to load waymo scenarios without any external packages +- Added vehicle of interest coloring through scenario studio. This lets the scenario color vehicles that match a certain pattern of vehicle id. ### Changed ### Deprecated ### Fixed