How to get position of drone

Hello! How to get the location of the drone when it was just connected? I used the position() function but it didn’t work.

Please share the full output of what you saw.

1 Like

Sorry, I use position() function of class Telemetry and print position.latitude_deg and position.longitude_deg to console, but it print ‘nan’


and my code change in takeoff_and_land

Looks correct. And what’s the output?

This is output:


Sometimes it works properly:
I don’t understand why it works like that.

In the very beginning it has not received any position updates yet, so the data is still nan (not a number). Once it has received data it shows it.

If you did telemetry->position() later it should work.

1 Like

Thank you! I will use it carefully.