Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images from the Unity window lag by 1 step in versions >= 2.5.0 #538

Closed
mattdeitke opened this issue Dec 8, 2020 · 1 comment
Closed

Comments

@mattdeitke
Copy link
Member

When opening a controller and running:

from ai2thor.controller import Controller
c = Controller()
event = c.step('MoveAhead')

the Unity window that opens in the background is always 1-step behind the action!

However, when viewing the actual returned image from the event, it is up to date:

from PIL import Image
Image.fromarray(event.frame)
@mattdeitke mattdeitke pinned this issue Dec 8, 2020
@mattdeitke
Copy link
Member Author

This is expected behavior in versions >= 2.4.23!

For a bit of background, the servers that communicate between Python and Unity were updated, and this allows all actions to run substantially faster, which is often a preferred trade-off.


But, it is of course useful to view and debug the current frame, so here are a few ways to do that:

  1. Execute a dummy event, that will update the Unity window's frame:
c.step('Pass')
  1. View the Event's image frame in a Python interactive environment with Python's Imaging Library (PIL):
# setup controller
from ai2thor.controller import Controller
c = Controller()
event = c.step('MoveAhead')

# visualize frame with PIL
from PIL import Image
Image.fromarray(event.frame)
  1. Plot the image with matplotlib and have it open up in a new window (depending on your environment):
# setup controller
from ai2thor.controller import Controller
c = Controller()
event = c.step('MoveAhead')

# visualize frame with matplotlib
import matplotlib.pyplot as plt
plt.imshow(event.frame)
plt.axis('off')
plt.show()

@mattdeitke mattdeitke changed the title Images from the Unity window lag by 1-step in versions >= 2.4.23 Images from the Unity window lag by 1 step in versions >= 2.4.23 Dec 8, 2020
@mattdeitke mattdeitke changed the title Images from the Unity window lag by 1 step in versions >= 2.4.23 Images from the Unity window lag by 1 step in versions >= 2.5.0 Dec 8, 2020
@winthos winthos unpinned this issue May 6, 2021
@mattdeitke mattdeitke pinned this issue Jun 3, 2021
@Lucaweihs Lucaweihs unpinned this issue Sep 16, 2022
@Lucaweihs Lucaweihs pinned this issue Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant