I have a quick question on sending waypoints through the APM planner. I am working on a project using OpenCV to do live video analysis of FPV feeds in order to look for "targets" for a competition, i.e. post-processing the video on a computer and determining course of action from the results. From there, I have to modify the flight plan in-flight to acquire the next target, retreive data, such as the GPS data at the point where the plane identified the target, from the planner, and print the data out to a txt document. My question is; is there any way I can retrieve this data from the planner and send waypoints through the planner, such as an API? I would like to keep the APM planner in the loop, as it works really well, and I would rather not cut it out. I know I COULD make my own custom program/gui that gets the data I need over serial, but if I can avoid it, please, let me know. Does anyone know of a way to get the values out of the planner that I need, and a way to pass waypoints to the plane through the planner? I really only want to interface the video-processing program and the planner, basically just to send commands and get values. Let me know what you think I should do! Thanks!

Views: 4209

Reply to This

Replies to This Discussion

Please excuse me for not actually commenting in the code or adding notes, I literally posted that 10 minutes after waking up. The APM server test.py is the server that you run in the APM planner to broadcast whatever values you want to pull from the planner. Please note that I send a switching string in between every different value when I broadcast it. On the receiving end, which you can write in any programming language that supports UDP, the script listens to the stream coming from the server and decodes which values are which based on the switching strings coming in, stores the values, then displays them all at once. Please note that in the example I gave you, the main loop that decodes the values runs completely every 19ms. To add more values, just add another switching string to the server and send your value, and add another conditional on the receiver to listen for the string and then value. The default IP settings are local host, but you can play with that and broadcast it over a network for multiple computers to receive. Also, the values that come from the planner seem to lose 1-3 digits of precision, which isn't too big of a deal for values like airspeed, but it can put you off by 300-1000 feet with GPS coordinates. I think the problem is somewhere in the Iron Python API and how it gets values from the rest of the planner... Float precision, especially cross platform, is horrible to deal with. I hope this helps!

P.S. I currently do not have a breakpoint on the receiver, so unless you want to be trapped in an infinite loop forever, you might benefit from adding a break.

Hey, thanks for the answer. I will take a look at it and let you know if I figure something out. 



I am not 100% sure yet as I don't have a lot of time to test it right now but from initial tests with Xplane its seems to fix the problem. I just had to change lat = str("%.12f"%cs.lat).

Note: I also switched to TCP from UDP as it is more reliable and I was getting some packets mixed up on my computer with UDP. 

In case you are still looking to the get request for the waypoint from python I got it to work by using 

import httplib

conn = httplib.HTTPConnection("", 56781)
conn.request("GET", "/guided?lat=37.5220524601240&lng=-122.508888244620&alt=300")

Let me know how things go for you and I'll do the same.



thanks you all for the interesting work, i am at the beginning of a similar project and will post and share my experiences as soon i am testing out in the field.


Thank you so much .. It was an useful discussion. But , what happened after that? Eere you able to retreive  and to send the GPS  values through the planner software??

As it turns out, using Mavproxy is a much simpler option. I just created my own "module" (plugin) for Mavproxy, and use it to send any values that are sent through mavlink from my copter through to the network. Mavproxy also has a ton of output capability as well, so you can still keep mission planner as a front end and just put Mavproxy in the middle. Mavproxy also allows you to send commands. For example, as of right now, I have the ability coded in a custom Mavproxy "module" (plugin) to allow me to send my copters to a specific waypoint, specific location, or even move it over a few meters in a direction. I can also tell them to land and what action to take when they arrive at a location. If you need help or example code for MavProxy, let me know! It is fairly confusing, and took me quite a few hours to figure out, but it is definitely worth all the work. It's become a great tool. And it can be run on onboard Raspberry Pi's, which is a huge plus. Let me know if this helps!


I was very interested in you work,can you give me some Mavproxy example code?

Thank you!

Reply to Discussion



Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2020   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service