allenai / ai2thor

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

Bizarre Physics on Couch #753

Open thomason-jesse opened 3 years ago

thomason-jesse commented 3 years ago

I have the initial configuration that caused this to happen, but when I reload the simulator with it it doesn't happen each time. It seems like something on the couch isn't resolving right with respect to physics, so the couch just keeps sliding backwards until catastrophically colliding with everything else. The couch started sliding on simulator startup and settled eventually by the back window.

Screen Shot 2021-05-14 at 1 41 28 PM Screen Shot 2021-05-14 at 1 41 41 PM

winthos commented 3 years ago

Yes, please post the initial configuration to see how this might be replicated. Based on these images, it appears you are placing objects stationary = TRUE in some way. When this happens, the rigidbody of an object is set to kinematic true. My guess is some sort of placed kinematic rigidbody is clipping with a non kinematic body, causing it to move and slide as shown here.

When a kinematic body is parented to a nonkinematic body, if their colliders intersect, the kinematic object will constantly "shove" the nonkinematic body in an attempt to resolve their collision, but because the objects are parented they cannot separate, causing this sliding behavior. That appears to be what is going on.

If you could post a code snippet so that I can replicate this in-editor, I could investigate exactly which object, or perhaps what sequence of actions lead to this state. Ideally you do not want to mix and match placeStationary while also wanting objects to be moveable. If you want all objects placed on the sofa or on the table to then be able to be moved, I would recommend just letting physics resolve their placement by itself.

winthos commented 3 years ago

Another thing that may help are two helper functions that are currently undocumented, but are available to use on the latest version.

This will force all sim objects to have their kinematics set to true, and also force their primary property to change from moveable/pickupable to static. This means these objects will not longer be able to be picked up or shoved around, so this will only be useful for object navigation, as interacting with objects will be effectively disabled when this is used.

controller.step(action="MakeAllObjectsStationary")

This action makes all sim objects to have their kinematics set to false, causing physics to immediately begin resolving their positions if required.

controller.step(action="MakeAllObjectsMoveable")
thomason-jesse commented 3 years ago

The initial behavior was observed when I used InitialRandomSpawn with placeStationary=True, but in subsequent attempts to replicate the behavior I'm using SetObjectPoses with placeStationary=True. I've included the latter call below. The MakeAllObjectsStationary solution won't work for me since I'm doing object interaction, and MakeAllObjectsMoveable sounds like it might create a small nightmare for non-deterministic behavior for episode replay, etc. for ML 😬

Simulator start config:

{'scene': 'FloorPlan201_physics', 'gridSize': 0.25, 'snapToGrid': True, 'visibilityDistance': 1.5, 'width': 900, 'height': 900, 'agentCount': 1, 'commit_id': '2cca88de394ff1fa3f85f9ee3585444552059da9'}

Initial config:

