@Gimbal: Don't connect the sonar, it is not supported and of no use anyway, Autolanding is perfect with harakiris anyway without sonar. (For the rest: RTFM!)
So, i reworked the GPS INS part completely and it SHOULD work better now. There still have to be some factors figured out to make it actually usable but the code looks very ok to me now.
gps_ins_vel = 0.700 [0-1.0] This is the most important factor. The higher the value (max 1.0) the HIGHER the acc influence is and the lower is the GPS correction on acc measured speed.
gps_ins_pos = 0.350 [0-1.0] The LOWER this value is (min: 0) the higher is the influence of the acc for getting absolute GPS Position. Because the acc position is gathered by acc speed assumptions, it is dependent on gps_ins_vel. The HIGHER this value is, the more the GPS position corrects the acc position estimation
gps_acc_lpf = 2 [1-10] Is the acc lowpassfilter for the acc/gps integration. It is compareable to the lpf factor for accz/althold integration there it is 10. But 10 is too much filtering for position, so you can configure it here. A value of 1 disables the filtering 10 is too much in my opinion.
The ublox support is also reworked.
gps_type = 0 [GPS_NMEA = 0, GPS_UBLOX = 1, GPS_MTK16 = 2, GPS_MTK19 = 3, GPS_UBLOX_DUMB = 4]
gps_type = 0 GPS_NMEA
gps_type = 1 GPS_UBLOX (does autoconfig, sends the "block", you set baudrate)
gps_type = 2 GPS_MTK16 (old MTK binary protocol, 3drob. 1.6, baud is set automatically)
gps_type = 3 GPS_MTK19 (new MTK binary protocol, 3drob. 1.9, baud is set automatically)
gps_type = 4 GPS_UBLOX_DUMB (You have to set baudrate, You have to configure ublox with ublox center on your own. This mode just parses the ublox binary output)
So with type 4 you will have to/can configure ublox with the ublox center on your own. It will just parse the binary output (not nmea, thats mode 0).
The INS Code accepts GPS data at the rates: 4Hz, 5Hz and 10Hz.
Recommended setting for GPS (if manual setting is desired/required):
Stay away from 10Hz with current mtk/ublox GPS, they screw up! Stay away from NMEA - if possible.
Use 5HZ binary protocol at 57K Baud (57600).
If you use MTK3339 in crap NMEA mode, use a 5Hz FW. The advertised 10Hz stuff simply sucks, it is just marketing. 10Hz will loose GPS precision, plus you loose the last digit of precision with NMEA mode anyway. 10Hz maybe beneficial with the old mwii approach (and BF up to this version) because the gps stuff was just executed when new gps data arrived. That gave twice the execution time and may have things look smoother. With this harakiri8b the GPS stuff is done all the time, so it is smooth anyway. When new gps data arrive they are taken to correct acc assumptions wich feed the navigation continiously.
Warning: When doing a RTH/RTL this version will climb to 20m, if it was lower than that. It will not descent to 20m when RTH was engaged at 30m etc. This can be adjusted with the parameter: gps_rtl_minhight = 20 [0-200]
It will do an autolanding when RTH is done.
Have fun testing out, looking at the code etc...
Cheers
Kraut Rob
EDIT:
Hehe, i just did a test flight and found that my default parameters are not ok, so i set them both to 0.5 to have a starting point with default gps pids - and bingo! Very nice for the first test! gps_acc_lpf was turned off with a value of 1. So it works, it's a parameter job now

. I would suggest setting/keeping gps_ins_pos to 0.5 and start fiddeling with gps_ins_vel starting with 0.5.