From fc4f53e0ad4ed514b2bf32ec8bc940f117059ecf Mon Sep 17 00:00:00 2001 From: QuanyiLi Date: Sun, 21 Jul 2024 13:13:10 +0100 Subject: [PATCH] format --- metadrive/tests/vis_env/vis_sumo_map.py | 18 +++++++++------- metadrive/utils/sumo/map_utils.py | 28 ++++++++++++------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/metadrive/tests/vis_env/vis_sumo_map.py b/metadrive/tests/vis_env/vis_sumo_map.py index 7545ab1ad..39f4917c1 100644 --- a/metadrive/tests/vis_env/vis_sumo_map.py +++ b/metadrive/tests/vis_env/vis_sumo_map.py @@ -1,6 +1,5 @@ """use netconvert --opendrive-files CARLA_town01.net.xml first""" - from metadrive.envs import BaseEnv from metadrive.obs.observation_base import DummyObservation import logging @@ -9,7 +8,6 @@ class MyEnv(BaseEnv): - def reward_function(self, agent): return 0, {} @@ -30,12 +28,16 @@ def setup_engine(self): if __name__ == "__main__": # create env - env = MyEnv(dict(use_render=True, - # if you have a screen and OpenGL suppor, you can set use_render=True to use 3D rendering - vehicle_config={"spawn_position_heading": [(0, 0), 0]}, - manual_control=True, # we usually manually control the car to test environment - use_mesh_terrain=True, - log_level=logging.CRITICAL)) # suppress logging message + env = MyEnv( + dict( + use_render=True, + # if you have a screen and OpenGL suppor, you can set use_render=True to use 3D rendering + vehicle_config={"spawn_position_heading": [(0, 0), 0]}, + manual_control=True, # we usually manually control the car to test environment + use_mesh_terrain=True, + log_level=logging.CRITICAL + ) + ) # suppress logging message env.reset() for i in range(10000): # step diff --git a/metadrive/utils/sumo/map_utils.py b/metadrive/utils/sumo/map_utils.py index 03577a13a..b2960746a 100644 --- a/metadrive/utils/sumo/map_utils.py +++ b/metadrive/utils/sumo/map_utils.py @@ -39,9 +39,9 @@ def buffered_shape(shape, width: float = 1.0) -> Polygon: class LaneShape: def __init__( - self, - shape, - width: float, + self, + shape, + width: float, ): shape = buffered_shape(shape.getShape(), shape.getWidth()) self.shape = shape @@ -88,10 +88,7 @@ def __init__(self, sumolib_obj): self.width: float = sumolib_obj.getWidth() self.length: float = sumolib_obj.getLength() - self.shape: LaneShape = LaneShape( - sumolib_obj, - self.width - ) + self.shape: LaneShape = LaneShape(sumolib_obj, self.width) if sumolib_obj.getEdge().getFunction() == 'walkingarea': shape = [[p[0], p[1]] for p in sumolib_obj.getShape()] @@ -108,11 +105,11 @@ def __init__(self, sumolib_obj): class RoadNode: def __init__( - self, - sumolib_obj, - lanes, - from_junction, - to_junction, + self, + sumolib_obj, + lanes, + from_junction, + to_junction, ): self.sumolib_obj: sumolib.net.edge = sumolib_obj self.name: str = sumolib_obj.getID() @@ -147,8 +144,8 @@ def __init__( class RoadLaneJunctionGraph: def __init__( - self, - sumo_net_path, + self, + sumo_net_path, ): self.sumo_net = sumolib.net.readNet( @@ -205,7 +202,8 @@ def __init__( for junction_id, junction in self.junctions.items(): junction.sumolib_obj.setShape( - [(x - center_x, y - center_y, z) for x, y, z in junction.sumolib_obj.getShape3D()]) + [(x - center_x, y - center_y, z) for x, y, z in junction.sumolib_obj.getShape3D()] + ) junction.shape = junction.sumolib_obj.getShape() for junction_id, junction in self.junctions.items():