{'action': 'SetObjectPoses', 'objectPoses': [{'objectName': 'Bowl_7550395a', 'rotation': {'x': -0.00013105418474879116, 'y': 5.8590365370037034e-05, 'z': -0.0001388449891237542}, 'position': {'x': -2.1718571186065674, 'y': 0.34545159339904785, 'z': 4.766630172729492}}, {'objectName': 'Bowl_7550395a', 'rotation': {'x': -0.00013105418474879116, 'y': 5.8590365370037034e-05, 'z': -0.0001388449891237542}, 'position': {'x': -2.250732421875, 'y': 0.09605193883180618, 'z': 4.845340728759766}}, {'objectName': 'Newspaper_ed198726', 'rotation': {'x': 1.6171410083770752, 'y': 86.24957275390625, 'z': 1.0230543613433838}, 'position': {'x': -1.8429360389709473, 'y': 0.45266205072402954, 'z': 3.403693437576294}}, {'objectName': 'Watch_1c5a7993', 'rotation': {'x': 1.6171410083770752, 'y': 86.24957275390625, 'z': 1.0230543613433838}, 'position': {'x': -2.095585584640503, 'y': 0.4577411413192749, 'z': 3.207230567932129}}, {'objectName': 'Vase_1c69ba8d', 'rotation': {'x': -0.0001767237699823454, 'y': 0.01727353408932686, 'z': -5.624519326374866e-05}, 'position': {'x': -2.490907907485962, 'y': 0.6862150430679321, 'z': 1.0520662069320679}}, {'objectName': 'Vase_1c69ba8d', 'rotation': {'x': -0.0001767237699823454, 'y': 0.01727353408932686, 'z': -5.624519326374866e-05}, 'position': {'x': -1.825070858001709, 'y': 0.6862151622772217, 'z': 1.2990646362304688}}, {'objectName': 'Pen_38a5a485', 'rotation': {'x': 5.6245200539706275e-05, 'y': 90.01727294921875, 'z': -0.00017672379908617586}, 'position': {'x': -2.9346377849578857, 'y': 0.6918617486953735, 'z': 1.4229989051818848}}, {'objectName': 'Pencil_b282d60f', 'rotation': {'x': 0.0005257498123683035, 'y': 321.31817626953125, 'z': 0.0004969359142705798}, 'position': {'x': -1.2489982843399048, 'y': 0.47517186403274536, 'z': 5.790215969085693}}, {'objectName': 'CreditCard_175f12dc', 'rotation': {'x': -0.00013105418474879116, 'y': 5.8590365370037034e-05, 'z': -0.0001388449891237542}, 'position': {'x': -2.556231737136841, 'y': 0.3428759276866913, 'z': 5.1550726890563965}}, {'objectName': 'RemoteControl_eb7522de', 'rotation': {'x': -0.0001767237699823454, 'y': 0.01727353408932686, 'z': -5.624519326374866e-05}, 'position': {'x': -2.712679624557495, 'y': 0.6879205703735352, 'z': 1.5465316772460938}}, {'objectName': 'Box_c586a821', 'rotation': {'x': -0.0001767237699823454, 'y': 0.01727353408932686, 'z': -5.624519326374866e-05}, 'position': {'x': -2.2688374519348145, 'y': 0.8779166340827942, 'z': 1.5463972091674805}}, {'objectName': 'Box_c586a821', 'rotation': {'x': 1.0226492881774902, 'y': 356.22076416015625, 'z': 358.3825988769531}, 'position': {'x': -2.1199073791503906, 'y': 0.6438950896263123, 'z': 3.6586155891418457}}, {'objectName': 'Pillow_4a1ae820', 'rotation': {'x': 0.006414187140762806, 'y': -0.00020801859500352293, 'z': 0.004846717696636915}, 'position': {'x': -2.261432409286499, 'y': 0.31496813893318176, 'z': 6.37723970413208}}, {'objectName': 'Laptop_718b7c6a', 'rotation': {'x': 1.0226492881774902, 'y': 356.22076416015625, 'z': 358.3825988769531}, 'position': {'x': -1.5905194282531738, 'y': 0.43894630670547485, 'z': 3.5999855995178223}}, {'objectName': 'Laptop_718b7c6a', 'rotation': {'x': -0.0004969358560629189, 'y': 51.318172454833984, 'z': 0.0005257496377453208}, 'position': {'x': -0.7439574003219604, 'y': 0.4704503118991852, 'z': 5.837979793548584}}, {'objectName': 'Book_2ac32d6c', 'rotation': {'x': 1.9957529730163515e-05, 'y': 242.63967895507812, 'z': -5.757989129051566e-05}, 'position': {'x': -4.342825889587402, 'y': 0.4704478681087494, 'z': 5.73518180847168}}, {'objectName': 'Box_c586a821', 'rotation': {'x': 0.0005148173659108579, 'y': -4.964526669937186e-05, 'z': 0.001743022003211081}, 'position': {'x': -3.362011194229126, 'y': 0.1933620423078537, 'z': 6.426006317138672}}, {'objectName': 'Statue_e3fdcaf8', 'rotation': {'x': 1.0226492881774902, 'y': 356.22076416015625, 'z': 358.3825988769531}, 'position': {'x': -1.5727813243865967, 'y': 0.4437505006790161, 'z': 3.3314473628997803}}, {'objectName': 'Laptop_718b7c6a', 'rotation': {'x': -0.0009860903955996037, 'y': 329.23590087890625, 'z': 0.0005484414286911488}, 'position': {'x': -1.6986356973648071, 'y': 0.6798738241195679, 'z': 1.6595364809036255}}, {'objectName': 'Television_4addc2dc', 'rotation': {'x': 359.9634704589844, 'y': 179.990966796875, 'z': 0.010014066472649574}, 'position': {'x': -2.356977701187134, 'y': 1.205823302268982, 'z': 6.246156692504883}}, {'objectName': 'HousePlant_3023153b', 'rotation': {'x': 0.003645721822977066, 'y': 0.0017206792254000902, 'z': -0.0031924748327583075}, 'position': {'x': -2.9329960346221924, 'y': 0.5955494046211243, 'z': -0.09395638108253479}}, {'objectName': 'TissueBox_ab5820df', 'rotation': {'x': -0.0001767237699823454, 'y': 0.01727353408932686, 'z': -5.624519326374866e-05}, 'position': {'x': -1.6031501293182373, 'y': 0.6872583031654358, 'z': 1.2989976406097412}}, {'objectName': 'CreditCard_175f12dc', 'rotation': {'x': -0.0001767237699823454, 'y': 0.01727353408932686, 'z': -5.624519326374866e-05}, 'position': {'x': -2.9347493648529053, 'y': 0.6846601963043213, 'z': 1.0521999597549438}}, {'objectName': 'Plate_eb4e4676', 'rotation': {'x': -0.00013105418474879116, 'y': 5.8590365370037034e-05, 'z': -0.0001388449891237542}, 'position': {'x': -2.1711158752441406, 'y': 0.6082373857498169, 'z': 4.844342231750488}}, {'objectName': 'KeyChain_167e8f3a', 'rotation': {'x': 0.00013884501822758466, 'y': 90.00006103515625, 'z': -0.00013105418474879116}, 'position': {'x': -2.3260064125061035, 'y': 0.6081990003585815, 'z': 4.844342231750488}}, {'objectName': 'GarbageCan_1f148d38', 'rotation': {'x': 0.007500971667468548, 'y': 89.9532241821289, 'z': -0.0014052470214664936}, 'position': {'x': -4.864551544189453, 'y': -0.0010344088077545166, 'z': 0.26722151041030884}}, {'objectName': 'FloorLamp_6190ff49', 'rotation': {'x': 0.004812958184629679, 'y': 316.9354553222656, 'z': 0.045055244117975235}, 'position': {'x': -0.5665968656539917, 'y': 0.002766132354736328, 'z': 0.024653425440192223}}, {'objectName': 'Vase_1c69ba8d', 'rotation': {'x': 0.006414187140762806, 'y': -0.00020801859500352293, 'z': 0.004846717696636915}, 'position': {'x': -2.6363112926483154, 'y': 0.24444742500782013, 'z': 6.135425090789795}}, {'objectName': 'DeskLamp_9ecba3b6', 'rotation': {'x': 0.0641014501452446, 'y': 0.24849015474319458, 'z': 0.3417264521121979}, 'position': {'x': -0.2733239233493805, 'y': 0.700796365737915, 'z': 3.6126513481140137}}, {'objectName': 'Pencil_b282d60f', 'rotation': {'x': 0.0022119604982435703, 'y': 0.0008692800183780491, 'z': -0.0020661649759858847}, 'position': {'x': -2.9314708709716797, 'y': 0.6147384643554688, 'z': -0.20023339986801147}}, {'objectName': 'Pillow_4a1ae820', 'rotation': {'x': 358.8290710449219, 'y': 177.63771057128906, 'z': 1.5279948711395264}, 'position': {'x': -3.1134774684906006, 'y': 0.5529193878173828, 'z': 3.225052833557129}}, {'objectName': 'Bowl_7550395a', 'rotation': {'x': 0.007500971667468548, 'y': 89.9532241821289, 'z': -0.0014052470214664936}, 'position': {'x': -4.864466190338135, 'y': 0.049807947129011154, 'z': 0.17153659462928772}}, {'objectName': 'RemoteControl_eb7522de', 'rotation': {'x': 0.0005148173659108579, 'y': -4.964526669937186e-05, 'z': 0.001743022003211081}, 'position': {'x': -3.3620059490203857, 'y': 0.024274572730064392, 'z': 6.318464756011963}}, {'objectName': 'Watch_1c5a7993', 'rotation': {'x': 1.6171410083770752, 'y': 86.24957275390625, 'z': 1.0230543613433838}, 'position': {'x': -1.8312618732452393, 'y': 0.4502626061439514, 'z': 3.224557399749756}}, {'objectName': 'Pen_38a5a485', 'rotation': {'x': -0.00013105418474879116, 'y': 5.8590365370037034e-05, 'z': -0.0001388449891237542}, 'position': {'x': -2.248560905456543, 'y': 0.6127803325653076, 'z': 5.154998779296875}}, {'objectName': 'Newspaper_ed198726', 'rotation': {'x': 1.0226492881774902, 'y': 356.22076416015625, 'z': 358.3825988769531}, 'position': {'x': -2.642366886138916, 'y': 0.4532760977745056, 'z': 3.4408302307128906}}, {'objectName': 'SideTable_cef19ac5', 'rotation': {'x': 0.05089559778571129, 'y': 270.0382080078125, 'z': 0.004339828155934811}, 'position': {'x': -0.25502318143844604, 'y': 0.00188368558883667, 'z': 3.3689963817596436}}, {'objectName': 'ArmChair_323e738d', 'rotation': {'x': -5.757989129051566e-05, 'y': 152.63970947265625, 'z': -1.995754792005755e-05}, 'position': {'x': -4.376028060913086, 'y': -1.0967254638671875e-05, 'z': 6.016268730163574}}, {'objectName': 'ArmChair_364ebecb', 'rotation': {'x': 0.0004969361471012235, 'y': 231.3181915283203, 'z': -0.000525749521329999}, 'position': {'x': -0.8474658131599426, 'y': -9.59634780883789e-06, 'z': 5.983976364135742}}, {'objectName': 'DiningTable_599f0096', 'rotation': {'x': -0.0001767237699823454, 'y': 0.01727353408932686, 'z': -5.624519326374866e-05}, 'position': {'x': -2.26887583732605, 'y': -0.016784071922302246, 'z': 1.4228003025054932}}, {'objectName': 'CoffeeTable_854d98c6', 'rotation': {'x': -0.00013105418474879116, 'y': 5.8590365370037034e-05, 'z': -0.0001388449891237542}, 'position': {'x': -2.326007604598999, 'y': 0.002134770154953003, 'z': 4.9220075607299805}}, {'objectName': 'TVStand_26eb2906', 'rotation': {'x': 0.006414187140762806, 'y': -0.00020801859500352293, 'z': 0.004846717696636915}, 'position': {'x': -2.3852694034576416, 'y': 0.006555378437042236, 'z': 6.296602725982666}}, {'objectName': 'Sofa_0722df8d', 'rotation': {'x': 1.0226492881774902, 'y': 356.22076416015625, 'z': 358.3825988769531}, 'position': {'x': -2.3795530796051025, 'y': -0.09131979942321777, 'z': 3.24937105178833}}, {'objectName': 'SideTable_faa04c7b', 'rotation': {'x': 0.0022119604982435703, 'y': 0.0008692800183780491, 'z': -0.0020661649759858847}, 'position': {'x': -2.9359912872314453, 'y': 0.004407107830047607, 'z': -0.10397173464298248}}, {'objectName': 'SideTable_1868d2af', 'rotation': {'x': 0.00016074262384790927, 'y': -0.0001348929072264582, 'z': -2.9748712222499307e-06}, 'position': {'x': -2.113999605178833, 'y': 0.002106785774230957, 'z': -0.1400027722120285}}, {'objectName': 'Chair_ffaf216e', 'rotation': {'x': 0.05755050107836723, 'y': 359.9834289550781, 'z': 0.2903119623661041}, 'position': {'x': -1.8620448112487793, 'y': 0.02012231945991516, 'z': 1.0353593826293945}}, {'objectName': 'Chair_f31ee21b', 'rotation': {'x': 0.05773348733782768, 'y': 104.99970245361328, 'z': 0.2903056740760803}, 'position': {'x': -3.1229865550994873, 'y': 0.02012118697166443, 'z': 1.4100403785705566}}, {'objectName': 'Chair_477dc4d9', 'rotation': {'x': 0.05748341232538223, 'y': 185.03213500976562, 'z': 0.29025664925575256}, 'position': {'x': -1.8640297651290894, 'y': 0.020124435424804688, 'z': 1.8382856845855713}}, {'objectName': 'Chair_61055466', 'rotation': {'x': 0.05749853327870369, 'y': 6.188820838928223, 'z': 0.29026344418525696}, 'position': {'x': -2.5079846382141113, 'y': 0.020122110843658447, 'z': 0.991270899772644}}, {'objectName': 'Chair_bc39b412', 'rotation': {'x': 0.057656027376651764, 'y': 164.9768829345703, 'z': 0.29038891196250916}, 'position': {'x': -2.5190091133117676, 'y': 0.02012050151824951, 'z': 1.88224458694458}}, {'objectName': 'Chair_158507f1', 'rotation': {'x': 0.057717133313417435, 'y': 270.3693542480469, 'z': 0.2903945744037628}, 'position': {'x': -1.335023283958435, 'y': 0.020121604204177856, 'z': 1.4301602840423584}}], 'placeStationary': True}
winthos commented 3 years ago

