Skip to content
Snippets Groups Projects
Commit cd33c5c7 authored by u229589's avatar u229589
Browse files

add visualization for distance map

parent dd6ae4da
No related branches found
No related tags found
No related merge requests found
import numpy as np
import matplotlib.pyplot as plt
from flatland.envs.distance_map import DistanceMap
from flatland.envs.observations import TreeObsForRailEnv
from flatland.envs.predictions import ShortestPathPredictorForRailEnv
from flatland.envs.rail_env import RailEnv
......@@ -17,3 +21,11 @@ def load_flatland_environment_from_file(file_name, load_from_package=None, obs_b
schedule_generator=schedule_from_file(file_name, load_from_package),
obs_builder_object=obs_builder_object)
return environment
def visualize_distance_map(distance_map: DistanceMap, agent_handle: int = 0):
assert agent_handle < distance_map.get().shape[0]
# take min value of all 4 directions
min_distance_map = np.min(distance_map.get(), axis=3)
plt.imshow(min_distance_map[agent_handle][:][:])
plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment