Initialization

Prior to running any additional commands, it is assumed you have run the following::

import ai2thor.controller
controller = ai2thor.controller.Controller()
controller.start()
# can be any one of the scenes FloorPlan###
controller.reset('FloorPlan28')
controller.step(dict(action='Initialize', gridSize=0.25))

Initialize

Initialize must be called after resetting a scene to set fields such as gridSize.

controller.step(dict(action='Initialize', gridSize=0.25))
Parameter Type Description Default
gridSize float Size of the grid that the agent navigates in. This determines the step size that the agent takes when the actions MoveAhead, MoveBack, MoveRight, MoveLeft are taken. 0.25
renderDepthImage bool When enabled a depth image is sent and made available on the returned Event as the attribute depth_frame. False
renderClassImage bool When enabled a class segmentation image is sent and made available on the returned Event as the attribute class_segmentation_frame. False
renderObjectImage bool When enabled an object segmentation image is sent and made available on the returned Event as the attribute instance_segmentation_frame. False
visibilityDistance float Distance in meters from the agent’s camera (positioned near the top of the agent) that an object should be considered visibile. 1.5
cameraY float Height of the camera attached to the agent. 0.675
fieldOfView float Field of view for the agent’s camera. Corresponds to the value Camera.fieldOfView 60.0



Object Position Randomization

After initializing the scene, pickupable objects can have their default positions randomized to any valid receptacle they could be placed in within the scene.

controller.reset('FloorPlan28')
controller.step(dict(action='Initialize', gridSize=0.25))
controller.step(dict(action = 'InitialRandomSpawn', randomSeed = 0, forceVisible = false, maxNumRepeats = 5))

Remember to reset and initiialize the scene before using the Position Randomizer, otherwise seeded values will be innacurate.

Parameter Type Description Default
randomSeed int Used to seed the randomization for duplicatable scene states. Because this seed depends on the current state of the scene, remember to reset the scene with controller.reset() before running InitialRandomSpawn(), otherwise the seeded randomization will not be accurate 0
forceVisible bool When enabled, the scene will attempt to randomize all moveable objects outside of receptacles in plain view. Use this if you want to avoid objects spawning inside closed drawers, cabinets, etc. False
maxNumRepeats int how many times each object in the scene attempts to randomly spawn. Setting this value higher will lead to fewer spawn failures at the cost of performance 5

All Object State Randomization

After initializing the scene, all objects with State changes can have their initial states randomized. This will randomly set or toggle all potential states that every sim object has (ie: a Cup might randomly be filled with water, dirty, broken, etc.). Use this after randomizing object positions with InitialRandomSpawn as many state changes are one-way and destructive, so objects cannot be guaranteed to be repositioned if states have already be randomized.

controller.reset('FloorPlan28')
controller.step(dict(action='Initialize', gridSize=0.25))
controller.step(dict(action = 'RandomToggleStateOfAllObjects', randomSeed = 0))
Parameter Type Description Default
randomSeed int Used to seed the randomization for duplicatable scene states. Because this seed depends on the current state of the scene, always reset the scene with controller.reset() before performing additional Random state toggles. 0

Specific State Randomization

After initializing the scene, this will randomly set or toggle the state of all sim objects in the scene that have the state specified by StateChange (ie: Randomly break all objects in the scene that CanBreak). Use this after randomizing object positions with InitialRandomSpawn as many state changes are one-way and destructive, so objects cannot be guaranteed to be repositioned if states have already be randomized.

controller.reset('FloorPlan28')
controller.step(dict(action='Initialize', gridSize=0.25))
controller.step(dict(action = 'RandomToggleSpecificState', randomSeed = 0, StateChange = "CanOpen");
Parameter Type Description Default
randomSeed int Used to seed the randomization for duplicatable scene states. Because this seed depends on the current state of the scene, always reset the scene with controller.reset() before performing additional Random state toggles. 0
StateChange string Used to specify which state to randomly toggle for all objects that have the state. Valid states are: CanOpen, CanToggleOnOff, CanBeFilled, CanBeSliced, CanBeCooked, CanBreak, CanBeDirty, CanBeUsedUp CanOpen

Next Steps

Continue on to the Agent Navigation documentation for information on how to manipulate and move the Agent within the environment.