Simulated GPS over ArduPilot SITL TCP

Hi there - I’m trying to run ArduCopter SITL, with sim_vehicle.py, and with a custom GPS signal.

When I run this ‘normally’ (./sim_vehicle.py -v ArduCopter -L Ballarat -f gazebo-iris --model JSON --map --console --no-mavproxy --udp -C --mav20 -aircraft=iris) all works, and I can connect the simulated UAV to QGroundControl successfully over UDP, fly, etc.

However, what I really want to be able to do is to send GPS NMEA data over TCP (e.g. with software like gpsfeed+), for the UAV to then receive this, to process it, and to use this instead.

Currently, I only have partial success: I run the command
./sim_vehicle.py -v ArduCopter -f gazebo-iris -A "--serial3=tcpclient:172.20.80.1:2222" --model JSON --map --console --no-mavproxy --udp -C --mav20 -aircraft=iris
to make the UAV listen for serial GPS data on that TCP connection. Then, I try to connect the UAV to QGroundControl, and it then does not do so until I start up a gpsfeed+ session which sends NMEA data over that TCP connection (I’ve verified this works just with wget). When the NMEA data starts sending, the UAV suddenly connects to QGroundControl successfully, but it does not register any GPS input, it doesn’t show the UAV on the map at all, and as soon as the NMEA data stops being sent over TCP, the UAV immediately disconnects from QGroundControl again.

I’ve added the below to APM_Config.h as well, to try and get the UAV to read NMEA data properly, but also no luck.

#define GPS_PROTOCOL GPS_PROTOCOL_NMEA
#define GPS_TYPE 5
#define SERIAL3_PROTOCOL 5
#define AP_SIM_ENABLED 1
#define AP_GPS_ENABLED 1

I have two questions really:

  1. How can I get the UAV to read the NMEA data properly from the TCP connection
  2. Why is the connection of the UAV to QGC dependent on NMEA data being sent on the TCP port?