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

Control Allocation Sequential Desaturation unit tests #22612

Conversation

somebody-once-told-me
Copy link
Contributor

Solved Problem

Unit tests for ControlAllocationSequentialDesaturation. No code changes are made to any existing library, this only adds unit tests. The unit tests serve 2 purposes: 1) help ensure that expected functionality remains the same and 2) documents and demonstrates (through examples) the desaturation algorithm.

@somebody-once-told-me
Copy link
Contributor Author

hmm, looks like the tailsitter SITL test is failing? curious as this only adds a unit test.

@somebody-once-told-me
Copy link
Contributor Author

merged; now all SITL tests are passing.

@sfuhrer
Copy link
Contributor

sfuhrer commented Jan 15, 2024

Thanks for your contribution, I'm going through it later.

hmm, looks like the tailsitter SITL test is failing? curious as this only adds a unit test.

It's now passing. These SITL tests are a bit flaky.

Can you rebase your branch on latest main? Something seems to have been messed up with your history, and this PR shows up many commits that don't come from you.

@somebody-once-told-me
Copy link
Contributor Author

@sfuhrer I can try, but I am not sure why those other commits are showing up. Although, the changes are accurately captured, as can be seen in the Files changed tab. If this PR is merged as-is, won't it all be squashed in a single commit anyway (and the weird commit history shown above won't matter)?

@somebody-once-told-me somebody-once-told-me force-pushed the control-allocation-sequential-desaturation-unit-test branch 2 times, most recently from c4c1d88 to 3c5d8ae Compare January 15, 2024 13:35
@somebody-once-told-me
Copy link
Contributor Author

@sfuhrer the commit history has been cleaned up.

@somebody-once-told-me somebody-once-told-me force-pushed the control-allocation-sequential-desaturation-unit-test branch 4 times, most recently from 670e226 to 025881f Compare January 17, 2024 08:53
Copy link
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

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

Thanks for kicking this off, that's very valuable.
I only have some minor things. I leave it up to you to also add some test cases for the "normalized" allocation - could though also be a follow up PR.


const auto &actuator_sp = allocator.getActuatorSetpoint();
// In the case of yaw saturation, thrust per motor will be reduced by the hard-coded
// magic-number yaw margin of 0.15f.
Copy link
Contributor

Choose a reason for hiding this comment

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

@MaEtUgR maybe it's a good time to document this magic number in the algorithm as well!

Copy link
Member

Choose a reason for hiding this comment

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

I can only imagine why this is useful. I think @bresch had the full context here.

@somebody-once-told-me somebody-once-told-me force-pushed the control-allocation-sequential-desaturation-unit-test branch 4 times, most recently from 5f997b4 to 060d4c2 Compare January 19, 2024 02:20
@somebody-once-told-me somebody-once-told-me force-pushed the control-allocation-sequential-desaturation-unit-test branch from 060d4c2 to 4bce6d9 Compare January 20, 2024 01:50
Copy link
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

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

Just some mini comments, otherwise good to go.

PS: please do not force push a branch that you opened already a pull request for, as otherwise it's not possible for the reviewer to see what has changed since the last review. Just add the review comments as new commits on top, and push the branch like that. Once the PR is approved you can clean up the commits or we just squash-merge to merge it all into one commit.

…ionSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
…ionSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
…ionSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
Copy link
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

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

You forgot a couple of MOTOR_COUNTS. Lets do them all in ints and then we can get this in!

…for logical float zeros, and make YAW_MOTORS an int
@somebody-once-told-me
Copy link
Contributor Author

@sfuhrer thanks, I fixed those and also added the float specifier suffix to all float zeros, replaced magic numbers with MOTOR_COUNT where applicable, and changed YAW_MOTORS to an int.

Copy link
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

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

Thanks for the last clean up, let's get it in!

@sfuhrer sfuhrer merged commit f40ede6 into PX4:main Jan 26, 2024
88 checks passed
@somebody-once-told-me somebody-once-told-me deleted the control-allocation-sequential-desaturation-unit-test branch January 27, 2024 01:06
jwwaite pushed a commit to AIVS-Inc/PX4-Autopilot that referenced this pull request Feb 12, 2024
* [control_allocation] add unit tests for ControlAllocationSequentialDesaturation

* complete first 2 unit tests

* add yaw test

* add more unit tests

* improve comments

* format

* address review comments

* submodule update

* Update src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* Update src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* Update src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* remove float suffix for logical integers, add missing float suffixes for logical float zeros, and make YAW_MOTORS an int

---------

Co-authored-by: Master Chief <master-chief@the-void.com>
Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
avcuenes pushed a commit to avcuenes/PX4-Autopilot that referenced this pull request Feb 28, 2024
* [control_allocation] add unit tests for ControlAllocationSequentialDesaturation

* complete first 2 unit tests

* add yaw test

* add more unit tests

* improve comments

* format

* address review comments

* submodule update

* Update src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* Update src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* Update src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* remove float suffix for logical integers, add missing float suffixes for logical float zeros, and make YAW_MOTORS an int

---------

Co-authored-by: Master Chief <master-chief@the-void.com>
Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
Peize-Liu pushed a commit to Peize-Liu/PX4-Autopilot that referenced this pull request Mar 24, 2024
* [control_allocation] add unit tests for ControlAllocationSequentialDesaturation

* complete first 2 unit tests

* add yaw test

* add more unit tests

* improve comments

* format

* address review comments

* submodule update

* Update src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* Update src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* Update src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturationTest.cpp

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* remove float suffix for logical integers, add missing float suffixes for logical float zeros, and make YAW_MOTORS an int

---------

Co-authored-by: Master Chief <master-chief@the-void.com>
Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants