Throttle drop when switching to Loiter from RTL

Hi @rmackay9, this does fix one case but not the another one, unfortunately.

Let me re-summarize the issue. Two final RTL steps are affected: a) descending to RTL_ALT_FINAL, b) hovering at RTL_ALT_FINAL.
If you switch to Loiter during step A - you will observe a DCrt drop.
If you switch to Loiter during step B - you will also observe a DCrt drop.

I tested in SITL your latest fix and it does fix the B case only.

The A case is still here:

1 Like

Sergey,

Yup, OK. While implementing I thought this might happen. Let me have another look.

Hi @rmackay9

Now after some comprehension I believe the causes of case A and B are not much related.
Case B is a bug, and your fix above does fix it. So it is a must.

Case A is not a bug it is just how attitude control implemented. When switching from RTL to Loiter the DAlt are not changes, but the allowed descend rate is much more in Loiter. So pos_controller immediately applies that new descend rate.

I see two options of how this behavior could be changed:

  • to always set desired altitude with current altitude on Loiter init(). I.e. revert this fix. But this will cause a jumps (because of vehicle inertia). So it isn’t a correct option.
  • to limit the acceleration to smooth the transition. And this is what @peterbarker talked about I think.
1 Like

Thanks Sergey.

I think another solution may be to change the AC_PosControl::set_alt_target_with_slew() method so that it uses feed forward. We could do this by ramping up and down the climb rate as required to get the vehicle to the target altitude. I’ll need to talk with @Leonardthall about this.

I’ll push a PR with the fix for Case B shortly.

EDIT: here is the PR

Maybe this change could be a solution make Thr.Out smoother in case A?

BTW it is interesting what is the original purpose of that fix.

Sergey,

That might work but we should really fix the underlying problem instead of masking it. The underlying issue is the switch between using and not using feed-forward I think. It may also work to just set the desired to zero whenever set-alt-target-with-slew is called. I.e. remove setting it to WPNAV_SPEED_UP or WPNAV_SPEED_DN.