allenai / ai2thor

An open-source platform for Visual AI.
http://ai2thor.allenai.org
Apache License 2.0
1.16k stars 217 forks source link

Mulit-Agent 2 image window #239

Open jiafei1224 opened 5 years ago

jiafei1224 commented 5 years ago

Can check with you if when running the multi-agent, is it suppose to have two separate pop up window with two different POV? Cause i have only one POV but still able to control both agent.

jiafei1224 commented 5 years ago

There is like a overlay of POV, how to i separate it into two different window?

jiafei1224 commented 5 years ago

And when i run my mulit-agent, it says my multi-agent has AttributeError: 'MultiAgentEvent' object has no attribute 'frame'

ekolve commented 5 years ago

For displaying the each view in a multi-agent environment, the easiest way would probably be use opencv to display the window as follows

import cv2
multi_agent_event = controller.step(action=dict(action='RotateRight'))

for i,e in enumerate(multi_agent_event.events):
    cv2.imshow('agent%s' % i, e.cv2img)

There doesn't appear to be a trivial way to display a window per agent using Unity.

I am not clear what you mean by overlay of the POV. If it is the instance segmentation mask, you could display it separately using opencv.

To get access to the frame parameter, you must index in to the agent you want to see the frame for:


multi_agent_event = controller.step(action=dict(action='RotateRight'))
multi_agent_event.events[0].frame # frame for agent 1
multi_agent_event.events[1].frame # frame for agent 2 (if one exists)
grahamannett commented 5 years ago

Im messing around with this and trying to understand the framework and trying to understand some stuff but wanted to do what @jiafei1224 is doing. It seems like it should be feasible to have multiple controllers that work on the same "server" ? Im confused about a few terms and they dont seem documented really, what is a "controller" supposed to be and what is the "server" supposed to be doing?

Was hoping something like

shared_server = server.Server(shared_request_queue, shared_response_queue, host, port=port)
main_controller = ai2thor.controller.Controller(quality='Very Low')
event = main_controller.start_shared_server(shared_server)

second_controller = ai2thor.controller.Controller(quality='Very Low')
second_controller.attach_shared_server(shared_server)

Is it even possible to see the same scene with multiple controllers or is a controller supposed an isolated unity process? I guess can the agents be gotten from server for a controller?

mattdeitke commented 4 years ago

https://github.com/allenai/ai2thor/issues/343#issuecomment-673768363 Seems related, but the best approach would be to create some sort of local dashboard that renders all views. We will likely get around to support this at some point.

Frost-99 commented 4 years ago

Hi, Is there a way to switch between different agent's view when there are multiple agents? I created two agents and the Unity window displays agent1's view by default and whenever agent0 takes action the Unity window quickly flashes to agent0's view and then flashes back to agent1's view again. Is there a way to switch the default view to agent0?