Sending data to FC for EKF2 to work


I’m trying to build an autonomous drone. I have a raspberry pi attached to a pixhawk mini via a serial connection, and am running ROS to control the drone. I need to use a GPS sensor on the raspberry pi so that I can read it for my calculations within my code, so I’m trying to send the required data to the flight controller using mavros to save weight. I am currently sending the latitude, longitude, and altitude however when trying to arm i get “PreArm: EKF2 still initialising” continuously. I think I’m not sending enough data to the FC but I can’t seem to work out what else is needed for the EKF2 to work.

What does the EKF2 need to initialize??

This is the code I am currently trying to use:

#!/usr/bin/env python2.7

import serial   
import time
import pynmea2

import rospy
from sensor_msgs.msg import NavSatFix

def gpsToFC():

    rospy.init_node('gpsToFC', anonymous=True)
    pub = rospy.Publisher('global_position/global', NavSatFix, queue_size=10)

    msg = NavSatFix()

   	while True:
	    ser = serial.Serial(port, baudrate=9600, timeout=0.5)
	    dataout = pynmea2.NMEAStreamReader()
	    if data[0:6] == "$GPGGA":
		    msg.header.stamp =
		    msg.header.frame_id = "gps"
		    parsed_data = pynmea2.parse(data)
		    msg.latitude = parsed_data.latitude 
		    msg.longitude = parsed_data.longitude
		    msg.altitude = parsed_data.altitude

if __name__ == '__main__':
    except rospy.ROSInterruptException:


Are you using the mavros “fake_gps” plugin? or are you using the “GPS_input” plugin?

I’m using the GPS_input pluggin