Pitch peaks in AUTO turns

Hello

I have problems with assuring a smooth ride of a converted DJI Mavic Air 2 drone. It is reasonably stable in Loiter, and when flying AUTO, it looks great from the ground but logs show some oscillations (which sometimes are that big that make visible jerks in the video footage).

I have two questions:

-there are both pitch and roll oscillations, which seem to be commanded (so not bad tuning?). How to fix this, or diagnose that it’s a problem with say airframe stiffness?

-why there are so big pitch increases in turns? This happens in every turn.

First of the two pitch excursions in the right side of the graph happens here (entering the turn):

Is this expected? Should the copter slow down for some reason? (too big lateral acceleration?)

The log

Hi @maciek252,

The roll and pitch tuning looks pretty good. There are some small overshoots so perhaps reducing the ATC_RAT_RLL_P/I/D and ATC_RAT_PIT_P/I/D by 5% might help a bit.

.. but I think in general you just want the vehicle to be smoother when flying? I think you could reduce some of the WP_ or PSC_ parameter values to do this. So for example these two will reduce the acceleration (and change in acceleration) of the planned path.

  • WP_ACC : try reducing from 2.5 m/s/s to 1.5
  • WP_JERK: try reducing from 1 to 0.5

To reduce the reaction to position disturbances you could reduce:

  • PSC_NE_POS_P: try reducing from 1 to 0.5
  • PSC_NE_VEL_D : try reducing from 0.25 to 0.15

These are just ideas, I normally leave my vehicle with the defaults.

Thank you so much for your kind response, and in particular that you’ve given the exact values to try. I guess this part of tuning is covered to a much smaller degree than the Attitude/Rate PIDs. And also not adjusted by any autotune, in principle this should be possible, should it?

I’ve flown the same pattern. It was quite windy, but the pitch excursions are still there. It seems that before every turn the copter pitches positively, as if it wanted to slow down?

For example, there is a pattern of a “trident” in the pitch graph corresponding to the three turns one close to another. First of these turns is quite gentle, so no reason to slow down?

The log

(fw upgraded to 4.7.1)

Is this circuit too tight for flying with constant speed? How to recognize this?

There are significant pitch oscillations also in a straight fragment of the track:

Hi @maciek252,

Txs for the log, to make it even smoother, the only idea I have is to further reduce the WP_ACC and WP_JERK parameters. So you could try extremely low acceleration limits and you’ll find it is painfully slow to get up to speed but its pitch changes will be much smaller.

  • WP_ACC = 0.5 (default is 2.5)

I suspect what you’re seeing is just how ArduPilot very precisely controls its position, speed and acceleration and it’s not what you’re expecting. It’s probably different than a DJI or some other system. I don’t personally fly DJI of course but maybe tell us more what you’re expect?

For example, to go around a corner, the vehicle certainly needs to slowdown in the direction that it was moving before the corner.

For this issue, I don’t think autotune could be an answer because we’re not talking about attitude changes to resolve position and velocity errors. We’re talking instead about the output of the S-curve path planner.

FYI @Leonardthall

I think you have a 3S Lipo, so you need to set these:

BATT_ARM_VOLT,11.00
BATT_CRT_VOLT,10.50
BATT_LOW_VOLT,10.80
BATT_FS_CRT_ACT,1
BATT_FS_LOW_ACT,2
MOT_BAT_VOLT_MAX,12.60
MOT_BAT_VOLT_MIN,9.90

They are really mandatory, not optional. Don’t skip any.
If you have a different battery type then please provide that detail.

Since everything is not configured consistently, I guess you have about 14inch props, so set:
INS_GYRO_FILTER,30
and this will be near enough. There are other related parameters that should have been set - you should have used AMC, or at least Initial Parameters in MissionPlanner, to start setting up this copter.
(NOTE TO SELF: fix Initial Parameters to suit version 4.7+)

Unless you have T-Motor Alpha or Flames ESCs then you probably dont need any *_SMAX parameters set to non-zero. Put them all back to 0 unless you know your ESCs have a hard time responding, or if your copter is very large (which I doubt).

Set ATC_THR_MIX_MAN,0.5 since vibrations dont appear to be an issue.
Set ATC_INPUT_TC,0.15 to fix RC input response and suit v4.7.
Turn off the FFT, it’s not needed: FFT_ENABLE,0 and set up the harmonic notch filter so it works, and with some safer values (since there’s no data to check it):

INS_HNTCH_BW,10
INS_HNTCH_FM_RAT,1
INS_HNTCH_FREQ,60
INS_HNTCH_OPTS,2
INS_HNTCH_REF,1     <- this was 0

It may be that the harmonic notch filter is not even required, a log with data could be helpful.

Now set these to adjust the yaw response:

ATC_RATE_WPY_MAX,30    <- probably Ok for missions
PILOT_Y_RATE,60        <- can be higher if required

Before you head out flying again expecting those things to make a big difference, the next step is to set AUTOTUNE_AGGR,0.1 and run autotune on pitch and roll.
You may want to reduce the new ATC_ACC_P_MAX and ATC_ACC_R_MAX values by 10% after that autotune.
Do yaw autotune if you feel it’s required after you’ve tested pitch and roll.
Let’s see a log of a test flight after autotune.

EDIT:
My reasoning is there is poor configuration and tuning, before we start changing advanced parameters (which may not be the real problem) let’s get the copter flying as it should, then tackle whatever issues are left over.

Thanks! I’ll try to implement and test these, when the wind calms down.

The copter is no longer DJIish, its soul is already ArduCopter :slight_smile: I just want it to fly inside the gimbal’s envelope, these oscillations are sometimes too big for what this gimbal can take (mostly around turns, usually fine when flying straight or ligthly curved fragments). But this is not necessarily specific to DJI, all the other gimbals behave simillarily.

What is strange to me is that these oscillation seem to be commanded, so not related to vibrations, flexible airframe etc. Or is this conclusion not justified and some problems can result in this desired control?

BTW I think the conversion DJI->ArduCopter is maybe the most cost-effective solution nowadays to get a decent gimbal+video running Ardu. Used DJIs are quite cheap (even better when crashed and not flyable but still recording), you need just an MicoAir AIO H743 v2, a gps and an ELRS RX and thats all. And you get really good quality camera/gimbal and a well-proven airframe.

Yes, and once the tuning is a little better we can adjust a few more things to give the gimbal a smooth ride.

If you’ve been able to convert a DJI you might want to do a blog post on that with some photos.

Added a thread here:

Hi @maciek252

The oscillations you are seeing are coming from your velocity PID loop. You should get a more relaxed navigation with these parameters:

PSC_NE_POS_P = 0.5

PSC_NE_VEL_D = 0.125

PSC_NE_VEL_I = 0.5

PSC_NE_VEL_P = 1

Little OT, What are the setting to have the new Loiter act less relaxed? My tests in Realflight seem to be overshooting. I have tested a old quad and a new one, each show this issue.

https://www.youtube.com/watch?v=Eg6kO-ofBKk Edit: I am moving this question to simulation.

I’ve implemented your advices and did a test flight. The results are not very conclusive, as it was very windy (7-8 m/s with gusts twice as that and lots of tubulence). The drone has survived it and flown the circuit without any problems. I think that the situation with the oscillations has improved, but for sure some addiional ones come from the wind (for example, more small camera oscillations when flying upwind). The horizon is tilted, not sure why, probably should have recentered it from the DJI menu.

The log

The video:

Thanks, I’ll give it a try.

So I’ve tested the suggested settings. But I’m not sure about the conclusion. I have a feeling that some micro-jerks appear now (not the big ones in turns), which were not present when I started tuning. I’ve need to experiment also with the DJI’s gimbal setting, they have some settings such as Speed, Smoothness and Rotation Speed for pitch and yaw, I wonder what is the relation of these with the ArduCopter’s auto turn curves and yaw speed/acceleration).

I present two movies and corresponding parameters: from today, with the changes:

the parameters

and when it started flying decently but before optimizing PSC (I used the automatic video settings here, and now I know this was not good as it used 1/60 shutter and this causes motion blur, better to use manual settings and select 1/100, 1/120 and adjust ISO depending on the conditions)


and the parameters for this case

This copter is of course very well designed, but requires careful tuning as the prop horizontal base is short, and the propellers are not on the same level (don’t know how it influences the stability). Maybe you have some ideas/recommendations how to tune it systematically?

The good news is that this build is definitely solid, it has flown many hours in very different conditions without any major incidents (since I’ve realised that 2.4 GHz ELRS interferes with the video link).

Hello,
I’ve analysed the logs once more and the problem is that the airspeed changes because of the turns, and accelerating/deaccelerating causes the pitch excursions.

