Quadcopter intermittent bad attitude control

Hello guys.
I have a problem with a 650mm quadcopter, 6s power setup with 15 in props, with a cube orange, running PX4 v1.12.3.
Sometimes the vehicle will twitch violently, specially in the pitch axis, while flying in stabilize or position modes and sometimes it will just fly normally. This is what I know so far:

  1. The problem shows up if I take-off immediately after the vehicle plays the position lock tones.
  2. If I wait longer (around a minute) the problem doesn’t show up.
  3. If the vehicle was behaving correctly but I reboot it by disconnecting and reconnecting the battery, we still need to wait before taking off or the problem will show up again.
  4. If the vehicle was behaving correctly and I reboot it by sending a reboot command (I did this with mission planner), I can take off immediately with no problems.
  5. If the vehicle is not behaving correctly, at least sometimes rebooting the vehicle by sending a reboot command will fix the issue (I don’t think I tested this enough to have anything conclusive).
  6. The pitch and roll actual rates vary a lot from the setpoints in unsuccessful flights, and are pretty much ok in successful flights.

Here are two logs from the same day:
Unsuccessful flight:
https://logs.px4.io/plot_app?log=179bbbaf-4d5c-4443-b9cb-a43a0184d0ac
Successful flight:
https://logs.px4.io/plot_app?log=9d74471f-2611-49e4-8562-a0764ce27bee

I made two vehicles at the same time with the same PID tunning and configuration, the other one worked perfectly. I recalibrated ESCs, IMU and compass, it didn’t help.

Any ideas?

Hi I am in a similar situation. did you solve it?