-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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 Allocator: Metric #24199
Control Allocator: Metric #24199
Conversation
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 40 byte (0 %)]
px4_fmu-v6x [Total VM Diff: 40 byte (0 %)]
Updated: 2025-01-17T20:21:13 |
f60507b
to
b257fe9
Compare
bool update_normalization_scale) | ||
{ | ||
ControlAllocation::setEffectivenessMatrix(effectiveness, actuator_trim, linearization_point, num_actuators, | ||
update_normalization_scale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is update_normalization_scale
ever used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not by metric allocator. It is used here in ControlAllocationPseudoInverse.cpp lines 53 and 62.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that if this is removed, than the code in
PX4-Autopilot/src/modules/control_allocator/ControlAllocator.cpp
Lines 592 to 593 in 5147394
_control_allocation[i]->setEffectivenessMatrix(config.effectiveness_matrices[i], config.trim[i], | |
config.linearization_point[i], total_num_actuators, reason == EffectivenessUpdateReason::CONFIGURATION_UPDATE); |
I can, however, remove it to avoid confusion and assume that if the user wishes to use it with control_allocator, there will be trouble. Perhaps that's the correct way?
@Jaeyoung-Lim I set the parameter to false to make it clear that we don't care about normalization in metric allocator. |
@sfuhrer would be happy to take inputs so we can merge this soon |
@Pedro-Roque yes sure, happy to have a look. Could you first rebase on latest main, as the PRs this was based on are since in main? And at the same time you could squash your commits. That makes reviewing bit easier. Thanks! |
efcca10
to
0f7f340
Compare
@sfuhrer done |
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to untangle the matrix normalization from the actual allocation algorithm inside the ControlAllocationPseudoInverse
. Then the metric allocation wouldn't even specific methods, but it would only be a flag (normalize or not) prior to passing it to the allocator.
If that cannot be done now then I'm okay to get this in, but would rename the files.
@@ -34,6 +34,8 @@ | |||
px4_add_library(ControlAllocation | |||
ControlAllocation.cpp | |||
ControlAllocation.hpp | |||
ControlAllocationMetric.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider calling it ControlAllocationPseudoInverseMetric? That would make it more clear which parts of the existing, normalized, pipeline you're replacing.
Next step would then be to move all the normalization and scaling of the allocation matrix out of the PseudoInverse. The algorithms in the end don't care whether the allocation matrix is normalized or not, do they? Would ControlAllocationSequentialDesaturation work out of the box with a metric allocation matrix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To address this I've created an internal variable to activate metric allocation. Then we keep the same structure and if non-metric is being used, the allocator behaves as previously expected.
I'd need to look in detail towards the sequential desaturation algorithm, but since I don't use it, I don't have a good answer as of now. In principle, yes, this should be possible.
Thanks for the input @sfuhrer ! I've done exactly that for now. The same interface could be added to the sequential desaturation, but since I don't work with that allocator, it's hard for me to test. But the principle would be the same... |
@@ -46,6 +46,7 @@ | |||
#pragma once | |||
|
|||
#include "ControlAllocation.hpp" | |||
#include <px4_platform_common/log.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this isn't necessary, as you don't enable it due to
``` // adding #include <px4_platform_common/log.h> + PX4_WARN leads to failed linking on test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the requested line. Let's get it merged? 😃
…on) (#24199) * add: metric allocation * add: actual files * rft: moved metric allocation to pseudo-inverse via flag with public method * del: removed metric allocation test and added test in pseudo-inverse testing * rft: deleted extra newline at the end of pseudo inverse test file * feat: removed unnecessary log include
…on) (PX4#24199) * add: metric allocation * add: actual files * rft: moved metric allocation to pseudo-inverse via flag with public method * del: removed metric allocation test and added test in pseudo-inverse testing * rft: deleted extra newline at the end of pseudo inverse test file * feat: removed unnecessary log include
Solved Problem
Adds metric control allocation (ie non-normalized) to make possible model-based control schemes.
Solution
sc
in https://github.com/DISCOWER/PX4-Space-Systems/tree/dev-sc_ctl_alloc/src/modules/sc_control_allocator )Changelog Entry
For release notes:
Test coverage
Context
Depends on #24196