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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
elrichgro
Flatland
Commits
3581033a
Commit
3581033a
authored
5 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
rendering prediction path and refactored layering
parent
83a4a761
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/utils/graphics_pil.py
+10
-8
10 additions, 8 deletions
flatland/utils/graphics_pil.py
flatland/utils/rendertools.py
+0
-3
0 additions, 3 deletions
flatland/utils/rendertools.py
with
10 additions
and
11 deletions
flatland/utils/graphics_pil.py
+
10
−
8
View file @
3581033a
...
@@ -38,10 +38,11 @@ class PILGL(GraphicsLayer):
...
@@ -38,10 +38,11 @@ class PILGL(GraphicsLayer):
window
=
tk
.
Tk
()
window
=
tk
.
Tk
()
RAIL_LAYER
=
0
RAIL_LAYER
=
0
AGENT_LAYER
=
1
PREDICTION_PATH_LAYER
=
1
PREDICTION_PATH_LAYER
=
2
TARGET_LAYER
=
2
SELECTED_AGENT_LAYER
=
3
AGENT_LAYER
=
3
SELECTED_TARGET_LAYER
=
4
SELECTED_AGENT_LAYER
=
4
SELECTED_TARGET_LAYER
=
5
def
__init__
(
self
,
width
,
height
,
jupyter
=
False
):
def
__init__
(
self
,
width
,
height
,
jupyter
=
False
):
self
.
yxBase
=
(
0
,
0
)
self
.
yxBase
=
(
0
,
0
)
...
@@ -187,6 +188,7 @@ class PILGL(GraphicsLayer):
...
@@ -187,6 +188,7 @@ class PILGL(GraphicsLayer):
def
begin_frame
(
self
):
def
begin_frame
(
self
):
# Create a new agent layer
# Create a new agent layer
self
.
create_layer
(
iLayer
=
PILGL
.
AGENT_LAYER
,
clear
=
True
)
self
.
create_layer
(
iLayer
=
PILGL
.
AGENT_LAYER
,
clear
=
True
)
self
.
create_layer
(
iLayer
=
PILGL
.
PREDICTION_PATH_LAYER
,
clear
=
True
)
def
show
(
self
,
block
=
False
):
def
show
(
self
,
block
=
False
):
img
=
self
.
alpha_composite_layers
()
img
=
self
.
alpha_composite_layers
()
...
@@ -263,6 +265,7 @@ class PILGL(GraphicsLayer):
...
@@ -263,6 +265,7 @@ class PILGL(GraphicsLayer):
def
create_layers
(
self
,
clear
=
True
):
def
create_layers
(
self
,
clear
=
True
):
self
.
create_layer
(
PILGL
.
RAIL_LAYER
,
clear
=
clear
)
# rail / background (scene)
self
.
create_layer
(
PILGL
.
RAIL_LAYER
,
clear
=
clear
)
# rail / background (scene)
self
.
create_layer
(
PILGL
.
AGENT_LAYER
,
clear
=
clear
)
# agents
self
.
create_layer
(
PILGL
.
AGENT_LAYER
,
clear
=
clear
)
# agents
self
.
create_layer
(
PILGL
.
TARGET_LAYER
,
clear
=
clear
)
# agents
self
.
create_layer
(
PILGL
.
PREDICTION_PATH_LAYER
,
clear
=
clear
)
# drawing layer for agent's prediction path
self
.
create_layer
(
PILGL
.
PREDICTION_PATH_LAYER
,
clear
=
clear
)
# drawing layer for agent's prediction path
self
.
create_layer
(
PILGL
.
SELECTED_AGENT_LAYER
,
clear
=
clear
)
# drawing layer for selected agent
self
.
create_layer
(
PILGL
.
SELECTED_AGENT_LAYER
,
clear
=
clear
)
# drawing layer for selected agent
self
.
create_layer
(
PILGL
.
SELECTED_TARGET_LAYER
,
clear
=
clear
)
# drawing layer for selected agent's target
self
.
create_layer
(
PILGL
.
SELECTED_TARGET_LAYER
,
clear
=
clear
)
# drawing layer for selected agent's target
...
@@ -492,9 +495,6 @@ class PILSVG(PILGL):
...
@@ -492,9 +495,6 @@ class PILSVG(PILGL):
return
pil
return
pil
def
clear_set_predicion_path_layer
(
self
):
self
.
clear_layer
(
PILGL
.
PREDICTION_PATH_LAYER
,
0
)
def
set_predicion_path_at
(
self
,
row
,
col
,
binary_trans
,
agent_rail_color
):
def
set_predicion_path_at
(
self
,
row
,
col
,
binary_trans
,
agent_rail_color
):
colored_rail
=
self
.
recolor_image
(
self
.
pil_rail_org
[
binary_trans
],
colored_rail
=
self
.
recolor_image
(
self
.
pil_rail_org
[
binary_trans
],
[
61
,
61
,
61
],
[
agent_rail_color
],
[
61
,
61
,
61
],
[
agent_rail_color
],
...
@@ -505,7 +505,9 @@ class PILSVG(PILGL):
...
@@ -505,7 +505,9 @@ class PILSVG(PILGL):
if
binary_trans
in
self
.
pil_rail
:
if
binary_trans
in
self
.
pil_rail
:
pil_track
=
self
.
pil_rail
[
binary_trans
]
pil_track
=
self
.
pil_rail
[
binary_trans
]
if
target
is
not
None
:
if
target
is
not
None
:
pil_track
=
Image
.
alpha_composite
(
pil_track
,
self
.
station_colors
[
target
%
len
(
self
.
station_colors
)])
target_img
=
self
.
station_colors
[
target
%
len
(
self
.
station_colors
)]
target_img
=
Image
.
alpha_composite
(
pil_track
,
target_img
)
self
.
draw_image_row_col
(
target_img
,
(
row
,
col
),
layer
=
PILGL
.
TARGET_LAYER
)
if
binary_trans
==
0
:
if
binary_trans
==
0
:
if
self
.
background_grid
[
col
][
row
]
<=
4
:
if
self
.
background_grid
[
col
][
row
]
<=
4
:
...
...
This diff is collapsed.
Click to expand it.
flatland/utils/rendertools.py
+
0
−
3
View file @
3581033a
...
@@ -292,9 +292,6 @@ class RenderTool(object):
...
@@ -292,9 +292,6 @@ class RenderTool(object):
"""
"""
rt
=
self
.
__class__
rt
=
self
.
__class__
if
type
(
self
.
gl
)
is
PILSVG
:
self
.
gl
.
clear_set_predicion_path_layer
()
for
agent
in
agent_handles
:
for
agent
in
agent_handles
:
color
=
self
.
gl
.
get_agent_color
(
agent
)
color
=
self
.
gl
.
get_agent_color
(
agent
)
for
visited_cell
in
prediction_dict
[
agent
]:
for
visited_cell
in
prediction_dict
[
agent
]:
...
...
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