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

bug: map projections with nan values #138

Open
mrpollo opened this issue Nov 1, 2018 · 8 comments
Open

bug: map projections with nan values #138

mrpollo opened this issue Nov 1, 2018 · 8 comments

Comments

@mrpollo
Copy link
Contributor

mrpollo commented Nov 1, 2018

In plot_app/helper.py#227-229

Consider the following conditionals

    arg = sin_anchor_lat * sin_lat + cos_anchor_lat * cos_lat * cos_d_lon
    arg[arg > 1] = 1
    arg[arg < -1] = -1

for the following example value of arg of type Numpy.Array

array([-0.0488, -0.042 ,  1.    ,  1.    ,  1.    ,     nan,  1.    ,
        1.    ])

Looks like we either filter nan values or learn how to deal with them

Errors:

flight_review/plot_app/helper.py:229: RuntimeWarning: invalid value encountered in greater
  arg[arg > 1] = 1
flight_review/plot_app/helper.py:230: RuntimeWarning: invalid value encountered in less
  arg[arg < -1] = -1
@bkueng
Copy link
Member

bkueng commented Nov 5, 2018

Probably filtering them out is best.

@mrpollo
Copy link
Contributor Author

mrpollo commented Nov 5, 2018

I wasn't sure if that was feasible, I don't think I grasp 100% of the math here, and I wasn't sure if filtering out NaN would even be a problem.

I'll submit a PR shortly.

@mrpollo
Copy link
Contributor Author

mrpollo commented Nov 5, 2018

Tried filtering but I noticed setpoints on maps are not displayed correctly with the following change

+    a = sin_anchor_lat * sin_lat + cos_anchor_lat * cos_lat * cos_d_lon
+    arg = np.array([index for index in a if np.isfinite(index)])

Any ideas?

with filter
screenshot 2018-11-05 11 25 10

no filter
screenshot 2018-11-05 11 24 04

@mrpollo
Copy link
Contributor Author

mrpollo commented Nov 5, 2018

Not sure if this is related, but the following plots show NaN regardless of this change

screenshot 2018-11-05 11 26 13
screenshot 2018-11-05 11 25 58

@bkueng
Copy link
Member

bkueng commented Nov 6, 2018

Can you provide the log(s)? It should not contain NaNs.

@mrpollo
Copy link
Contributor Author

mrpollo commented Nov 6, 2018

I randomly picked a log out of logs.px4.io/browse, I lost track of which one it was and since I'm not the original author I won't be re-uploading it to the site, instead here's a link to download that will probably remain available for a few weeks (sorry if you are reading this and the file is no longer available)

@bkueng
Copy link
Member

bkueng commented Nov 7, 2018

Thanks, I'll have a look. Log is here btw (the ID was still in the filename): https://logs.px4.io/plot_app?log=ba165f7d-113d-4c5d-b479-1fcf21e99175

@bkueng
Copy link
Member

bkueng commented Nov 8, 2018

For the lat, lon issue, you need to filter earlier, like this:

diff --git a/plot_app/helper.py b/plot_app/helper.py
index c2018eb..a26184c 100644
--- a/plot_app/helper.py
+++ b/plot_app/helper.py
@@ -218,6 +218,11 @@ def WGS84_to_mercator(lon, lat):

 def map_projection(lat, lon, anchor_lat, anchor_lon):
     """ convert lat, lon in [rad] to x, y in [m] with an anchor position """
+
+    # filter NaN values
+    lat = lat[~np.isnan(lat)]
+    lon = lon[~np.isnan(lon)]
+
     sin_lat = np.sin(lat)
     cos_lat = np.cos(lat)
     cos_d_lon = np.cos(lon - anchor_lon)

The NaN's in attitude are valid and fixed in #140.

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