Look at the graph (the final track uploaded above):

GPS speed (how to get the estimated airspeed?) is plotted on the top (the yellow line), and pitch in the bottom. It can be seen that when starting to accelerate, the copter pitches much too aggresively.

Should I further reduce WP_ACC and/or WP_JERK? How are these two parameters related? Is WP_JERK defining how quickly the horizontal acceleration changes? (a kind of a third distance derivative?) It can be seen in the graph that the acceleration is constant for most of the time (airspeed growth is linear), so what is causing this very big pitch change? Is this an attempt to reach the constant acceleration, so should WP_JERK be further reduced? Do you have some practical recommendations?

The same for the much smaller airspeed changes in the left part of the shown graph fragment: the airspeed changes are just small humps, but the pitch excursions are significant, so does this mean that the copter wants to reach the constant acceleration much too quickly?

Hi @maciek252,

I don’t have answers for all the questions but here are a few:

  1. Here is the wiki page to setup the wind speed estimation
  2. Yes, WP_JERK set the maximum rate of change in horizontal acceleration (e.g. lean angle) during missions so the lean angle will change more slowly
  3. WP_ACC sets the maximum acceleration (e.g. lean angle) during missions

Hi @rmackay9,

Thanks for your answer. I’ve tested the reduced WP_JERK and WP_ACC parameters and there is some improvement.

However, I’ve come to a conclusion that the gimbal micro vibrations are caused by the general copter vibrations. This happens also when flying in LOITER and there is no noticeable yaw/roll/pitch change. Things seem to be worse after I’ve applied the notch filter corrections recommended in this thread. I’m starting to examine this issue, but have very limited experience on that topic. I know there is plenty of documentation about vibrations, notch filters etc but maybe someone has some practicioner’s comments and suggestions about this?

Hello,

some progress:

  • after enabling RPM1*ESC mask and enabling the third harmonic the filter works much better and micro-vibrations are gone

-the gimbal does not like sharp turns, the problem is that the centrifugal force tilts the horizon a bit. After 10-15 seconds it settles horizontally again. You can see this in the movie around 0:22. I’ve set the WP_ACC_CNR to 1.2 and it makes the copter to slow down w.r.t. the horizontal speed to a crawl, and then it turns around its yaw axis quite fast. I need to limit ATC_RATE_Y_MAX, but is there any way to limit the yaw rate only for WP_ (auto) missions?

What happens if the ATC_RATE_Y_MAX is too slow for the copter to turn to follow the yaw required by the path? Will it slow down, or look sideways for some time?

-the only problem still present and preventing the DJI quality is that the copter accelerates and slow downs with a jerk. As shown in the graph, even for a relatively small change (8->6 m/s) the pitch changes around ~ 10 deg, it is not much but unfortunately visible in the footage. I’ve reduced both WP_ACC and WP_JERK, but I have a feeling that these values do not work as they should. The WP_ACC range is 0.5 to 5, does it work when set to say 0.4? WP_JERK range is 1 to 20, does it need to be an integer? Can I set it to say 0.3?

In the graph I show the speed (taken from the GPS) and the commanded and actual pitch:

Can you advice how to make these pitch variations smaller, even if taking longer time? Int his

footage, the problem occurs around 0:44. As it can be seen after 1:33 and the final turn, the speed has been reduced with a DO_CHANGE_SPEED and there are no gimbal jerks, however it would be better to limit the acceleration and not the speed.

The log

RPM sensor library isn’t used used for filtering so it shouldn’t matter.

Ardupilot uses max lean angle and speed parameters for feedforward so if you have decreased max speed feed forward may be too strong. There is a parameter for yaw rate in automatic modes. IIRC the copter will keep moving while pointing sideways, we don’t have coordinated turns for auto.

Hi @maciek252,

Just a couple of points:

  1. If ATC_RATE_Y_MAX is set too low, the vehicle’s yaw will take a long time to come around to point at the next waypoint and it will end up looking sideways for a while. During missions, AP doesn’t limit the horizontal progress in order to allow the yaw to catch up.
  2. I suspect the gimbal’s attitude being incorrect is because the gimbal is not receiving any information from the flight controller about the vehicle’s acceleration. This will throw off the gimbal’s attitude estimator and lead to the leans you’re seeing. I can also imagine that the gimbal doesn’t have a 2nd IMU in its base because it wouldn’t normally need this because it would get all the info it needs from the flight controller.