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
sfwatergit
Flatland
Commits
c4848fb0
Commit
c4848fb0
authored
5 years ago
by
hagrid67
Browse files
Options
Downloads
Patches
Plain Diff
fixed up MPL GL again - colors in [0,1]^3, spurious plt.figure
parent
026c3e10
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/play_model.py
+1
-1
1 addition, 1 deletion
examples/play_model.py
flatland/utils/editor.py
+5
-2
5 additions, 2 deletions
flatland/utils/editor.py
flatland/utils/rendertools.py
+22
-14
22 additions, 14 deletions
flatland/utils/rendertools.py
with
28 additions
and
17 deletions
examples/play_model.py
+
1
−
1
View file @
c4848fb0
...
...
@@ -155,7 +155,7 @@ def main(render=True, delay=0.0):
env_done
=
0
# Run episode
for
step
in
range
(
5
0
):
for
step
in
range
(
10
0
):
# if trials > 114:
# env_renderer.renderEnv(show=True)
# print(step)
...
...
This diff is collapsed.
Click to expand it.
flatland/utils/editor.py
+
5
−
2
View file @
c4848fb0
...
...
@@ -58,7 +58,7 @@ class View(object):
def
init_canvas
(
self
):
# update the rendertool with the env
self
.
new_env
()
plt
.
figure
(
figsize
=
(
10
,
10
))
#
plt.figure(figsize=(10, 10))
self
.
oRT
.
renderEnv
(
spacing
=
False
,
arrows
=
False
,
sRailColor
=
"
gray
"
,
show
=
False
)
img
=
self
.
oRT
.
getImage
()
plt
.
clf
()
...
...
@@ -363,7 +363,7 @@ class EditorModel(object):
set a new env for the editor, used by load and regenerate.
"""
self
.
env
=
env
self
.
yxBase
=
array
([
6
,
21
])
# pixel offset
#
self.yxBase = array([6, 21]) # pixel offset
# self.nPixCell = 700 / self.env.rail.width # 35
# self.oRT = rt.RenderTool(env)
...
...
@@ -680,3 +680,6 @@ class EditorModel(object):
binTrans
,
sbinTrans
,
[
sbinTrans
[
i
:(
i
+
4
)]
for
i
in
range
(
0
,
len
(
sbinTrans
),
4
)])
\ No newline at end of file
This diff is collapsed.
Click to expand it.
flatland/utils/rendertools.py
+
22
−
14
View file @
c4848fb0
...
...
@@ -19,7 +19,7 @@ class MPLGL(GraphicsLayer):
self
.
height
=
height
self
.
yxBase
=
array
([
6
,
21
])
# pixel offset
self
.
nPixCell
=
700
/
width
pass
self
.
img
=
None
def
plot
(
self
,
*
args
,
**
kwargs
):
plt
.
plot
(
*
args
,
**
kwargs
)
...
...
@@ -67,23 +67,31 @@ class MPLGL(GraphicsLayer):
return
plt
.
get_cmap
(
*
args
,
**
kwargs
)
def
beginFrame
(
self
):
self
.
img
=
None
plt
.
figure
(
figsize
=
(
10
,
10
))
pass
def
endFrame
(
self
):
# plt.clf()
# plt.close()
pass
def
getImage
(
self
):
ax
=
plt
.
gca
()
fig
=
ax
.
get_figure
()
fig
.
tight_layout
(
pad
=
0
)
fig
.
canvas
.
draw
()
data
=
np
.
frombuffer
(
fig
.
canvas
.
tostring_rgb
(),
dtype
=
np
.
uint8
)
data
=
data
.
reshape
(
fig
.
canvas
.
get_width_height
()[::
-
1
]
+
(
3
,))
return
data
self
.
img
=
self
.
getImage
(
force
=
True
)
plt
.
clf
()
plt
.
close
()
def
getImage
(
self
,
force
=
False
):
if
self
.
img
is
None
or
force
:
ax
=
plt
.
gca
()
fig
=
ax
.
get_figure
()
fig
.
tight_layout
(
pad
=
0
)
fig
.
canvas
.
draw
()
data
=
np
.
frombuffer
(
fig
.
canvas
.
tostring_rgb
(),
dtype
=
np
.
uint8
)
data
=
data
.
reshape
(
fig
.
canvas
.
get_width_height
()[::
-
1
]
+
(
3
,))
self
.
img
=
data
return
self
.
img
def
adaptColor
(
self
,
color
,
lighten
=
False
):
color
=
super
(
self
.
__class__
,
self
).
adaptColor
(
color
,
lighten
)
# MPL has RGBA in [0,1]^4 not \mathbb{N} \cap [0,255]^4
color
=
tuple
([
iRGBA
/
255
for
iRGBA
in
color
])
return
color
class
RenderTool
(
object
):
Visit
=
recordtype
(
"
Visit
"
,
[
"
rc
"
,
"
iDir
"
,
"
iDepth
"
,
"
prev
"
])
...
...
@@ -469,7 +477,7 @@ class RenderTool(object):
# so for now I've changed it to 1 (from 10)
cell_size
=
1
self
.
gl
.
beginFrame
()
self
.
gl
.
clf
()
#
self.gl.clf()
# if oFigure is None:
# oFigure = self.gl.figure()
...
...
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