Skip to content
Snippets Groups Projects
Commit 1d8fb2df authored by mhocke's avatar mhocke Committed by Andi Gerken
Browse files

Show values of text datasets in title of render view.

parent 756cc2f1
Branches
No related tags found
1 merge request!26Show values of text datasets in title of render view
Pipeline #48442 passed
...@@ -129,6 +129,7 @@ def render(args=None): ...@@ -129,6 +129,7 @@ def render(args=None):
"view_size": 60, "view_size": 60,
"slow_view": 0.8, "slow_view": 0.8,
"cut_frames": 0, "cut_frames": 0,
"show_text": False,
} }
for key, value in default_options.items(): for key, value in default_options.items():
......
...@@ -836,6 +836,7 @@ class File(h5py.File): ...@@ -836,6 +836,7 @@ class File(h5py.File):
"slow_view": 0.8, "slow_view": 0.8,
"slow_zoom": 0.95, "slow_zoom": 0.95,
"cut_frames": None, "cut_frames": None,
"show_text": False,
} }
options = { options = {
...@@ -851,9 +852,12 @@ class File(h5py.File): ...@@ -851,9 +852,12 @@ class File(h5py.File):
plt.plot([], [], lw=options["linewidth"], zorder=0)[0] plt.plot([], [], lw=options["linewidth"], zorder=0)[0]
for _ in range(n_entities) for _ in range(n_entities)
] ]
categories = [entity.attrs.get("category", None) for entity in self.entities]
entity_polygons = [ entity_polygons = [
patches.Polygon(shape_vertices(options["entity_scale"]), facecolor="k") patches.Polygon(shape_vertices(options["entity_scale"]), facecolor=color)
for _ in range(n_entities) for color in [
"gray" if category == "robot" else "k" for category in categories
]
] ]
border_vertices = np.array( border_vertices = np.array(
...@@ -883,6 +887,15 @@ class File(h5py.File): ...@@ -883,6 +887,15 @@ class File(h5py.File):
min_view = np.max((np.max(start_pose, axis=0) - np.min(start_pose, axis=0))[:2]) min_view = np.max((np.max(start_pose, axis=0) - np.min(start_pose, axis=0))[:2])
self.view_size = np.max([options["view_size"], min_view + options["margin"]]) self.view_size = np.max([options["view_size"], min_view + options["margin"]])
def title(file_frame: int) -> str:
"""Search for datasets containing text for displaying it in the video"""
output = []
for e in self.entities:
for key, val in e.items():
if val.dtype == object and type(val[0]) == bytes:
output.append(f"{e.name}.{key}='{val[file_frame].decode()}'")
return ", ".join(output)
def init(): def init():
ax.set_xlim(-0.5 * self.world_size[0], 0.5 * self.world_size[0]) ax.set_xlim(-0.5 * self.world_size[0], 0.5 * self.world_size[0])
ax.set_ylim(-0.5 * self.world_size[1], 0.5 * self.world_size[1]) ax.set_ylim(-0.5 * self.world_size[1], 0.5 * self.world_size[1])
...@@ -943,6 +956,8 @@ class File(h5py.File): ...@@ -943,6 +956,8 @@ class File(h5py.File):
self.middle_of_swarm[1] - self.view_size / 2, self.middle_of_swarm[1] - self.view_size / 2,
self.middle_of_swarm[1] + self.view_size / 2, self.middle_of_swarm[1] + self.view_size / 2,
) )
if options["show_text"]:
ax.set_title(title(file_frame))
poses_trails = entity_poses[ poses_trails = entity_poses[
:, max(0, file_frame - options["trail"]) : file_frame :, max(0, file_frame - options["trail"]) : file_frame
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment