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

Tradheli Autotune Improvements #26722

Merged
merged 25 commits into from
Jul 2, 2024

Conversation

bnsgeyer
Copy link
Contributor

@bnsgeyer bnsgeyer commented Apr 9, 2024

This PR was primarily focused on enabling the safe tuning of larger helicopters. I have made other changes along the way that help clean up the code and make it more efficient. Here is a list of changes

  • feedforward tuning was switched to a 5 deg attitude frequency dwell test for safety
  • all tuning of the rate PIDs is accomplished with a sweep in attitude rather than rate to provide more safety when going to low frequencies for larger vehicles.
  • Rate and acceleration limits are used and included as separate parameters
  • removed the sweep conducted before Rate D tuning and modified code so that data could be gathered during Max Gain sweep
  • Significantly cleaned up the dwell_run method
  • significantly cleaned up the test_init method
  • Significantly cleaned up the update gain methods
  • Align frequency search algorithms for the rate P, rate D, and max gained tests

@bnsgeyer bnsgeyer self-assigned this Apr 9, 2024
@bnsgeyer bnsgeyer requested a review from IamPete1 April 13, 2024 05:14
@bnsgeyer
Copy link
Contributor Author

@IamPete1 I made a pretty significant clean up of the heli autotune code. At least by my standards ;) I was wondering if you might take a look over the heli.cpp and provide any additional pointers on how to clean it up a little more. I'm sure there is a little more refactoring and ways that I could make it more readable. Already I have save 6K in flash on the cube orange+ :)

@peterbarker
Copy link
Contributor

@bnsgeyer you asked me to have a look at the autotests for this PR.

It doesn't look like you're changing the test suite itself, just the simulated vehicle and default tuning values?

I can have a look at the test failures, but if it's a vehicle dynamics sort of thing then you're far better off with help from @IamPete1 (or many other developers!) vs my rudimentary knowledge :-)

@bnsgeyer
Copy link
Contributor Author

bnsgeyer commented Apr 16, 2024

@peterbarker sorrry, this was not the PR I was referring to. I just submitted the autotest PR last night. It is this PR
#26810

I was having troubles with it but I think I figured out the error. Still would like you to look at it.
thanks!

@bnsgeyer bnsgeyer force-pushed the pr-autotune-improve-tests branch from b2d06ae to 0b3c2e1 Compare April 18, 2024 02:26
@bnsgeyer bnsgeyer force-pushed the pr-autotune-improve-tests branch 5 times, most recently from fe46f83 to cf14372 Compare April 24, 2024 02:21
@bnsgeyer bnsgeyer force-pushed the pr-autotune-improve-tests branch from d8f8d38 to ab0c00d Compare May 25, 2024 18:10
@bnsgeyer bnsgeyer force-pushed the pr-autotune-improve-tests branch 3 times, most recently from d37eb8f to 71183ec Compare June 16, 2024 03:43
@@ -572,6 +607,7 @@ void AC_AutoTune_Heli::load_gain_set(AxisType s_axis, float rate_p, float rate_i
attitude_control->get_rate_roll_pid().slew_limit(smax);
attitude_control->get_angle_roll_p().kP(angle_p);
attitude_control->set_accel_roll_max_cdss(max_accel);
attitude_control->set_ang_vel_roll_max_degs(max_rate);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think these are ever saved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are only set to allow user to limit rates during autotune, if desired. autotune does not determine max rates.

Copy link
Member

Choose a reason for hiding this comment

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

Do we need a load call to put it back to the user's value after the tune is done in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The load gain set method is used by the post test gain set method to load the original values. look above at the other methods that call the load gain set method. You have
load_tuned_gains
load_intra_test_gains
load_test_gains
load_orig_gains
in all cases except load_test_gains the orig rate max is used.

void AC_AutoTune_FreqResp::set_dwell_cycles(uint8_t cycles)
{
dwell_cycles = cycles;
delete meas_peak_info_buffer;
Copy link
Contributor

Choose a reason for hiding this comment

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

Randy or PeterB will come up with a suggestion on how we can avoid the delete by create a larger-than-required ring buffer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rmackay9 @peterbarker I removed the ring buffer delete statement and cleaned things up. I think my code works fine without them. I just clear the buffer before it is used the next time. I guess the buffer pops that first thing that was given to it if it is not full? Please have a look and let me konw.

@bnsgeyer bnsgeyer force-pushed the pr-autotune-improve-tests branch from 00f6997 to 15e183b Compare June 29, 2024 02:26
@bnsgeyer
Copy link
Contributor Author

@IamPete1 can I get you to approve this since you had done all of the review.

@rmackay9 I have removed the delete ring buffer lines and checked to ensure it wasn't exceeding the buffer. Once Pete approves and it passes CI, can I merge or do you want me to take it back to Devcall?

Copy link
Member

@IamPete1 IamPete1 left a comment

Choose a reason for hiding this comment

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

LGTM (review only, I have not tested)

@bnsgeyer
Copy link
Contributor Author

bnsgeyer commented Jul 1, 2024

This has been tested on actual helicopters by myself and @Ferruccio1984

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.

Looks OK to me

@bnsgeyer bnsgeyer merged commit 5fa2fcf into ArduPilot:master Jul 2, 2024
92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants