mag_calibration: only allocate as much memory as needed #9312
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PX4 has a hard-coded maximum number of magnetometers it supports, which is 4:
https://github.com/PX4/Firmware/blob/123f11fcdda9dc6c39ebd94657c5ee94ee53cc90/src/modules/commander/mag_calibration.cpp#L66
Current situation: The calibration routine always allocates the memory for four mags to be calibrated, even when the platform only has a single compass.
Suggestion: Only allocate the memory for the number of mags that the platform actually carries. In case of a single mag, the memory footprint is lowered by 75%. In my test it then allocated only
3800
instead of15200
bytes.