Lua script manually switch between GPS and GPS2?

Hi, i need to switch between primary GPS and second GPS2(simulated signal from onboard cpu in my case) manually via aux rc channel? How to do that? is it even possible?

Set GPS_AUTO_SWITCH=0 and then have your script toggle the GPS_PRIMARY parameter as desired.

I’m not sure under what conditions this parameter is re-polled, so it may not be a foolproof way to do what you ask. But it’s where I’d start.

Well i solved problem “my way”. It is not very elegant way but… I disconected GPS module tx wire and connected it to my 2 way turnigy camera switch for switching GPS tx wire on and off. Now i can switch GPS tx wire on and off via rc receiver. When i switch tx wire off ardupilot automaticly thinks that GPS is bad and swithes to GPS2 and vice versa.

Much better to feed in your “fake” GPS using the vision position estimate mavlink messages.