Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copter: fix unconstrained avoidance backup speed #26858

Merged
merged 2 commits into from
May 1, 2024

Conversation

IamPete1
Copy link
Member

This fix is the result of a log where home changed altitude resulting in a huge breach of the max altitude fence. There was no fence action configured, however avoidance was enabled resulting in the vehicle trying to back away from the max altitude fence at 15 m/s. The configured climb rate limits were +-2.5 m/s.

image

Firstly this fixes the avoidance to constrain the velocity to AVOID_BACKUP_SPD parameter.

Secondly this constrains Z backup to half the set pos controller speeds. This helps keep the speeds in balance since the the avoid backup speed is probably set with XY speed in mind and could be too large for Z.

I have not tested this yet. We might want a minimal fix to just apply the backup speed in avoid for a backport.

@rmackay9 rmackay9 mentioned this pull request Apr 22, 2024
92 tasks
@IamPete1 IamPete1 force-pushed the unconstrained_backup branch from 951f9e0 to dd54484 Compare April 22, 2024 13:05
@IamPete1 IamPete1 marked this pull request as ready for review April 22, 2024 13:06
@IamPete1
Copy link
Member Author

Rebased and added a auto test which fails on master and passes with this PR.

Copy link
Contributor

@rishabsingh3003 rishabsingh3003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! One minor comment. Thanks so much for fixing this.

// Ensure back up action keeps to the climbrate limits of the mode
// Apply 50% knock down to ensure backup is not too exciting
const float knock_down = 0.5;
return constrain_float(target_rate, pos_control->get_max_speed_down_cms() * knock_down, pos_control->get_max_speed_up_cms() * knock_down);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this additional constraint? Is this going to change how "backing up" feels to the users already using it?

I ask this since we are already constraining the back up in AC_Avoid (added in this PR)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thinking here is that there is only one back up speed in AC_Avoid. So a user might set that faster with horizontal speed in mind, say 5m/s. That would be fine in XY for most vehicles but could be too much for descending. Ultimately the vehicle should never move faster than the limits set for the given mode. If I could only have one constrain it would be this one. I can see a argument for not using the 50% knock down tho....

@IamPete1
Copy link
Member Author

I have reworked to take a pos control pointer from copter which allows the constrain to pos control limits to be done inside AC_Avoid resulting in a much smaller change.

AC_Avoid is also used by rover which will not set the pointer so will not try and use pos control.

A alternative method might be to add a pos control singleton.

@IamPete1 IamPete1 force-pushed the unconstrained_backup branch 2 times, most recently from 052c57d to ac2508e Compare April 23, 2024 17:02
@rmackay9
Copy link
Contributor

I'm slightly surprised that the vertical speed limits weren't being applied in AC_PosControl but perhaps that's because we are not using "input shaping"

@IamPete1
Copy link
Member Author

I'm slightly surprised that the vertical speed limits weren't being applied in AC_PosControl but perhaps that's because we are not using "input shaping"

The pos controller does not apply any limits, its on the caller to restrict what they ask for. I do think it should (#24100) this is a case where having hard pos control limits would have been a good idea.

@rmackay9
Copy link
Contributor

We discussed this on the call and agreed to use a new AVOID_BACKZ_SPD parameter.

@IamPete1 IamPete1 force-pushed the unconstrained_backup branch from ac2508e to e275638 Compare April 30, 2024 19:38
@IamPete1
Copy link
Member Author

Reworked to separate the speed limit into horizontal and vertical components. I also found I had omitted to apply the Z limit in the 3D case which I have now fixed.

Copy link
Contributor

@rmackay9 rmackay9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@rmackay9
Copy link
Contributor

rmackay9 commented May 1, 2024

@peterbarker, I think we can merge this unless you're comment above re the autotest is a blocker... so up to you.

@tridge tridge merged commit 97449b0 into ArduPilot:master May 1, 2024
91 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 4.5.3-beta1
Status: 4.4.4-beta1
Development

Successfully merging this pull request may close these issues.

6 participants