-
Notifications
You must be signed in to change notification settings - Fork 258
Top-Down Image Frame Updates #814
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
Conversation
|
This pull request introduces 2 alerts when merging fd272ce into e8bf86e - view on LGTM.com new alerts:
|
|
Here is a notebook sharing results: https://colab.research.google.com/drive/1GSIF78B62hNskyr-SYtUMgMdsZ7tJpJQ?usp=sharing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new action looks good to go.
I think the only thing is, if we are going to completely deprecate ToggleMapView, we need to be explicit in the documentation that if you do want this new 3rd party, top down camera to follow the agent as the old ToggleMapView camera did, they will need to update the spawned 3rd party camera since it won't automatically follow the agent position and orientation.
I can think of use cases where you would want that old behavior as an option, so perhaps deprecating it entirely is a bit too hasty?
Can you provide some? I can't think of any reason one would want to move the top-down camera and the agent at the same time, especially when it means the images from the top-down camera will no longer capture the entire scene. |
|
Now ready to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this change, LGTM.
|
Hi @mattdeitke Thanks for this new feature! Since I was using ai2thor==3.1.0 (on Windows), how can I merge this new feature and make it work in ai2thor-3.1.0? I tried to Thanks! |
|
Just a follow-up, since I'm on Windows, does that mean I need to rebuild everything from ai2thor/unity folder in Unity to make this new feature work? The new feature is related to the change of the controller, so I guess the answer is yes? Thanks! |
|
Hey @xubo92, Yes, if you rebuild locally from the latest commit on the |
|
Hi @mattdeitke I tried this new feature and found out it only works for single agent. When I set Thanks! |
|
And a follow-up question for this feature: how can I enable this top-down view all the time for real-time visualization while running controller for many steps? I tried this code https://colab.research.google.com/drive/1GSIF78B62hNskyr-SYtUMgMdsZ7tJpJQ?usp=sharing#scrollTo=CvZ2PkYp95U2 , it works good when I use plt to show one image. But when I only run my controller and want to visualize in a top-down view constantly, it does not work and still using first-person view. Thanks! |
Here is a demo of it working in the multi-agent case: https://colab.research.google.com/drive/1C_-9zqAqhSUcZvrxVlwlTMZQzWnEzY9k?usp=sharing. One needs to also pass in
How are you visualizing the frames? For the single agent case, check out |
|
Hi @mattdeitke Thanks a lot for these examples! Probably I'm not saying clearly. Here is a code snippet I use
Basically, I'm running a RL algorithm using ai2thor with multiple agents moving around. I expect to visualize the simulated scenes continuously, in a top-down view, so that I can have a sense of the policy training process by keeping an eye on the movement of agents. I expect the top-down view can give me a view of two (or) more agents in a room (not like the first-person view that I have to choose the agentId and get its local view.) Not sure how to achieve this. Thanks! |
|
I remember when use the old command "ToggleMapView", it works like a switch, and one only needs to call it somewhere once (initialization) and after that the default view is switched to top-down view. I thought the new feature works the same way, especially when one has multiple agents so that top-down view can give a whole scene containing every agent. Sorry I have a lot of questions here... |
I see. You're looking at the Unity window instead of the image frames. Basically, the old Instead, what is now happening, is that we just add a new camera to the scene (a third party camera) and it is positioned such that it captures the scene from a top-down view. However, the agent's camera will still show up in the Unity window. I don't think it's easy to change which camera is displayed in the Unity window. What I would do is take videos of the top-down sequences, and save them locally. So, you're code may become: # initialize a controller
self.controller = Controller(agentMode=self.agent_types[0], agentCount=2, scene=self.scene, width=1600, height=900, local_executable_path=local_executable_path)
# setup top-down view
event = self.controller.step(action="GetMapViewCameraProperties")
event = self.controller.step(action="AddThirdPartyCamera", agentId=0, **event.metadata["actionReturn"])
# after setting top-down view, for each move, I expect a unity windows pop out showing what happened in the scene (multiple agents moving), in a top-down view
map_frames = []
for i in range(100):
act = np.random.choice(ACTS)
e1 = self.controller.step(action=act, agentId=0)
e2 = self.controller.step(action=act, agentId=1)
map_frames.append(e1.events[0].third_party_camera_frames[0])
map_frames.append(e2.events[0].third_party_camera_frames[0])
# save the video
from moviepy.editor import ImageSequenceClip
clip = ImageSequenceClip(frames, fps=25)
clip.write_videofile("trajectory.mp4") |
|
Hi @mattdeitke Thank you so much for clarifying the difference! Now I understand what is happening. Saving frames and create a video sounds good! I'll try it. Thanks! |
|
Hi@mattdeitke |
|
Hi @yaofeng11, There isn't currently a way to view the images from 2 separate cameras in separate Unity windows. But, what might be a workaround is you can do is save images or videos from the agent's perspective and from the top-down perspective, and then view them afterwards. I just put this notebook demo together on that, which you may find useful: Let me know if that helps, |
|
Dear Mr Matt:
Thanks for your help. It bothered me for a whole week. Now I know how to solve it, and I will try it. Much appreciate.
Yaofeng :)
…------------------ 原始邮件 ------------------
发件人: "allenai/ai2thor" ***@***.***>;
发送时间: 2022年1月13日(星期四) 下午3:07
***@***.***>;
***@***.******@***.***>;
主题: Re: [allenai/ai2thor] Top-Down Image Frame Updates (#814)
Hi @yaofeng11,
There isn't currently a way to view the images from 2 separate cameras in separate Unity windows. But, what might be a workaround is you can do is save images or videos from the agent's perspective and from the top-down perspective, and then view them afterwards.
I just put this notebook demo together on that, which you may find useful:
https://colab.research.google.com/drive/1p6A_LDZA853-6boLdo4ha_1Bg6Cy3Jj9?usp=sharing
Let me know if that helps,
Matt :)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Now allows third party cameras to be used in place of ToggleMapView with
I don't think these should be merged into a single action, because, eventually, Third Party Cameras should be deprecated in favor of having the camera actually be an agent.
Resolves #812.
Fixes #445.
Resolves #599.
Deprecates
ToggleMapView.