Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions pogema/svg_animation/animation_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
@dataclass
class AnimationConfig:
directory: str = 'renders/'
static: bool = False
show_agents: bool = True
egocentric_idx: typing.Optional[int] = None
frame_idx: typing.Optional[int] = None
static_frame_idx: typing.Optional[int] = None
uid: typing.Optional[str] = None
save_every_idx_episode: typing.Optional[int] = 1
show_grid_lines: bool = True
Expand Down Expand Up @@ -117,7 +116,7 @@ def create_animation(self, grid_holder: GridHolder):
if gh.config.show_agents:
agents = self.create_agents(gh)
targets = self.create_targets(gh)
if gh.config.static:
if gh.config.static_frame_idx is not None:
agents = self.create_static_agents(gh)
if gh.config.egocentric_idx is not None:
obstacles = self.create_static_obstacles(obstacles= obstacles, grid_holder=gh)
Expand All @@ -135,7 +134,7 @@ def create_animation(self, grid_holder: GridHolder):

if gh.config.egocentric_idx is not None:
field_of_view = self.create_field_of_view(grid_holder=gh)
if not gh.config.static:
if gh.config.static_frame_idx is None:
self.animate_obstacles(obstacles=obstacles, grid_holder=gh)
self.animate_field_of_view(field_of_view, gh)
drawing.add_element(field_of_view)
Expand Down Expand Up @@ -186,8 +185,8 @@ def create_field_of_view(grid_holder):

def create_frame_view(self, grid_holder):
gh: GridHolder = grid_holder
frame_idx = gh.config.frame_idx
gh.history = [[agent_states[gh.config.frame_idx]] for agent_states in gh.history]
frame_idx = gh.config.static_frame_idx
gh.history = [[agent_states[frame_idx]] for agent_states in gh.history]

def animate_field_of_view(self, view, grid_holder):
gh: GridHolder = grid_holder
Expand Down Expand Up @@ -329,7 +328,7 @@ def create_obstacles(self, grid_holder):

def create_static_obstacles(self, obstacles, grid_holder):
gh: GridHolder = grid_holder
frame_idx = gh.config.frame_idx
frame_idx = gh.config.static_frame_idx
result = []
seen = set()

Expand Down Expand Up @@ -415,7 +414,7 @@ def create_static_agents(self, grid_holder):
agents = []
gh: GridHolder = grid_holder
ego_idx = grid_holder.config.egocentric_idx
frame_idx = grid_holder.config.frame_idx
frame_idx = grid_holder.config.static_frame_idx

static_positions = [state[frame_idx].get_xy() for state in grid_holder.history]
for idx, (x, y) in enumerate(static_positions):
Expand Down
Loading