Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bioroboticslab
robofish
io
Commits
07869025
Commit
07869025
authored
Sep 26, 2023
by
mhocke
Browse files
Options
Downloads
Patches
Plain Diff
Render goal threshold zone and fish without orientation as circle
parent
574b27ee
No related branches found
No related tags found
1 merge request
!50
Merge dev_mathis with multiple changes
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/robofish/io/app.py
+4
-0
4 additions, 0 deletions
src/robofish/io/app.py
src/robofish/io/file.py
+68
-38
68 additions, 38 deletions
src/robofish/io/file.py
with
72 additions
and
38 deletions
src/robofish/io/app.py
+
4
−
0
View file @
07869025
...
...
@@ -438,3 +438,7 @@ def update_world_shape(args: dict = None) -> None:
pbar
.
update
(
1
)
print
(
"
Update finished.
"
)
if
__name__
==
"
__main__
"
:
render
()
This diff is collapsed.
Click to expand it.
src/robofish/io/file.py
+
68
−
38
View file @
07869025
...
...
@@ -16,34 +16,31 @@
# -----------------------------------------------------------
from
__future__
import
annotations
import
robofish.io
from
robofish.io.entity
import
Entity
import
h5py
import
numpy
as
np
import
datetime
import
logging
from
typing
import
Iterable
,
Union
,
Tuple
,
List
,
Optional
,
Dict
from
pathlib
import
Path
import
platform
import
shutil
import
datetime
import
tempfile
import
uuid
import
deprecation
import
types
import
uuid
import
warnings
from
pathlib
import
Path
from
subprocess
import
run
from
textwrap
import
wrap
import
platform
from
typing
import
Dict
,
Iterable
,
List
,
Optional
,
Tuple
,
Union
import
deprecation
import
h5py
import
matplotlib
import
matplotlib.pyplot
as
plt
import
matplotlib.cm
from
matplotlib
import
animation
from
matplotlib
import
patches
import
matplotlib
.pyplot
as
plt
import
numpy
as
np
from
matplotlib
import
animation
,
patches
from
tqdm.auto
import
tqdm
from
subprocess
import
run
import
robofish.io
from
robofish.io.entity
import
Entity
# Remember: Update docstring when updating these two global variables
default_format_version
=
np
.
array
([
1
,
0
],
dtype
=
np
.
int32
)
...
...
@@ -1024,7 +1021,8 @@ class File(h5py.File):
f
"
ffmpeg is required to store videos. Please install it.
\n
{
e
}
"
)
def
shape_vertices
(
scale
=
1
)
->
np
.
ndarray
:
def
shape_vertices
(
scale
=
1
,
has_orientation
=
True
)
->
np
.
ndarray
:
if
has_orientation
:
base_shape
=
np
.
array
(
[
(
+
3.0
,
+
0.0
),
...
...
@@ -1037,6 +1035,13 @@ class File(h5py.File):
(
+
2.5
,
-
1.0
),
]
)
else
:
# show a circle if there is no orientation
num_vertices
=
8
radius
=
2
angles
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
num_vertices
,
endpoint
=
False
)
base_shape
=
np
.
column_stack
((
np
.
cos
(
angles
),
np
.
sin
(
angles
)))
*
radius
return
base_shape
*
scale
default_options
=
{
...
...
@@ -1111,15 +1116,22 @@ class File(h5py.File):
entity_polygons
=
[
patches
.
Polygon
(
shape_vertices
(
options
[
"
entity_scale
"
]),
shape_vertices
(
options
[
"
entity_scale
"
],
has_orientation
=
entity
.
orientations_rad
[:].
std
()
>
0
,
),
edgecolor
=
edgecolor
,
facecolor
=
color
,
alpha
=
0.8
,
)
for
edgecolor
,
color
in
[
(
"
k
"
,
"
white
"
)
for
edgecolor
,
color
,
entity
in
[
(
"
k
"
,
"
white
"
,
self
.
entities
[
entity
]
)
if
category
==
"
robot
"
else
(
entity_colors
[
entity
],
entity_colors
[
entity
])
else
(
entity_colors
[
entity
],
entity_colors
[
entity
],
self
.
entities
[
entity
],
)
for
entity
,
category
in
enumerate
(
categories
)
]
]
...
...
@@ -1152,13 +1164,33 @@ class File(h5py.File):
xv
,
yv
=
np
.
meshgrid
(
x
,
y
)
points
=
[
plt
.
scatter
([],
[],
marker
=
"
x
"
,
color
=
"
k
"
),
plt
.
plot
([],
[],
linestyle
=
"
dotted
"
,
alpha
=
0.5
,
color
=
"
k
"
,
zorder
=
0
)[
0
],
plt
.
scatter
(
xv
,
yv
,
c
=
"
gray
"
,
s
=
1.5
),
]
goal_components
=
[
plt
.
scatter
([],
[],
marker
=
"
x
"
,
color
=
"
k
"
),
# goal
plt
.
plot
([],
[],
linestyle
=
"
dotted
"
,
alpha
=
0.5
,
color
=
"
k
"
)[
0
],
]
border
=
patches
.
Polygon
(
border_vertices
.
T
,
facecolor
=
"
w
"
,
zorder
=-
1
)
goal_threshold_cm
=
self
.
attrs
.
get
(
"
change_goal_threshold
"
,
0.05
)
*
100
def
update_goal
(
file_frame
:
int
):
num_vertices
=
32
goal
=
get_goal
(
file_frame
)
if
goal
is
not
None
:
goal_components
[
0
].
set_offsets
(
goal
)
angles
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
num_vertices
)
shape
=
(
np
.
column_stack
((
np
.
cos
(
angles
),
np
.
sin
(
angles
)))
*
goal_threshold_cm
)
goal_components
[
1
].
set_data
(
goal
[
0
]
+
shape
[:,
0
],
goal
[
1
]
+
shape
[:,
1
]
)
def
title
(
file_frame
:
int
)
->
str
:
"""
Search for datasets containing text for displaying it in the video
"""
output
=
[]
...
...
@@ -1308,12 +1340,10 @@ class File(h5py.File):
annotations
[
i
].
xy
=
this_pose
[
i
,
:
2
]
if
options
[
"
render_goals
"
]:
goal
=
get_goal
(
file_frame
)
if
goal
is
not
None
:
points
[
0
].
set_offsets
(
goal
)
update_goal
(
file_frame
)
if
options
[
"
render_targets
"
]:
points
[
1
].
set_data
(
get_target
(
file_frame
))
points
[
0
].
set_data
(
get_target
(
file_frame
))
poses_trails
=
entity_poses
[
:,
max
(
0
,
file_frame
-
options
[
"
trail
"
])
:
file_frame
...
...
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