-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
"requests", | ||
"shapely", | ||
"opencv-python", | ||
"jax[cpu]", | ||
], | ||
extras_require={ | ||
"dev": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from f110_gym.envs.utils import edt as jedt | ||
from scipy.ndimage import distance_transform_edt as edt | ||
from f110_gym.envs.track import Track | ||
import numpy as np | ||
import jax.numpy as jnp | ||
|
||
track = Track.from_track_name("Spielberg") | ||
map_img_real = track.occupancy_map | ||
|
||
map_img = 255 * np.ones((5, 5)) | ||
map_img[2, 3] = 0 | ||
|
||
dt = edt(map_img) | ||
jdt = jedt(jnp.array(map_img)) | ||
|
||
print(map_img) | ||
print('------') | ||
print(dt) | ||
print('------') | ||
print(jdt) | ||
assert np.allclose(dt, jdt) | ||
print(f"Transforms equal: {np.allclose(dt, jdt)}.") | ||
|
||
# benchmark | ||
import timeit | ||
|
||
print(timeit.timeit("edt(map_img)", globals=globals())) | ||
print(timeit.timeit("jedt(jnp.array(map_img))", globals=globals())) |