Drone yawing to the north pole direction when takeoff

IM USING A HEXACOPTER DRONE FOR AGRI SPRAYING PURPOSE, WITH PIXHAWK CUBE ORANGE AND ONE HERE 3GPS , EVERY TIME WHEN I TAKEOFF THE DRONE IS YAWING TO THE NORTH POE DIRECTION OF EARTH AND WHENEVER I TAKE OFF I GET A MESSAGE EKF3 IMU2 MAGO GROUND ANOMALY, YAW REALINGED,EKF3 IMU1 MAGO GROUND ANOMALY, YAW REALINGED, EKF_YAW_RESET, I HAVE ATTACHED THE LOG FILE , PLEASE DO HELP ME IN FINDING OUT THE SOLUTION FOR THIS PROBLEM

@pratheep_hild_defenc that is normal when taking off from a location with bad magnetic environment. During takeoff the yaw can drift. But as soon as the aircraft is in air the Yaw will be reset and missions should behave. If you need more robust heading solution consider using Moving Baseline Yaw, which is supported by HerePro. Newer Here4s will also have support for that.

Thank you sir

But as i was new to this drone field ,i didn’t understand what is robust heading solution and moving baseline yaw , can you please explain me on this ?

Please refer to the details here HerePro Manual - CubePilot

HerePro is one of the products that support moving baseline. Here4 is another product from CubePilot that’s getting support for moving baseline as well.

Yaw reset is normal after takeoff.
Yaw realigned means there has been some GPS position change and EKF can now tell which way the copter is going compared to what the compass initially reports - and that has been fixed.
Yaw ground mag anomaly means there is interference from your electrics, like heavy currents in battery wires.

So there is two things to fix in relation to the compass - the compass calibrations, and account for the interference - or ignore that compass, likely the built in one.

I can see using magfit the calibration is a bit out and can be improved, but this flight doesnt have enough yaw data. Disable the built in compass, and do a test flight with circles and plenty of yaw (after all the parameter changes below)
COMPASS_USE,0

Other issues are:

  • Many default values in parameters
  • Needs tuning
  • frame or motor-mount twist - I can see there is a consistent difference between clockwise and counter-clockwise motors, meaning one or more of the motor mounts are not perfectly aligned - try to fix this physical issue first

Let me know exactly what props. motors, ESCs and battery you have.
Do you actually use the BATT2 input?

Until then I can make some safe assumptions based in your log and you said it’s an agri sprayer, so you can definitely set these before you do the next test flight:

ATC_ANG_YAW_P,2.4
ATC_ACCEL_P_MAX,40000
ATC_ACCEL_R_MAX,40000
ATC_ACCEL_Y_MAX,16000
ATC_INPUT_TC,0.2
ATC_RAT_PIT_FLTD,10
ATC_RAT_PIT_FLTT,10
ATC_RAT_RLL_FLTD,10
ATC_RAT_RLL_FLTT,10
ATC_RAT_YAW_FLTE,2
ATC_RAT_YAW_FLTT,10
BATT_FS_CRT_ACT,1
GPS_GNSS_MODE,65
INS_ACCEL_FILTER,10
INS_HNTCH_ENABLE,1 // write then refresh params to see the rest
INS_HNTCH_MODE,1
INS_HNTCH_REF,0.23
INS_HNTCH_FREQ,40
INS_HNTCH_BW,20
INS_HNTCH_FM_RAT,0.7
INS_LOG_BAT_MASK,1
INS_LOG_BAT_OPT,4
LOG_BITMASK,180222
MOT_BAT_VOLT_MAX,49
MOT_BAT_VOLT_MIN,34
MOT_THST_EXPO,0.74
PILOT_THR_BHV,7
PSC_ACCZ_I,0.50
PSC_ACCZ_P,0.20

Some of these may change as I find out more, or after the next test flight, but they are a safe starting point. Remeber to do plenty of yaw, circles and some ascent and descent - let’s see that log.

1 Like

thanks for your reply sir.
IN BATT2 i have connected flow sensor for spraying purpose.
propeller size-23inch
motor and esc- hobby wing x6 motor with inbuilt esc

the total weight of the drone is 25 kg with pixhawk cube orange flight controller and here 3 gps

Set these

MOT_PWM_MIN,1050
MOT_PWM_MAX,1950

and then recheck your MOT_SPIN_ARM and MOT_SPIN_MIN using MissionPlanner motor test.
Read through my previous notes:

  • Fix motor mount twist
  • Apply all those settings including COMPASS_USE,0

Dont skip anything thinking just one item will fix your copter.
Do another test flight and let’s see that log

Hi sir done the test changing the parameter as you said , but still the drone is yawing and when moved forward the altitude of the drone drops suddenly WHENEVER I TAKE OFF I GET A MESSAGE EKF3 IMU2 MAGO GROUND ANOMALY, YAW REALINGED,EKF3 IMU1 MAGO GROUND ANOMALY, YAW REALINGED, only when i recieve this ground mag anomaly my drone is yawing ,i have attached the link of the files here .
https://drive.google.com/drive/folders/1uJl5jQ6kzCJ0AASmNnvPdCZYbfV7uoHI?usp=drive_link

@pratheep_hild_defenc please change the order of your Magnetometers. You seem to be using internal mag which AK09916 instead of good quality external Mag over DroneCAN. Please follow the steps here:
https://ardupilot.org/copter/docs/common-compass-setup-advanced.html#compass-ordering-and-priority
Ensure the DroneCAN Compass has highest priority

I must have missed your reply, I looked in the latest log there and couldnt see any of the compass-related errors.
I’ll check more for the altitude and yaw problems.