Toilet bowling when switch from optical flow to gps

I’d like to use a rangefinder & optical flow(MTF-01P) when within range of the optical flow for loiter mode & later switch to GPS being the source once the quad climbs beyond the range of the MTF 01P

I’m switching between the GPS and Optical flow using the EKF source switch as mentioned in the docs.

Each sensor works well, by itself. When I switch source from optical flow back to gps, the quad starts toilet bowling with it’s circle starting to increase..

Settings are:
EK3_SRC1_POSXY,3
EK3_SRC1_POSZ,1
EK3_SRC1_VELXY,3
EK3_SRC1_VELZ,3
EK3_SRC1_YAW,1
EK3_SRC2_POSXY,0
EK3_SRC2_POSZ,2
EK3_SRC2_VELXY,5
EK3_SRC2_VELZ,0
EK3_SRC2_YAW,1

Would you have any ideas as to why this might happen?

P.S. I’ve tried to recalibrate the compass, but that didn’t help. I will also be capturing logs soon.

One thing I’ve been seeing with my compass was, whenever the quad moves and then stops, the compass value keeps moving for a while, after which it stabilizes.
Also, the compass direction that the quad reads is way off, compared to the true direction (I’ve used my phone as a reference which I assume is relatively accurate)

So I’ve learnt something new. I have mounted my compass (the combi on the HGLRC m100 pro) 180 degrees around on the yaw axis (unfortunately I couldn’t find a doc stating the mounting direction at the time but some datasheet reading now makes me certain),
Also my custom mount has a pitch of 30 degree which I didn’t account for.

Reading the docs, it seemed like this should be accounted for by the calibration already, but the orientation set is incorrect (it auto set to yaw of 280), maybe the pitch throws it off.

I’m now trying:
CUST_ROT_ENABLE: 1
COMPASS_AUTO_ROT: 0
COMPASS_ORIENT: 101
CUST_ROT1_PIT: 30
CUST_ROT_1_YAW: 180

I will run compass calibration next and post my results.

Hi @Melroy_Cordeiro,

If the compass is leaning 30deg from flat (as compared to the autopilot) that will definitely cause problems unless the custom rotation is used. Using the custom rotation is very unusal though. I’ve never done it myself.

Thanks @rmackay9

Using the custom rotation + completing calibration, the compass seems to be fairly ok.
However, whenever in position hold using GPS, I’m still seeing toilet bowling :confused: (sorry, I’ll post logs soon)

Would you know any checks I could do to ensure the GPS & compass readings are correct w.r.t the FC?

Hi @Melroy_Cordeiro,

Good news. The easiest check is to use MP’s EKF view and move the vehicle around.

@rmackay9 Thanks a ton!!
I did a compass MOT, to rule out any interference, but the max interference at 60% throttle was 13, which seems to be very good.
The EKF view is very interesting, when I yaw the drone 180 degrees, the compass field goes red & into the bad regions.
I need to see why..

Hi @Melroy_Cordeiro,

Ok sounds mostly good. The compass going read means that the heading from the compass is not lining up with the rotations detected by the IMU. So the likely causes are:

  1. interference on the compass from motors, escs, etc
  2. calibration is still not quite right
  3. compass mot is actually making it worse

Thank you @rmackay9

I’ve tried out the following:

  1. Compass MOT
  2. Compass calibration with auto
  3. Compass calibration with manual settings of orientation
  4. I was previously sharing the compass voltage line with the optical flow + lidar, assuming that the lidar current draw might cause peaks, tried with using different voltage pads (coming from seperate BECs) and calibrated the compass.
  5. Monitored the elf & can see errors still.

With all the above, I still see toilet bowling :confused:

I think the HGLRC m100 pro might not be a very good module, I think the compass isn’t reliable (or at least the unit I have)

Once, it worked fine, I took off in alt hold, moved to loiter in GPS and switched between optical flow & GPS, no issues seen.

So clearly setup looks okay. I’m going to buy a new compass.

Thanks for all the support!

Hi @Melroy_Cordeiro,

ok, I hope the new compass module works. I have to say though that I’ve almost never seen the compass sensor itself be the problem. It’s nearly always the placement of the sensor that is the issue. If it’s very close to the frame (e.g. not up on a stalk) then it can be very unreliable. If its elevated then it normally works.

BTW, I guess we haven’t seen a log..

Hi @rmackay9

Sorry I had taken a log but hadn’t added it yesterday, with your reply, I am now working on moving the GPS away to a different location, printing a mast & trying that out & finally shielding the connecting wires to the GPS as well (all 3 separate checks)

The log file is at: https://drive.google.com/file/d/1GIkzts-T3hIUM7D9AF2gTugcOo91xNAi/view?usp=drive_link

I’ve switched between the optical flow & gps in this log when it starts toilet bowling.

Thank you.

@rmackay9 thanks a lot of supporting me & for all the advice given!

It was interference all this while!

Adding some info here, in case it helps anyone in the future:

I did a test with the GPS +compass module moved to another location & had no luck.

Then I 3d printed a temporary mast & mounted the GPS on it.

Note: calibration done after every new mounting location.

Things noticed after moving onto the mast:

  1. GPS lock was way quicker, AHRS home position locked soon too & the drone went to 13 GPS satellites within a few minutes! This looked positive
  2. GPS compass calibration on “default” went through the first time for every attempt!
  3. Ekf for the compass stayed green, everytime I moved the quad & shows no jitter once stationary. Previously, ekf would go red everytime & jitter seen after being stationary

With the GPS being on a mast, I now have very good performance on loiter & switching between optical to GPS has no trouble.

Here’s some pictures to give a visual understanding, in case it helps someone:

The GPS was in the red tpu printed holder which doesn’t seem like a good position for my build.

GPS then moved on top of the yellow mast (GPS taped on the top).

These are only temporary, I need to make the mounts better.

I will also shield the cables with copper tape for further shielding.

@rmackay9 thank you for being ever so helpful!!

Hi @Melroy_Cordeiro,

Great news! Glad that it’s fixed and thanks for the follow-up!