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

.

parent c74f225f
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Rail Editor v0.2 # Rail Editor v0.2
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
%load_ext autoreload %load_ext autoreload
%autoreload 2 %autoreload 2
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import numpy as np import numpy as np
from numpy import array from numpy import array
import ipywidgets import ipywidgets
import IPython import IPython
from IPython.core.display import display, HTML from IPython.core.display import display, HTML
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` 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, EditorModel, View, Controller from flatland.utils.editor import EditorMVC, EditorModel, View, Controller
``` ```
%% Output %% Output
cairo installed: OK cairo installed: OK
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
mvc = EditorMVC(sGL="PILSVG" ) # sGL="PIL") mvc = EditorMVC(sGL="PILSVG" ) # sGL="PIL")
``` ```
%% Output %% Output
<flatland.utils.graphics_pil.PILSVG object at 0x000001FFD1ED30B8> <class 'flatland.utils.graphics_pil.PILSVG'> <flatland.utils.graphics_pil.PILSVG object at 0x000001C03C7A3080> <class 'flatland.utils.graphics_pil.PILSVG'>
<super: <class 'PILSVG'>, <PILSVG object>> <class 'super'> <super: <class 'PILSVG'>, <PILSVG object>> <class 'super'>
0000000000000000 Background_#91D1DD.svg 0000000000000000 Background_#91D1DD.svg
WE 0000000000000100 Gleis_Deadend.svg WE 0000000000000100 Gleis_Deadend.svg
WW EE NN SS 1000010000100001 Gleis_Diamond_Crossing.svg WW EE NN SS 1000010000100001 Gleis_Diamond_Crossing.svg
WW EE 0000010000000001 Gleis_horizontal.svg WW EE 0000010000000001 Gleis_horizontal.svg
EN SW 0000100000010000 Gleis_Kurve_oben_links.svg EN SW 0000100000010000 Gleis_Kurve_oben_links.svg
WN SE 0000000001001000 Gleis_Kurve_oben_rechts.svg WN SE 0000000001001000 Gleis_Kurve_oben_rechts.svg
ES NW 0001001000000000 Gleis_Kurve_unten_links.svg ES NW 0001001000000000 Gleis_Kurve_unten_links.svg
NE WS 0100000000000010 Gleis_Kurve_unten_rechts.svg NE WS 0100000000000010 Gleis_Kurve_unten_rechts.svg
NN SS 1000000000100000 Gleis_vertikal.svg NN SS 1000000000100000 Gleis_vertikal.svg
NN SS EE WW ES NW SE WN 1001011001101001 Weiche_Double_Slip.svg NN SS EE WW ES NW SE WN 1001011001101001 Weiche_Double_Slip.svg
EE WW EN SW 0000110000010001 Weiche_horizontal_oben_links.svg EE WW EN SW 0000110000010001 Weiche_horizontal_oben_links.svg
EE WW SE WN 0000010001001001 Weiche_horizontal_oben_rechts.svg EE WW SE WN 0000010001001001 Weiche_horizontal_oben_rechts.svg
EE WW ES NW 0001011000000001 Weiche_horizontal_unten_links.svg EE WW ES NW 0001011000000001 Weiche_horizontal_unten_links.svg
EE WW NE WS 0100010000000011 Weiche_horizontal_unten_rechts.svg EE WW NE WS 0100010000000011 Weiche_horizontal_unten_rechts.svg
NN SS EE WW NW ES 1001011000100001 Weiche_Single_Slip.svg NN SS EE WW NW ES 1001011000100001 Weiche_Single_Slip.svg
NE NW ES WS 0101001000000010 Weiche_Symetrical.svg NE NW ES WS 0101001000000010 Weiche_Symetrical.svg
NN SS EN SW 1000100000110000 Weiche_vertikal_oben_links.svg NN SS EN SW 1000100000110000 Weiche_vertikal_oben_links.svg
NN SS SE WN 1000000001101000 Weiche_vertikal_oben_rechts.svg NN SS SE WN 1000000001101000 Weiche_vertikal_oben_rechts.svg
NN SS NW ES 1001001000100000 Weiche_vertikal_unten_links.svg NN SS NW ES 1001001000100000 Weiche_vertikal_unten_links.svg
NN SS NE WS 1100000000100010 Weiche_vertikal_unten_rechts.svg NN SS NE WS 1100000000100010 Weiche_vertikal_unten_rechts.svg
EW 0000000100000000 Bahnhof_#d50000_Deadend_links.svg EW 0000000100000000 Bahnhof_#d50000_Deadend_links.svg
NS 0010000000000000 Bahnhof_#d50000_Deadend_oben.svg NS 0010000000000000 Bahnhof_#d50000_Deadend_oben.svg
WE 0000000000000100 Bahnhof_#d50000_Deadend_rechts.svg WE 0000000000000100 Bahnhof_#d50000_Deadend_rechts.svg
SN 0000000010000000 Bahnhof_#d50000_Deadend_unten.svg SN 0000000010000000 Bahnhof_#d50000_Deadend_unten.svg
EE WW 0000010000000001 Bahnhof_#d50000_Gleis_horizontal.svg EE WW 0000010000000001 Bahnhof_#d50000_Gleis_horizontal.svg
NN SS 1000000000100000 Bahnhof_#d50000_Gleis_vertikal.svg NN SS 1000000000100000 Bahnhof_#d50000_Gleis_vertikal.svg
Clear rails Clear rails
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Instructions ## Instructions
- Drag to draw (improved dead-ends) - Drag to draw (improved dead-ends)
- Shift-Drag to erase rails (erasing dead ends not yet automated - drag right across them) - Shift-Drag to erase rails (erasing dead ends not yet automated - drag right across them)
- ctrl-click to add agent - ctrl-click to add agent
- direction chosen randomly to fit rail - direction chosen randomly to fit rail
- ctrl-shift-click to add target for last agent - ctrl-shift-click to add target for last 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
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
mvc.view.display() mvc.view.display()
``` ```
%% Output %% Output
---------------------------------------------------------------------------
TypeError 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 save(self, event)
374
375 def save(self, event):
--> 376 self.model.save()
377
378 def step(self, event):
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\utils\editor.py in save(self)
670 self.log("save to ", self.env_filename, " working dir: ", os.getcwd())
671 # self.env.rail.save_transition_map(self.env_filename)
--> 672 self.env.save(self.env_filename)
673
674 def regenerate(self, method=None, nAgents=0, env=None):
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 save(self, filename)
372 def save(self, filename):
373 with open(filename, "wb") as file_out:
--> 374 file_out.write(self.get_full_state_msg())
375
376 def load(self, filename):
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_full_state_msg(self)
343
344 msgpack.packb(grid_data)
--> 345 msgpack.packb(agent_data)
346 msgpack.packb(agent_static_data)
347
c:\users\u216993\appdata\local\programs\python\python36\lib\site-packages\msgpack\__init__.py in packb(o, **kwargs)
44 See :class:`Packer` for options.
45 """
---> 46 return Packer(**kwargs).pack(o)
47
48
msgpack\_packer.pyx in msgpack._cmsgpack.Packer.pack()
msgpack\_packer.pyx in msgpack._cmsgpack.Packer.pack()
msgpack\_packer.pyx in msgpack._cmsgpack.Packer.pack()
msgpack\_packer.pyx in msgpack._cmsgpack.Packer._pack()
msgpack\_packer.pyx in msgpack._cmsgpack.Packer._pack()
msgpack\_packer.pyx in msgpack._cmsgpack.Packer._pack()
msgpack\_packer.pyx in msgpack._cmsgpack.Packer._pack()
TypeError: can not serialize 'numpy.int32' object
Clear rails
Clear rails
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
mvc.view.wOutput.clear_output() mvc.view.wOutput.clear_output()
mvc.view.wOutput mvc.view.wOutput
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
len(mvc.editor.env.agents), len(mvc.editor.env.agents_static) len(mvc.editor.env.agents), len(mvc.editor.env.agents_static)
``` ```
%% Output %% Output
(0, 0) (0, 0)
......
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