Poor behavior for quadroter in hold mode

Hi everyone, I’m new here in this community, I found many advices are helpful on this website, so I’m here to ask for some help, many thanks for stopping by.
Our ultimate goal is to achieve position/velocity control in the offboard mode. For instance, we want control our drone by sending a coordinate to it (0, 0, 2) and then it will hover at that point.
Before we go into the offboard mode, we decided to try the HOLD mode first as we thought the logic behind those two modes should be exactly the same( we assumed that hold mode would try its best to maintain its current status). However, while we were testing the HOLD mode, both x and y position seemed to diverge as shown in the log.
We used gps and optical flow for position estimation and we thought the positioning result was pretty good. Now we have several assumptions:

  1. x and y diverged because of bad controller, we used default PID parameters from PX4 as we couldn’t run autotune for unknown reason.
  2. Low positioning data frequency, we ran this test at night so we were not sure about the performance of Optical Flow.
    Thank you for reading this topic, and it will be a great help if you have any idea about what is going on with our drone.
    log is here https://logs.px4.io/plot_app?log=59d76b2b-7e5f-499f-acdd-560ebf9c08f8
    We used px4 firmware, gps and PX4flow.

Hi,
regarding autotune, this will work on master (1.13+) so I assume you are on an earlier version?
From the location plot it looks like you’re toilet-bowling, did you make sure your magnetometers are calibrated and working solid on the ground?

Thank you so much for replying! Yes, we used v1.12.3 master. However, I noticed that v1.13.0 was pre-released 11 days ago which means autotune in PX4 is a relatively new function? As for the magnetometers, we calibrated it quite a long time ago and we will calibrate it once again and come back with some updates. Thanks again!

Yes, autotune is (from what I understand, anybody feel free correcting me) a new feature meaning 1.13+.
At least I didn’t get it to work on 1.12 versions while on 1.13+ it does its thing and theres even some parameters to play around with… ,)
For compass, do you use an external sensor or does your flight control hardware have one onboard?
Because in the latter case the auto orientation for compass calibration will work.
For external sensors you’ll have to figure out the correct orientation settings yourself.
Actually if that setting is wrong (looking stable when turning on a level plane but spinning uncontrolled when rolled or pitched) it can very likely result in that “toilet bowl” behavior!
Cheers mate :call_me_hand:t2: