ai2thor icon indicating copy to clipboard operation
ai2thor copied to clipboard

How to get top-down map without the agent in the scene?

Open liuxz-cs opened this issue 2 years ago • 6 comments

When we use the AddThirdPartyCamera action to get the top-down map, there is the agent in the scene. How can we get the top-down map without the agent in the scene?

liuxz-cs avatar Aug 14 '22 13:08 liuxz-cs

And, when we use action AddThirdPartyCamera, we cannot set the y of camera too high, cause that if the y is over the size of the bounds, the camera can only capture the ceiling. So how can we set the parameter of the action AddThirdPartyCamera, we can get the whole complete top-down map of the proper size?

liuxz-cs avatar Aug 14 '22 14:08 liuxz-cs

How can we get the top-down map without the agent in the scene?

Try passing in makeAgentsVisible=False upon Controller initialization or reset (e.g.,:

from ai2thor.controller import Controller
controller = Controller(makeAgentsVisible=False)

Note that this will hide the agents in all of the camera views.

we cannot set the y of camera too high, cause that if the y is over the size of the bounds

When you create / update a third party camera, try passing in farClippingPlane=50, or some larger number. This represents the maximum meters from the camera that pixels may render in the frame.

mattdeitke avatar Aug 15 '22 06:08 mattdeitke

When you create / update a third party camera, try passing in farClippingPlane=50, or some larger number. This represents the maximum meters from the camera that pixels may render in the frame.

For this, I mean althrough I set farClippingPlane=50, when I set y to 2.7, the camera only shows the ceiling covering the scene, when I set y to 2.5, the camera can get the image o f the scene, but sometimes it cannot obtain the image of the whole scene because the y is not high enough. However if the y is set high enough, the camera can only get the ceiling covering the scene, and it has nothing to do with the value of farClippingPlane.

liuxz-cs avatar Aug 15 '22 08:08 liuxz-cs

Oh, I see. Try also passing in rotation=dict(x=90, y=0, z=0). This will tilt the camera down.

Also, you may find the GetMapViewCameraProperties action useful: https://github.com/allenai/ai2thor/pull/814 :)

mattdeitke avatar Aug 15 '22 13:08 mattdeitke

Oh, I see. Try also passing in rotation=dict(x=90, y=0, z=0). This will tilt the camera down.

Also, you may find the GetMapViewCameraProperties action useful: #814 :)

In scenes in i-thor, there exist the ceiling, and use this function, the ceiling cover the while scene, I use the following code:

 controller = Controller(
    scene = "FloorPlan221",
    gridSize = 0.25, 
    renderDepthImage = True,
    renderInstanceSegmentation = True,
    makeAgentsVisible = False
)
event = controller.step(action = "GetMapViewCameraProperties", raise_for_failure = True)
pose = copy.deepcopy(event.metadata["actionReturn"])
bounds = event.metadata["sceneBounds"]["size"]
max_bound = max(bounds["x"], bounds["z"])
pose["fieldOfView"] = 50
pose["position"]["y"] += 1.1 * max_bound
pose["orthographic"] = False
pose["farClippingPlane"] = 50
pose["rotation"] = dict(x = 90, y = 0, z = 0)
del pose["orthographicSize"]
event = controller.step(
    action=  "AddThirdPartyCamera",
    **pose,
    skyboxColor = "white",
    raise_for_failure = True,
)
top_down_frame = event.third_party_camera_frames[-1]
plt.imsave("ai_top.png", top_down_frame)

and I get the following result: ai_top

The celling cover the scene. How can we solve this problem?

liuxz-cs avatar Aug 27 '22 03:08 liuxz-cs

Oh, I see. Try also passing in rotation=dict(x=90, y=0, z=0). This will tilt the camera down.

Also, you may find the GetMapViewCameraProperties action useful: #814 :)

Also, we cant to know how to draw the 3d scene images like this? aa08c1874ef35e210fa0507f13447ca

liuxz-cs avatar Aug 27 '22 04:08 liuxz-cs