Allow actions at (x, y) to return objectID on success
See original GitHub issueI’m using actions that accept x, y positions as inputs (e.g. event = controller.step('OpenObject', x=0.2, y=0.5)
). Once it’s executed, I’m trying to figure out what object was interacted with.
-
Is there any way to do it with the currently exposed methods?
-
Alternately, is there a way to just get the object that the raycast would hit?
public bool ScreenToWorldTarget(float x, float y, ref SimObjPhysics target, bool requireWithinViewportRange)
does this and populates target
, but this isn’t an exposed method. Could this be made a callable easily?
Is there an easy way to do what I’m after? I thought I could just modify the interaction functions to return the target as a feedback parameter: e.g.actionFinished(true) --> actionFinished(true, feedback)
like some methods that return info in actionReturn
, but I’m finding it hard to parse recent code. PutObject has an actionFinished(true)
, but OpenObject does not, so I got confused.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
I don’t necessarily think returning the
objectId
will work in every case, since some actions (i.e.,TouchThenApplyForce
) already return information to theactionReturn
.What I may add is a query action to the environment for the object at
(x, y)
:where
forceAction
specifies if visibility/interactability distance to the object should be ignored.If an object is there, the
objectId
is returned inside ofactionReturn
. If not, the action return will be either null or empty. Then, if anobjectId
is returned, you can guarantee that calling:targets an object, or can equivalently pass in the returned objectId, which is marginally faster:
Is this of interest?
This functionality is now supported in v2.7.4. with the new
GetObjectInFrame
query action:Documentation will be updated shortly. But, briefly,
forceAction=True
lets the targeted object be further away than the initialized visibility/insteractable distance of 1.5 meters.Also note that
bool(ai2thor.server.Event)
(i.e.,bool(query)
) is now an alias toquery.metadata['lastActionSuccess']
.If you’re using Python 3.8+ you can also use the new walrus operator:
which merges the query declaration inside of the conditional.