dronekit / dronekit-python

DroneKit-Python library for communicating with Drones via MAVLink.
https://readthedocs.org/projects/dronekit-python/
Apache License 2.0
1.62k stars 1.45k forks source link

Methods to get distance to target and from home #133

Open hamishwillee opened 9 years ago

hamishwillee commented 9 years ago

It is useful to be able to perform actions based on distance to target or distance from home. It would also be useful to be able to get a callback when the distance from target/home is a certain value.

While the maths for determining distances is fairly straighforward, this is probably required often enough that providing an API makes sense.

hamishwillee commented 9 years ago

More generically would probably be good to be able to shove in any two Location objects and get the distance (maybe both as single number at ground level (ie x, y plane) and as an x, y, z)

krufab commented 9 years ago

More generally, there are a bunch of functions that could be imported from the ardupilot autotest common.py file as they might be useful... I.e. get_distance(loc1, loc2) and the wait_* ones...

hamishwillee commented 9 years ago

@jmacgithu yes, they look very useful. @mrpollo thoughts - best way to integrate?

hamishwillee commented 9 years ago

170 adds some documentation for the more useful of these, so they will be in the guide shortly. It would be convenient to have these as part of the API, but then we'd have to work out a library that was rock solid at latitudes near the poles and over longer distances. I don't think this is a priority right now.

I propose we close this issue once the documentation in 170 goes live.

hamishwillee commented 9 years ago

@mrpollo What do you think (see previous comment). Should we close this, or should we keep it open and plan integration of helper functions into the API?

mrpollo commented 9 years ago

we should implement

hamishwillee commented 9 years ago

@mrpollo I agree.

My only concern is that most of the algorithms floating around (like those I documented) are only good within certain latitudes, and over certain distances. With the "documentation solution" you can just add a warning and people can try alternatives if they find errors.

If you provide a function then you need to make it far more reliable over larger distances/latitudes or provide some sort of "accuracy" feedback. This is particularly true if we start to rely on it - for example I can see we might want to provide our own "frames of reference code" and that would have to depend on the library for conversions.

Another thought - is there a good 3rd party library we could either use or recommend instead of rolling out our own solution.