Skip to content

Commit

Permalink
update script for creating edt
Browse files Browse the repository at this point in the history
  • Loading branch information
hzheng40 committed Feb 28, 2024
1 parent c9a589b commit 21a9e44
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions examples/create_edt.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
from f110_gym.envs.track import Track
from scipy.ndimage import distance_transform_edt as edt
import argparse
import numpy as np

parser = argparse.ArgumentParser()
parser.add_argument("--track_name", type=str, required=True)
args = parser.parse_args()
DEFAULT_MAP_NAMES = [
"Austin",
"BrandsHatch",
"Budapest",
"Catalunya",
"Hockenheim",
"IMS",
"Melbourne",
"MexicoCity",
"Montreal",
"Monza",
"MoscowRaceway",
"Nuerburgring",
"Oschersleben",
"Sakhir",
"SaoPaulo",
"Sepang",
"Shanghai",
"Silverstone",
"Sochi",
"Spa",
"Spielberg",
"YasMarina",
"Zandvoort",
]

print("Loading a map without edt, a warning should appear")
track = Track.from_track_name(args.track_name)
occupancy_map = track.occupancy_map
resolution = track.spec.resolution
for track_name in DEFAULT_MAP_NAMES:
print("Loading a map without edt, a warning should appear")
track = Track.from_track_name(track_name)
occupancy_map = track.occupancy_map
resolution = track.spec.resolution

dt = resolution * edt(occupancy_map)
dt = resolution * edt(occupancy_map)

# saving
np.save(track.filepath, dt)
# saving
np.save(track.filepath, dt)

print("Loading a map with edt, warning should no longer appear")
track_wedt = Track.from_track_name(args.track_name)
print("Loading a map with edt, warning should no longer appear")
track_wedt = Track.from_track_name(track_name)

0 comments on commit 21a9e44

Please sign in to comment.