Skip to content

TimeoutError with multi-agent #1265

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

Open
abpaudel opened this issue Mar 20, 2025 · 2 comments
Open

TimeoutError with multi-agent #1265

abpaudel opened this issue Mar 20, 2025 · 2 comments

Comments

@abpaudel
Copy link

I'm trying to get top-down view with two agents in the scene using the following code.

import random
import matplotlib.pyplot as plt
import prior
from ai2thor.controller import Controller
from ai2thor.platform import CloudRendering


NUM_AGENTS = 1

dataset = prior.load_dataset("procthor-10k")
scene = dataset["train"][0]

controller = Controller(platform=CloudRendering, scene=scene)

multi_agent_event = controller.step(dict(action='Initialize', agentCount=NUM_AGENTS))
event = controller.step(action="GetMapViewCameraProperties")
event = controller.step(action="AddThirdPartyCamera", **event.metadata["actionReturn"])

reachable_positions_ = controller.step(action="GetReachablePositions").metadata["actionReturn"]
reachable_positions = [(p["x"], p["y"], p["z"]) for p in reachable_positions_]

random.seed(42)
for i in range(NUM_AGENTS):
    pos = random.choice(reachable_positions_)
    controller.step(dict(action="Teleport", position=pos, agentId=i))

img = controller.last_event.events[0].third_party_camera_frames[-1][::-1, ...]
plt.imshow(img)
plt.show()

This code works as expected. However, I get the following TimeoutError for NUM_AGENTS = 2. Let me know how I can get this to work for 2 or more agents.

Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/ai2thor/controller.py", line 979, in step
    self.last_event = self.server.receive()
  File "/opt/venv/lib/python3.10/site-packages/ai2thor/fifo_server.py", line 229, in receive
    metadata, files = self._recv_message(
  File "/opt/venv/lib/python3.10/site-packages/ai2thor/fifo_server.py", line 145, in _recv_message
    header = self._read_with_timeout(
  File "/opt/venv/lib/python3.10/site-packages/ai2thor/fifo_server.py", line 134, in _read_with_timeout
    raise TimeoutError(f"Reading from AI2-THOR backend timed out (using {timeout}s) timeout.")
TimeoutError: Reading from AI2-THOR backend timed out (using 100.0s) timeout.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ab/projects/ai2thor/multiagent_demo.py", line 25, in <module>
    controller.step(dict(action="Teleport", position=pos, agentId=i))
  File "/opt/venv/lib/python3.10/site-packages/ai2thor/controller.py", line 997, in step
    raise (TimeoutError if isinstance(e, TimeoutError) else RuntimeError)(
TimeoutError: Error encountered when running action {'action': 'Teleport', 'position': {'x': 2.75, 'y': 0.9009993672370911, 'z': 1.5}, 'agentId': 1, 'sequenceId': 9} in scene Procedural.
@NA-Wen
Copy link

NA-Wen commented Mar 21, 2025

I have the same problem. My code works as expected when initializing with 1 agent or 2 agents. However, I stuck in the initialize action and get TimeoutError for 3 agents.
The code:

controller = Controller(height=1000, width=1000)
controller.reset("FloorPlan" + str(floor_no)) 
print("Initializing agents: {}".format(3))
# Initialize n agents into the scene
multi_agent_event = controller.step(dict(action='Initialize', agentMode="default", snapGrid=False, gridSize=0.5, rotateStepDegrees=20, visibilityDistance=100, fieldOfView=90, agentCount=3))

The error:

Traceback (most recent call last):
  File "/workspace/ai2thor/logs/Wash_the_lettuce_and_place_lettuce_on_the_Countertop_plans_03-21-2025-08-37-59/executable_plan.py", line 69, in <module>
    multi_agent_event = c.step(dict(action='Initialize', agentMode="default", snapGrid=False, gridSize=0.5, rotateStepDegrees=20, visibilityDistance=100, fieldOfView=90, agentCount=3))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/venv/lib/python3.12/site-packages/ai2thor/controller.py", line 997, in step
    raise (TimeoutError if isinstance(e, TimeoutError) else RuntimeError)(
TimeoutError: Error encountered when running action {'action': 'Initialize', 'agentMode': 'default', 'snapGrid': False, 'gridSize': 0.5, 'rotateStepDegrees': 20, 'visibilityDistance': 100, 'fieldOfView': 90, 'agentCount': 3, 'sequenceId': 2} in scene FloorPlan6_physics.

@abpaudel
Copy link
Author

@NA-Wen Your code works fine when I run on mine for 5 agents, so it may be a different issue than mine. As for my issue, it seems like multi-agent support doesn't yet exist for ProcTHOR scenes (see #1169). But since you are not using ProcTHOR scenes, yours should work fine for multi-agent.

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

2 participants