Need help in log analysis (EKF and GPS position diverged when setting yaw just after takeoff)

Firmware - ArduCopter-4.0.4 (slightly modified but responsibly to my extent)
Hardware - Omnibusf4pro
GPS - Here+ RTK (flying with RTK setup in RTK FLOAT only)
Build - 5" props quadcopter

Made a recent modification in firmware directly where i am trying to fix the direction of telemetry antenna mounted on quadcopter in the direction of base station to maintain a good connectivity so RTCM messages don’t get interrupted during the whole flight. This modification is well tested on SITL also.

This process is always in check just after the quadcopter takes off in guided mode. I flew more than 40 quadcopters with this setup, all worked perfectly but except one, that one tried to fly away, and somehow we able to trigger land in right time, after getting the log of that flight, the outcome seems confusing, there were multiple issues in that log, which i am listing down below:

  • High velocity variance after setting the yaw just after takeoff
  • Change of magfield or Mag variance was not that high but MAG.x,y,z showed quite some changes after the yaw command, mag offsets was also slightly high
  • EKF and GPS position diverged after sometime and at same time quadcopter was trying to fly away


I think the issue arises was due to bad compass calibration or bad mag offsets, but i am not sure why velocity variances also increases at same time and EKF and GPS positions got diverged, some advices by experts on this issue will be helpful.