Gotchya, I'll look into replicating what is going on and see if its a specific set of objects clipping causing this behavior. Ideally, it should be relatively simple to adjust the colliders to make more room to prevent clipping. I'll post here again once I have more info.

winthos commented 3 years ago

Ok, I have found something interesting. I believe what is happening is when you restore your configuration using SetObjectPoses, the y value of the sofa's position is being set so that it gets clipped into the ground slightly. You can see the default position of the sofa is flush with the floor's plane in this image, and the sofa has a default y position value of -0.003344029 defaultSofaPos

After running your config with SetObjectPoses, the sofa ends up clipping with the floor given its y value of -0.09131979942321777

{"objectName": "Sofa_0722df8d", "rotation": {"x": 1.0226492881774902, "y": 356.22076416015625, "z": 358.3825988769531}, "position": {"x": -2.3795530796051025, "y": -0.09131979942321777, "z": 3.24937105178833}}

SetObjectPosesSofaPos

I believe the weird physics behavior is because the sofa ends up below the floor, it tries to self correct and resolve the collision by shoving the whole sofa and any contained objects up. But, because of the placeStationary value, the objects that are on top of the sofa are trying to keep the sofa in place, so it ends up wiggling around due to these conflicting physics resolutions trying to happen at the same time.

What is curious is I'm not sure how the sofa's y value ended up that low. Could you provide the InitialRandomSpawn you used to generate the values you passed in to SetObjectPoses? I'd like to try and replicate that call, because the sofa shouldn't be moving at all when InitialRandomSpawn is called, so perhaps something about placeStationary during InitialRandomSpawn lead to the bad y value, which subsequently caused the behavior you are observing when SetObjectPoses is used with the values generated after InitialRandomSpawn.