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

testing

parent ae2799cc
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Plot the Env and some trees
%% Cell type:code id: tags:
``` python
%load_ext autoreload
%autoreload 2
```
%% Cell type:code id: tags:
``` python
import jpy_canvas
import random
import time
import sys
```
%% Cell type:code id: tags:
``` python
# in case you need to tweak your PYTHONPATH...
sys.path.append("../flatland")
```
%% Cell type:code id: tags:
``` python
import flatland.core.env
import flatland.utils.rendertools as rt
from flatland.envs.rail_env import RailEnv, random_rail_generator
from flatland.envs.observations import TreeObsForRailEnv
```
%% Cell type:code id: tags:
``` python
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:90% !important; }</style>"))
```
%% Output
%% Cell type:markdown id: tags:
# Generate
%% Cell type:code id: tags:
``` python
nAgents = 3
fnMethod = random_rail_generator(cell_type_relative_proportion=[1] * 11)
env = RailEnv(width=20,
height=10,
rail_generator=fnMethod,
number_of_agents=nAgents,
obs_builder_object=TreeObsForRailEnv(max_depth=2))
```
%% Cell type:markdown id: tags:
# Render
%% Cell type:code id: tags:
``` python
oRT = rt.RenderTool(env,gl="PILSVG")
oRT.render_env()
oRT.render_env(show_observations=True,show_predictions=False)
img = oRT.get_image()
```
%% Output
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-7-5e6388f30b6b> in <module>
1 oRT = rt.RenderTool(env,gl="PILSVG")
2 oRT.render_env()
----> 3 img = oRT.get_image()
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.2.0-py3.6.egg\flatland\utils\rendertools.py in get_image(self)
418
419 def get_image(self):
--> 420 return self.gl.get_image()
421
422 def render_env_pil(self,
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.2.0-py3.6.egg\flatland\utils\graphics_pil.py in get_image(self)
216 with layer 0 at the "back".
217 """
--> 218 img = self.alpha_composite_layers()
219 return array(img)
220
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.2.0-py3.6.egg\flatland\utils\graphics_pil.py in alpha_composite_layers(self)
209 img = self.layers[0]
210 for img2 in self.layers[1:]:
--> 211 img = Image.alpha_composite(img, img2)
212 return img
213
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\PIL\Image.py in alpha_composite(im1, im2)
2703 im1.load()
2704 im2.load()
-> 2705 return im1._new(core.alpha_composite(im1.im, im2.im))
2706
2707
ValueError: images do not match
%% Cell type:code id: tags:
``` python
jpy_canvas.Canvas(img)
```
%% Cell type:code id: tags:
``` python
oRT = rt.RenderTool(env,gl="PIL")
oRT.render_env()
img = oRT.get_image()
```
%% Cell type:code id: tags:
``` python
jpy_canvas.Canvas(img)
```
......
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