Skip to content
Snippets Groups Projects
Commit 3c61da9f authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

bug fix

parent e02f332b
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Plot the Env and some trees # Plot the Env and some trees
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
%load_ext autoreload %load_ext autoreload
%autoreload 2 %autoreload 2
``` ```
%% Output
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import jpy_canvas import jpy_canvas
import random import random
import time import time
import sys import sys
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# in case you need to tweak your PYTHONPATH... # in case you need to tweak your PYTHONPATH...
sys.path.append("../flatland") sys.path.append("../flatland")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import flatland.core.env import flatland.core.env
import flatland.utils.rendertools as rt import flatland.utils.rendertools as rt
from flatland.envs.rail_env import RailEnv, random_rail_generator from flatland.envs.rail_env import RailEnv, random_rail_generator
from flatland.envs.observations import TreeObsForRailEnv from flatland.envs.observations import TreeObsForRailEnv
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
from IPython.core.display import display, HTML from IPython.core.display import display, HTML
display(HTML("<style>.container { width:90% !important; }</style>")) display(HTML("<style>.container { width:90% !important; }</style>"))
``` ```
%% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Generate # Generate
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
nAgents = 3 nAgents = 3
fnMethod = random_rail_generator(cell_type_relative_proportion=[1] * 11) fnMethod = random_rail_generator(cell_type_relative_proportion=[1] * 11)
env = RailEnv(width=20, env = RailEnv(width=20,
height=10, height=10,
rail_generator=fnMethod, rail_generator=fnMethod,
number_of_agents=nAgents, number_of_agents=nAgents,
obs_builder_object=TreeObsForRailEnv(max_depth=2)) obs_builder_object=TreeObsForRailEnv(max_depth=2))
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Render # Render
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
oRT = rt.RenderTool(env,gl="PILSVG") oRT = rt.RenderTool(env,gl="PILSVG")
env.dev_pred_dict = env.dev_obs_dict env.dev_pred_dict = env.dev_obs_dict
oRT.render_env(show_observations=True,show_predictions=True) oRT.render_env(show_observations=False,show_predictions=True)
img = oRT.get_image() img = oRT.get_image()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
jpy_canvas.Canvas(img) jpy_canvas.Canvas(img)
``` ```
%% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
oRT = rt.RenderTool(env,gl="PIL") oRT = rt.RenderTool(env,gl="PIL")
oRT.render_env() oRT.render_env()
img = oRT.get_image() img = oRT.get_image()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
jpy_canvas.Canvas(img) jpy_canvas.Canvas(img)
``` ```
%% Output
......
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