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(gate_name) randomly returns nan #38

Closed
yannbouteiller opened this issue Aug 21, 2019 · 2 comments
Closed

simGetObjectPose(gate_name) randomly returns nan #38

yannbouteiller opened this issue Aug 21, 2019 · 2 comments

Comments

@yannbouteiller
Copy link

yannbouteiller commented Aug 21, 2019

Hello,

I have been working quite a while on debugging an algorithm where 'nan' appeared randomly to finally find that this snippet from the baseline is responsible:

def get_ground_truth_gate_poses(self):
        gate_names_sorted_bad = sorted(self.airsim_client.simListSceneObjects("Gate.*"))
        gate_indices_bad = [int(gate_name.split('_')[0][4:]) for gate_name in gate_names_sorted_bad]
        gate_indices_correct = sorted(range(len(gate_indices_bad)), key=lambda k: gate_indices_bad[k])
        gate_names_sorted = [gate_names_sorted_bad[gate_idx] for gate_idx in gate_indices_correct]
        for gate_name in gate_names_sorted:
            p = self.airsim_client.simGetObjectPose(gate_name)
            assert not math.isnan(p.position.x_val), f"DEBUG: {gate_name} p.position.x_val is {p.position.x_val}"
            assert not math.isnan(p.position.y_val), f"DEBUG: {gate_name} p.position.y_val is {p.position.y_val}"
            assert not math.isnan(p.position.z_val), f"DEBUG: {gate_name} p.position.z_val is {p.position.z_val}"
        return [self.airsim_client.simGetObjectPose(gate_name) for gate_name in gate_names_sorted]

This randomly returns 'nan's on random gates after calling airsim_client.reset() repeatedly.

Regards,
Yann.

@yannbouteiller
Copy link
Author

yannbouteiller commented Aug 21, 2019

This workaround does the trick for me:

MAX_NUMBER_OF_GETOBJECTPOSE_TRIALS = 10
def get_ground_truth_gate_poses(self):
        gate_names_sorted_bad = sorted(self.airsim_client.simListSceneObjects("Gate.*"))
        gate_indices_bad = [int(gate_name.split('_')[0][4:]) for gate_name in gate_names_sorted_bad]
        gate_indices_correct = sorted(range(len(gate_indices_bad)), key=lambda k: gate_indices_bad[k])
        gate_names_sorted = [gate_names_sorted_bad[gate_idx] for gate_idx in gate_indices_correct]
        res = []
        for gate_name in gate_names_sorted:
            p = self.airsim_client.simGetObjectPose(gate_name)
            cpt = 0
            while (math.isnan(p.position.x_val) or math.isnan(p.position.y_val) or math.isnan(p.position.z_val)) and cpt < MAX_NUMBER_OF_GETOBJECTPOSE_TRIALS:
                print(f"DEBUG: {gate_name} position is nan, retrying...")
                cpt = cpt + 1
                p = self.airsim_client.simGetObjectPose(gate_name)
            assert not math.isnan(p.position.x_val), f"ERROR: {gate_name} p.position.x_val is still {p.position.x_val} after {cpt} trials"
            assert not math.isnan(p.position.y_val), f"ERROR: {gate_name} p.position.y_val is still {p.position.y_val} after {cpt} trials"
            assert not math.isnan(p.position.z_val), f"ERROR: {gate_name} p.position.z_val is still {p.position.z_val} after {cpt} trials"
            res.append(p)
        return res

msb336 pushed a commit to msb336/AirSim-NeurIPS2019-Drone-Racing that referenced this issue Sep 12, 2019
msb336 pushed a commit to msb336/AirSim-NeurIPS2019-Drone-Racing that referenced this issue Sep 12, 2019
madratman added a commit to madratman/AirSim-NeurIPS2019-Drone-Racing that referenced this issue Sep 12, 2019
madratman added a commit to madratman/AirSim-NeurIPS2019-Drone-Racing that referenced this issue Sep 12, 2019
@madratman
Copy link
Contributor

madratman commented Sep 12, 2019

This is happening very rarely coz of an unreal APIs we're using the backend - getAllActors - which fail randomly.
I've incorporated your suggestion in the baseline racer. It makes sense for the simgetobjectpose API to return NaN when object is not found, and the user to check it coz of this edge case
Didn't want to throw an error, which might kill the user's script

msb336 added a commit that referenced this issue Sep 26, 2019
fix nan checker snippet in baseline_racer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants