I failed to make any headway with sending the GPS_INPUT or HIL messages but this is what I have figured out so far:
GPS_INPUT is not loaded by default, you must add
module load GPSInput
to your ~/.mavinit.src to automatically run the module on default port 25100 UDP.
https://github.com/ArduPilot/MAVProxy/blob/master/MAVProxy/modules/mavproxy_GPSInput.py
The module code shows it is a JSON wrapper for mav.gps_input_send, the following code should send the correct packets to the UDP port:
#!/usr/bin/python import time import socket import json sockit = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sockit.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sockit.setblocking(0) while True: result = {} result['lat'] = 1.000000 result['lon'] = 1.234567 result['fix_type'] = 3 result['hdop'] = 1.0 result['vdop'] = 1.0 result['satellites_visible'] = 7 result['ignore_flags'] = 8 | 16 | 32 result = json.dumps(result) sockit.sendto(result.encode(), ('0.0.0.0', 25100)) time.sleep(0.2)
The second part is the message needs to be processed by the flight controler. Ardupilot will need some parameters adjusted to accept the message, I was not able to get this to work but based on forum post and github it seem two of the needed settings are:
GPS_TYPE: 14 (MAV), 7 (HIL)
GPS_INJECT_TO: 0, 1, 127