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

Jupyter notebook simplified

parent 23e281fd
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Railway Scene Editor # Railway Scene Editor
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
%load_ext autoreload
%autoreload 2
```
%% Cell type:code id: tags:
``` python
import numpy as np
from numpy import array
import ipywidgets
import IPython
from IPython.core.display import display, HTML from IPython.core.display import display, HTML
```
%% Cell type:code id: tags:
``` python
display(HTML("<style>.container { width:95% !important; }</style>")) display(HTML("<style>.container { width:95% !important; }</style>"))
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
from flatland.utils.editor import EditorMVC from flatland.utils.editor import EditorMVC
```
%% Cell type:code id: tags:
``` python
mvc = EditorMVC(sGL="PILSVG" ) mvc = EditorMVC(sGL="PILSVG" )
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Instructions ## Instructions
- Drag to draw (improved dead-ends) - Drag to draw (improved dead-ends)
- ctrl-click to add agent or select agent - ctrl-click to add agent or select agent
- if agent is selected: - if agent is selected:
- ctrl-click to move agent position - ctrl-click to move agent position
- use rotate agent to rotate 90° - use rotate agent to rotate 90°
- ctrl-shift-click to set target for selected agent - ctrl-shift-click to set target for selected agent
- target can be moved by repeating - target can be moved by repeating
- to Resize the env (cannot preserve work): - to Resize the env (cannot preserve work):
- select "Regen" tab, set regen size slider, click regenerate. - select "Regen" tab, set regen size slider, click regenerate.
- alt-click remove all rails from cell - alt-click remove all rails from cell
Demo Scene: complex_scene.pkl Demo Scene: complex_scene.pkl
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
mvc.view.display() mvc.view.display()
``` ```
%% Output %% Output
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\utils\editor.py in step(self, event)
384
385 def step(self, event):
--> 386 self.model.step()
387
388 def log(self, *args, **kwargs):
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\utils\editor.py in step(self)
760 if self.player is None:
761 self.env.restart_agents()
--> 762 self.player = Player(self.env)
763 self.env.reset(regen_rail=False, replace_agents=False)
764 self.player.step()
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\examples\play_model.py in __init__(self, env)
34 # Reset environment
35 self.env.obs_builder.reset()
---> 36 self.obs = self.env._get_observations()
37 for envAgent in range(self.env.get_num_agents()):
38 norm = max(1, max_lt(self.obs[envAgent], np.inf))
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\envs\rail_env.py in _get_observations(self)
321
322 def _get_observations(self):
--> 323 self.obs_dict = self.obs_builder.get_many(list(range(self.get_num_agents())))
324 return self.obs_dict
325
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\envs\observations.py in get_many(self, handles)
194 observations = {}
195 for h in handles:
--> 196 observations[h] = self.get(h)
197 return observations
198
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\envs\observations.py in get(self, handle)
278 new_cell = self._new_position(agent.position, branch_direction)
279 branch_observation, branch_visited = \
--> 280 self._explore_branch(handle, new_cell, branch_direction, root_observation, 0, 1)
281 observation = observation + branch_observation
282 visited = visited.union(branch_visited)
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\envs\observations.py in _explore_branch(self, handle, position, direction, root_observation, tot_dist, depth)
364 other_target_encountered = num_steps
365
--> 366 if position == agent.target:
367 if num_steps < own_target_encountered:
368 own_target_encountered = num_steps
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
......
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