Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
QuanyiLi committed Jul 21, 2024
1 parent 4fe9239 commit fc4f53e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
18 changes: 10 additions & 8 deletions metadrive/tests/vis_env/vis_sumo_map.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,7 +8,6 @@


class MyEnv(BaseEnv):

def reward_function(self, agent):
return 0, {}

Expand All @@ -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
Expand Down
28 changes: 13 additions & 15 deletions metadrive/utils/sumo/map_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()]
Expand All @@ -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()
Expand Down Expand Up @@ -147,8 +144,8 @@ def __init__(

class RoadLaneJunctionGraph:
def __init__(
self,
sumo_net_path,
self,
sumo_net_path,
):

self.sumo_net = sumolib.net.readNet(
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit fc4f53e

Please sign in to comment.