Skip to content

Commit

Permalink
Merge pull request #862 from allenai/obstructedObjectFix
Browse files Browse the repository at this point in the history
Adds isInteractable, removes obstructed from the object metadata
  • Loading branch information
winthos authored Sep 28, 2021
2 parents 3ce9fe1 + 4a32f53 commit 95745d5
Show file tree
Hide file tree
Showing 11 changed files with 264 additions and 218 deletions.
4 changes: 2 additions & 2 deletions ai2thor/tests/data/arm-metadata-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"visible": {
"type": "boolean"
},
"obstructed": {
"isInteractable": {
"type": "boolean"
},
"receptacle": {
Expand Down Expand Up @@ -404,7 +404,7 @@
"objectId",
"objectOrientedBoundingBox",
"objectType",
"obstructed",
"isInteractable",
"openable",
"parentReceptacles",
"pickupable",
Expand Down
4 changes: 2 additions & 2 deletions ai2thor/tests/data/metadata-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"visible": {
"type": "boolean"
},
"obstructed": {
"isInteractable": {
"type": "boolean"
},
"receptacle": {
Expand Down Expand Up @@ -268,7 +268,7 @@
"objectId",
"objectOrientedBoundingBox",
"objectType",
"obstructed",
"isInteractable",
"openable",
"parentReceptacles",
"pickupable",
Expand Down
4 changes: 2 additions & 2 deletions unity/Assets/Scripts/AgentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,9 +1295,9 @@ public class ObjectMetadata {
// public float cameraHorizon; moved to AgentMetadata, objects don't have a camerahorizon
public bool visible;

// If true, object is obstructed by something and actions cannot be performed on it.
// If true, object is obstructed by something and actions cannot be performed on it unless forced.
// This means an object behind glass will be obstructed=True and visible=True
public bool obstructed;
public bool isInteractable;

// is this object a receptacle?
public bool receptacle;
Expand Down
208 changes: 123 additions & 85 deletions unity/Assets/Scripts/BaseFPSAgentController.cs

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions unity/Assets/Scripts/DebugInputField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1722,16 +1722,6 @@ IEnumerator executeBatch(JArray jActions) {
break;
}

// Force pickup object
case "fpu": {
ServerAction action = new ServerAction();
action.action = "PickupObject";
action.objectId = splitcommand[1];
action.forceAction = true;
CurrentActiveController().ProcessControlCommand(action);
break;
}

// Get objects in box
case "oib": {
Dictionary<string, object> action = new Dictionary<string, object>();
Expand Down Expand Up @@ -2060,6 +2050,17 @@ IEnumerator executeBatch(JArray jActions) {
break;
}

// Force pickup object
case "fpu": {
Dictionary<string, object> action = new Dictionary<string, object>();
action["action"] = "PickupObject";
if (splitcommand.Length > 1) {
action["objectId"] = splitcommand[1];
}
action["forceAction"] = true;
CurrentActiveController().ProcessControlCommand(action);
break;
}
// pickup using screen coordinates
case "puxy": {
Dictionary<string, object> action = new Dictionary<string, object>();
Expand Down
8 changes: 5 additions & 3 deletions unity/Assets/Scripts/DroneFPSAgentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public override void FixedUpdate() {
}

// generates object metadata based on sim object's properties
public override ObjectMetadata ObjectMetadataFromSimObjPhysics(SimObjPhysics simObj, bool isVisible) {
public override ObjectMetadata ObjectMetadataFromSimObjPhysics(SimObjPhysics simObj, bool isVisible, bool isInteractable) {
DroneObjectMetadata objMeta = new DroneObjectMetadata();
objMeta.isCaught = this.isObjectCaught(simObj);
objMeta.numSimObjHits = simObj.numSimObjHit;
Expand Down Expand Up @@ -181,8 +181,6 @@ public override ObjectMetadata ObjectMetadataFromSimObjPhysics(SimObjPhysics sim
}
}



// can this object change others to hot?
objMeta.isHeatSource = simObj.isHeatSource;

Expand Down Expand Up @@ -213,6 +211,10 @@ public override ObjectMetadata ObjectMetadataFromSimObjPhysics(SimObjPhysics sim
// in the multiagent setting, explicitly giving this information for now.
objMeta.visible = isVisible; // simObj.isVisible;

//determines if the objects is unobstructed and interactable. Objects visible behind see-through geometry like glass will be isInteractable=False even if visible
//note using forceAction=True will ignore the isInteractable requirement
objMeta.isInteractable = isInteractable;

objMeta.isMoving = simObj.inMotion;// keep track of if this object is actively moving

objMeta.objectOrientedBoundingBox = simObj.ObjectOrientedBoundingBox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ SimObjPhysics cover in availableExpRoomContainersDict.OrderBy(
return false;
}
if (i == 0) {
if (isSimObjVisible(visibilityCheckCamera, toCover, 10f)) {
if (isSimObjVisible(visibilityCheckCamera, toCover, 10f).visible) {
return false;
}
}
Expand Down Expand Up @@ -415,9 +415,11 @@ public void ObjectsVisibleFromThirdPartyCamera(int thirdPartyCameraIndex, float?
if (!maxDistance.HasValue) {
maxDistance = maxVisibleDistance;
}

SimObjPhysics[] interactable;
actionFinishedEmit(true,
GetAllVisibleSimObjPhysicsDistance(
agentManager.thirdPartyCameras[thirdPartyCameraIndex], maxDistance.Value, null
agentManager.thirdPartyCameras[thirdPartyCameraIndex], maxDistance.Value, null, out interactable
).Select(sop => sop.ObjectID).ToList()
);
}
Expand All @@ -441,9 +443,8 @@ public void ProportionOfObjectVisible(
Camera camera = thirdPartyCameraIndex.HasValue ? agentManager.thirdPartyCameras[thirdPartyCameraIndex.Value] : m_Camera;
foreach (Transform point in visPoints) {
// if this particular point is in view...
if (CheckIfVisibilityPointInViewport(
target, point, camera, false
)) {

if (CheckIfVisibilityPointInViewport(target, point, camera, false).visible) {
visPointCount++;
}
}
Expand Down
Loading

0 comments on commit 95745d5

Please sign in to comment.