Skip to content

add feature to render specific static frame #43

Merged
Tviskaron merged 4 commits intoCognitive-AI-Systems:mainfrom
Jiaxi-Huang:main
Dec 19, 2025
Merged

add feature to render specific static frame #43
Tviskaron merged 4 commits intoCognitive-AI-Systems:mainfrom
Jiaxi-Huang:main

Conversation

@Jiaxi-Huang
Copy link
Contributor

    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]

By add frame_idx definition and create_frame_view, we can render specific frame and the use of frame_idx are valid when static=True
Below are some code to see the feature:

from pogema import pogema_v0, GridConfig, AnimationMonitor, AnimationConfig

# Define random configuration
grid_config = GridConfig(num_agents=64,  # number of agents
						 size=32, # size of the grid
						 density=0.4,  # obstacle density
						 seed=1,  # set to None for random
								  # obstacles, agents and targets
								  # positions at each reset
						 max_episode_steps=50,  # horizon
						 obs_radius=1,  # defines field of view
						 )

env = pogema_v0(grid_config=grid_config)
env = AnimationMonitor(env)
obs, info = env.reset()
env.render()


terminated = truncated = [False, ...]

while not all(terminated) and not all(truncated):
	# Use random policy to make actions
	obs, reward, terminated, truncated, info = env.step([env.action_space.sample() for _ in range(grid_config.num_agents)])
env.render()
from IPython.display import SVG, display
env.save_animation("render.svg", AnimationConfig(frame_idx=5, static=False))
display(SVG('render.svg'))
from IPython.display import SVG, display
env.save_animation("render.svg", AnimationConfig(frame_idx=15,static=True))
display(SVG('render.svg'))
from IPython.display import SVG, display
env.save_animation("render.svg", AnimationConfig(egocentric_idx=2,frame_idx=10,static=True))
display(SVG('render.svg'))

@Tviskaron Tviskaron self-requested a review December 17, 2025 06:51
@Tviskaron Tviskaron added the enhancement New feature or request label Dec 17, 2025
remove unrelated changes from the pull request
Copy link
Contributor

@Tviskaron Tviskaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pretty useful enhancement

@Tviskaron Tviskaron merged commit a2db721 into Cognitive-AI-Systems:main Dec 19, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants