Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pranjal_dhole
Flatland
Commits
8455735a
Commit
8455735a
authored
4 years ago
by
hagrid67
Browse files
Options
Downloads
Patches
Plain Diff
remove save images to tmp-images in test-collision.ipynb
parent
4fea2b28
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notebooks/test-collision.ipynb
+11
-17
11 additions, 17 deletions
notebooks/test-collision.ipynb
with
11 additions
and
17 deletions
notebooks/test-collision.ipynb
+
11
−
17
View file @
8455735a
...
...
@@ -126,8 +126,8 @@
" aImg = oRT.get_image()\n",
" pilImg = PIL.Image.fromarray(aImg)\n",
" oCan.put_image_data(aImg)\n",
" with open(f\"tmp-images/img-{iStep:03d}.png\", \"wb\") as fImg:\n",
" pilImg.save(fImg)\n",
"
#
with open(f\"tmp-images/img-{iStep:03d}.png\", \"wb\") as fImg:\n",
"
#
pilImg.save(fImg)\n",
" \n",
" time.sleep(0.05)"
]
...
...
@@ -143,24 +143,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"oEC = ju.EnvCanvas(env)\n",
"env.reset(regenerate_rail=False)\n",
"oEC.oRT.render_env()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
a485406ea061479db50fb90c43833bc2
",
"model_id": "
47677058c61e4c71bf23d56e80bc88d3
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -173,15 +162,20 @@
}
],
"source": [
"oEC = ju.EnvCanvas(env)\n",
"env.reset(regenerate_rail=False)\n",
"oEC.show()"
]
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
41
,
"metadata": {},
"outputs": [],
"source": []
"source": [
"oEC.step()\n",
"oEC.render()"
]
}
],
"metadata": {
...
...
%% Cell type:markdown id: tags:
# Test Collisions
A visual test of a "rear-shunt" collision, to ensure that the agent does not get marked as collided permananently.
%% Cell type:code id: tags:
```
python
%
load_ext
autoreload
%
autoreload
2
from
IPython.core
import
display
display
.
display
(
display
.
HTML
(
"
<style>.container { width:95% !important; }</style>
"
))
```
%% Output
%% Cell type:code id: tags:
```
python
import
PIL
from
IPython
import
display
from
ipycanvas
import
canvas
import
time
```
%% Cell type:code id: tags:
```
python
from
flatland.envs
import
malfunction_generators
as
malgen
from
flatland.envs.agent_utils
import
EnvAgent
#from flatland.envs import sparse_rail_gen as spgen
from
flatland.envs
import
rail_generators
as
rail_gen
from
flatland.envs
import
agent_chains
as
ac
from
flatland.envs.rail_env
import
RailEnv
,
RailEnvActions
from
flatland.envs.persistence
import
RailEnvPersister
from
flatland.utils.rendertools
import
RenderTool
from
flatland.utils
import
env_edit_utils
as
eeu
from
flatland.utils
import
jupyter_utils
as
ju
```
%% Cell type:code id: tags:
```
python
nAg
=
2
bUCF
=
False
bReverseStart
=
False
env
,
envModel
=
eeu
.
makeTestEnv
(
sName
=
"
merging_spurs
"
,
nAg
=
nAg
,
bUCF
=
bUCF
)
oRT
=
RenderTool
(
env
,
show_debug
=
True
)
oRT
.
render_env
(
show_rowcols
=
True
,
show_inactive_agents
=
True
,
show_observations
=
False
)
oCan
=
canvas
.
Canvas
(
size
=
(
600
,
300
))
oCan
.
put_image_data
(
oRT
.
get_image
())
print
(
f
"
UCF:
{
bUCF
}
"
)
display
.
display
(
oCan
)
iPauseStep
=
10
iPauseLen
=
5
for
iStep
in
range
(
25
):
if
bReverseStart
:
iAgentStart
=
max
((
nAg
-
2
-
iStep
*
2
),
0
)
else
:
iAgentStart
=
0
dActions
=
{
i
:
int
(
RailEnvActions
.
MOVE_FORWARD
)
for
i
in
range
(
iAgentStart
,
len
(
env
.
agents
))
}
if
(
iStep
>=
iPauseStep
)
and
(
iStep
<
iPauseStep
+
iPauseLen
):
dActions
[
0
]
=
RailEnvActions
.
STOP_MOVING
#print(dActions)
env
.
step
(
dActions
)
oRT
.
render_env
(
show_rowcols
=
True
,
show_inactive_agents
=
True
,
show_observations
=
False
)
aImg
=
oRT
.
get_image
()
pilImg
=
PIL
.
Image
.
fromarray
(
aImg
)
oCan
.
put_image_data
(
aImg
)
with
open
(
f
"
tmp-images/img-
{
iStep
:
03
d
}
.png
"
,
"
wb
"
)
as
fImg
:
pilImg
.
save
(
fImg
)
#
with open(f"tmp-images/img-{iStep:03d}.png", "wb") as fImg:
#
pilImg.save(fImg)
time
.
sleep
(
0.05
)
```
%% Output
UCF: False
%% Cell type:code id: tags:
```
python
#!ffmpeg -i ./tmp-images/img-%03d.png -vcodec mpeg4 -filter:v "setpts=8.0*PTS" -y movie_nucf_stop.mp4
```
%% Cell type:code id: tags:
```
python
oEC
=
ju
.
EnvCanvas
(
env
)
env
.
reset
(
regenerate_rail
=
False
)
oEC
.
oRT
.
render_env
()
```
%% Cell type:code id: tags:
```
python
oEC
.
show
()
```
%% Output
%% Cell type:code id: tags:
```
python
oEC
.
step
()
oEC
.
render
()
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment