question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow actions at (x, y) to return objectID on success

See original GitHub issue

I’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.

  1. Is there any way to do it with the currently exposed methods?

  2. 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:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mattdeitkecommented, Feb 9, 2021

I don’t necessarily think returning the objectId will work in every case, since some actions (i.e., TouchThenApplyForce) already return information to the actionReturn.

What I may add is a query action to the environment for the object at (x, y):

controller.step('GetObject', x=x, y=y, forceAction=True/False)

where forceAction specifies if visibility/interactability distance to the object should be ignored.

If an object is there, the objectId is returned inside of actionReturn. If not, the action return will be either null or empty. Then, if an objectId is returned, you can guarantee that calling:

controller.step('OpenObject', x=x, y=y, forceAction=True/False)

targets an object, or can equivalently pass in the returned objectId, which is marginally faster:

objectId = controller.step('GetObject', x=x, y=y, forceAction=True/False).metadata['actionReturn']
if objectId:
    controller.step('OpenObject', objectId=objectId, forceAction=True/False)

Is this of interest?

1reaction
mattdeitkecommented, Feb 23, 2021

This functionality is now supported in v2.7.4. with the new GetObjectInFrame query action:

forceAction = True
query = controller.step('GetObjectInFrame', x=x, y=y, forceAction=forceAction)
if query:
    controller.step(
        action='OpenObject',
        objectId=query.metadata['actionReturn'],
        forceAction=forceAction
    )

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 to query.metadata['lastActionSuccess'].


If you’re using Python 3.8+ you can also use the new walrus operator:

forceAction = True
if (query :=  = controller.step('GetObjectInFrame', x=x, y=y, forceAction=forceAction):
    controller.step(
        action='OpenObject',
        objectId=query.metadata['actionReturn'],
        forceAction=forceAction
    )

which merges the query declaration inside of the conditional.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cast to ObjectId failed for value \"updateInstock\" (type ...
I'm trying to get this to my backend in my productRouter.js , so that I can update ... actions/orderActions'; import {updateInstock} from '....
Read more >
00211: <value> cannot be used with sync capability—ArcGIS ...
To use sync capability, relationship classes and attachments must be based on a Global ID field. Solution. Use Migrate Relationship Class to convert...
Read more >
How To Use Transactions in MongoDB
A transaction is a sequence of database operations that will only succeed if every operation within the transaction has been executed ...
Read more >
Is there a way to get the objectID of an document from ...
And After getting the User-ID I wanna get the "Currency" field in the same document as the "User-ID" with the help of "_id"....
Read more >
ObjectId() — MongoDB Manual
Returns a new ObjectId. The 12-byte ObjectId consists of: A 4-byte timestamp, representing the ObjectId's creation, measured in seconds since the Unix epoch ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found