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: use attitude control base class #25224

Merged
merged 2 commits into from
Dec 4, 2023

Conversation

IamPete1
Copy link
Member

The base AC_AttitudeControl class implements all the methods from AC_AttitudeControl_Heli and AC_AttitudeControl_Multi so there is no need for the extra level of indirection.

This also changes over AC_CustomControl from AC_AttitudeControl_Multi to AC_AttitudeControl.

If we were to add any new methods to multi or heli attitude control this now requires that a virtual or pure virtual function be added in the base class and then overridden, but we have been following that pattern anyway.

@IamPete1
Copy link
Member Author

IamPete1 commented Oct 10, 2023

Unfortunately, we still need to use the class specific object for the parameters.

I was able to get params working by moving to a var pointer param table with GOBJECTVARPTR. This is the same way we do AP_Motors

@IamPete1 IamPete1 force-pushed the copter_attitude_control_class branch from 580a60b to 6440cab Compare December 1, 2023 14:42
@IamPete1 IamPete1 force-pushed the copter_attitude_control_class branch from 6440cab to b099c30 Compare December 3, 2023 23:56
@@ -1,4 +1,5 @@
#include "AC_CustomControl_PID.h"
#include "AC_AttitudeControl/AC_AttitudeControl_Multi.h"
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed because the same default defines are used for PID gains.

@IamPete1 IamPete1 requested a review from rmackay9 December 4, 2023 00:01
@IamPete1
Copy link
Member Author

IamPete1 commented Dec 4, 2023

This is saving a suspicious amount of flash on Durandal:

Binary Name      Text [B]         Data [B]     BSS (B)        Total Flash Change [B] (%)      Flash Free After PR (B)
---------------  ---------------  -----------  -------------  ----------------------------  -------------------------
arducopter-heli  -760 (-0.0433%)  0 (0.0000%)  0 (0.0000%)    -760 (-0.0432%)                                  209552
arduplane        0 (0.0000%)      0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                      223436
arducopter       -564 (-0.0323%)  0 (0.0000%)  -4 (-0.0015%)  -564 (-0.0322%)                                  216048
antennatracker   0 (0.0000%)      0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                      665352
ardurover        0 (0.0000%)      0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                      360032
blimp            0 (0.0000%)      0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                      712112
ardusub          0 (0.0000%)      0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                      422468

Much closer to what I would have expected on other the other builds, this is Pixhawk1-1M:

Binary Name      Text [B]       Data [B]     BSS (B)        Total Flash Change [B] (%)      Flash Free After PR (B)
---------------  -------------  -----------  -------------  ----------------------------  -------------------------
arducopter-heli  12 (+0.0012%)  0 (0.0000%)  -4 (-0.0020%)  12 (+0.0012%)                                     38292
arduplane        0 (0.0000%)    0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                       1[25](https://github.com/ArduPilot/ardupilot/actions/runs/7080162785/job/19267654301?pr=25224#step:10:26)88
arducopter       0 (0.0000%)    0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                       48964
antennatracker   0 (0.0000%)    0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                      [29](https://github.com/ArduPilot/ardupilot/actions/runs/7080162785/job/19267654301?pr=25224#step:10:30)6720
ardurover        0 (0.0000%)    0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                      112148
blimp            0 (0.0000%)    0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                      [31](https://github.com/ArduPilot/ardupilot/actions/runs/7080162785/job/19267654301?pr=25224#step:10:32)8220
ardusub          0 (0.0000%)    0 (0.0000%)  0 (0.0000%)    0 (0.0000%)                                      125760

I will run elf diff and see where the saving is coming from.

@IamPete1
Copy link
Member Author

IamPete1 commented Dec 4, 2023

Elf diff here: https://drive.google.com/file/d/1ttP5etMZU84Gjc-8dE6Um4KbaFqQPz8i/view?usp=sharing

All of the changes are in persisting symbols. So no functions are added or lost.

image

I don't think we have lost any functionality. Its only a saving on 2M boards, so its probably related to the optimization level. I usually put such things down to "alignment".

@IamPete1
Copy link
Member Author

IamPete1 commented Dec 4, 2023

Heli elf-diff, look like the same thing:

image

https://drive.google.com/file/d/1u0rjDFlPjxEqXVyrg1rTontytBn8WwmB/view?usp=sharing

@rmackay9 rmackay9 merged commit 60816f4 into ArduPilot:master Dec 4, 2023
87 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.

3 participants