Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simGetObjectPose() sometimes returns NaN #2695

Closed
MSBGit opened this issue May 15, 2020 · 6 comments
Closed

simGetObjectPose() sometimes returns NaN #2695

MSBGit opened this issue May 15, 2020 · 6 comments

Comments

@MSBGit
Copy link

MSBGit commented May 15, 2020

simGetObjectPose() sometimes returns NaN values due to a bug in UE4 API that is used to retrieve Actor information. The common way to deal with this in client code is to retry the call to simGetObjectPose() a number of times until valid data is returned or until the caller decides that it has made too many calls or waited too long for valid data. It would be great if AirSim would do the retries under the hood and not require clients of AirSim to do this. Then when/if the UE4 bug is fixed, client code doesn't need to change.

@rajat2004
Copy link
Contributor

This could also be due to the Actor not being found
https://github.com/microsoft/AirSim/blob/master/Unreal/Plugins/AirSim/Source/WorldSimApi.cpp#L75
Is there any bug report or forum post regarding this?

As to checking and retrying, ContainsNaN could be used for this I guess. No of retries and timeout will have to decided

@MSBGit
Copy link
Author

MSBGit commented May 20, 2020

This happens every so often, particularly when I am calling simGetObjectPose() at a 1Hz rate. I always call it for the same actor ID or tag.

Is there any bug report or forum post regarding this?

Do you mean a bug report or forum post in an Unreal bug system or forum? I haven't found any but I didn't do an exhaustive search.

Here is one example of how I deal with this in one of my Python modules:

def airsim_get_pose(airsim_client, object_name):
    """ Get the pose of the specified object from AirSim. Run in a loop to
    work around a bug where this sometimes returns nan."""
    for i in range(2):
        obj_pose = airsim_client.simGetObjectPose(object_name)
        if (not math.isnan(obj_pose.position.x_val) and \
            not math.isnan(obj_pose.position.y_val) and \
            not math.isnan(obj_pose.position.z_val) and \
            not math.isnan(obj_pose.orientation.x_val) and \
            not math.isnan(obj_pose.orientation.y_val) and \
            not math.isnan(obj_pose.orientation.z_val) and \
            not math.isnan(obj_pose.orientation.w_val)):
            return obj_pose
        time.sleep(0.0001)
    return None

@rajat2004
Copy link
Contributor

That does look quite painful. I've added a utility function in #2683 which will atleast reduce the amount of code required.
I agree, this could be checked inside AirSim itself, and called again if the Pose is Nan. However, this can be done only a few no. of times, and even then I think a check from the client side will be required just to be sure

@MSBGit
Copy link
Author

MSBGit commented May 20, 2020

That does look quite painful. I've added a utility function in #2683 which will at least reduce the amount of code required.

Thanks. I'll see if I can find the underlying Unreal issue that causes this.

@jonyMarino
Copy link
Collaborator

@MSBGit I'm not sure if was fixed in UE 4.24.3 but I'm not getting NaN never. Can you confirm?

@jonyMarino
Copy link
Collaborator

This issue got fixed in PR 2898, which added an asset map and scene object map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants