Use external positioning system for higher accuracy

I want to use an external positioning system to guide the drone. The system gives an accurate X,Y,Z and yaw information but I don’t really know the best way to comunicate this information to the drone.

What would be the best way to use an external positioning system with arducopter ? Is there a specefic MavLink message ? Or should I inject GPS information faking an RTK GPS ?
If any of you has already tried something I would be glad to hear your feedback.

Thank you all for your help,
Best regards,



We are trying to doing something similar, but haven’t put much effort in to the project yet. Soon.

I don’t think GPS inject will work. As far as I know the only thing you can inject is RTCM messages.

But you might be able to send a fake GPS NMEA message directly to the GPS serial port.


Hi Thomas,

You have the possibility of using MAVLink (fake) GPS ( / GPS_TYPE parameter set to 14). Also, in master there is support for Pozyx beacons and it was done in a way that support for other beacon systems can be added.


Sorry for my late answer.
Thank you for the help you provided.

So far i’ve tried to inject GPS with the GPS_INPUT and said that I had an RTK fix. Problem is, i’ve no idea what happens inside the pixhawk when it considers it has an RTK fix. Is there any specefic code ?

I’ll continue my investigation and keep you up to date if anything works.

Thanks again and have a good day

It doesn’t matter much. I mean, the location used is the one you provide. What exactly are you expecting from a code perspective?

I was more thinking about how much the code will “trust” my position information. I can easily understand that the EKF gives less importance to a 3d Fix GPS than to a RTK Fix GPS but is this really the case ? If so, are there any accessible parameters ?
I’ve started a more specefic thread concerning RTK and arducopter and some questions I have about this topic (How does Arducopter deal with RTK data)

Anyway, thank you for your help and I hope my question is a little more precise now.

Best regards,


The code reads the information coming from the GNSS receiver. A GGA NMEA message is a good example. Field 6 in a GGA message is GPS fix quality, which range from 0 - 5:

GPS Quality indicator:
0: Fix not valid
1: GPS fix
2: Differential GPS fix, OmniSTAR VBS
4: Real-Time Kinematic, fixed integers
5: Real-Time Kinematic, float integers, OmniSTAR XP/HP or Location RTK

For more information refer to the link.

Note: NMEA fix quality doesn’t correlate with what you’ll see in mission planner under GPSstatus. For example a 5 in mission planner is 3D RTK.

Hope this helps,


Hi all,

I am trying to use APMCopter with indoor motion capture system, OptiTrack, which provides accurate xyz and orientation information. So, basically, I am trying to do a similar thing. @Thomasss Were you able to solve your problem using GPS_INPUT mavlink message? If yes, what is the conversion formula to convert from xyz to lat/lon/alt and the other required fields in the GPS_INPUT message?



I managed to send the x,y,z info through the GPS_INPUT but the final result wasn’t what I expected and I haven’t put extra time in investigating why.
I only sent Longitude, Lattitude and Altitude (no velocity) but the drone entered in a really unstable behaviour with big oscillations. I suspect it had something to with the delay but I’m not sure.
If by chance you manage to have a good behaviour I will appreciate if you share.

For the conversion, if you are on small distances, you can directly convert from (deltaLong, deltaLat) to meters. This conversion depends on your actual lattitude (Lat).
1 degree in lattitude to meters : 111132,92 - 559,82 * COS(2Lat) + 1,175 * COS(4Lat) - 0,0023COS(6Lat)
1 degree in longitude to meters : 111412,84 * COS(Lat) - 93,5 * COS(3Lat) - 0,118COS(5*Lat)

I hope this aswers your questions.

Good luck and keep me updated on your results.



@OXINARF can you give more detail on the fake GPS (How it can be used)
and @mzahana can you tell me how did you proceed with Optitrack?
I need position but I have no GPS
Thank you both, Any feedback will be appreciated

Hi @rayane

Did you manage to set the drone position from external source?
I’m using a HTC VIVE for get the position of the drone, but I don’t know how to sent the data from the companion computer to the FC


hey @JustFineD
Actually i didn’t try since. Did it work for you with HTC VIVE!!! for sending the data, I think the ground control station should do the work.