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

scripts: Fixed extract_features.py not extracting some features properly #27796

Merged
merged 2 commits into from
Aug 9, 2024

Conversation

joshanne
Copy link
Contributor

@joshanne joshanne commented Aug 9, 2024

extract_features.py is not detecting/correctly extracting:

  • IMU Temperature Calibration
  • ExternalAHRS

Tested against a local build of CubeOrangePlus with hwdef modifications disabling the feature.

@joshanne joshanne force-pushed the pr/fix-extract-features branch from 234a15a to 07173e2 Compare August 9, 2024 03:12
@@ -73,14 +73,15 @@ def __init__(self, filename, nm="arm-none-eabi-nm", strings="strings"):
('HAL_NAVEKF3_AVAILABLE', 'NavEKF3::NavEKF3',),
('HAL_NAVEKF2_AVAILABLE', 'NavEKF2::NavEKF2',),
('HAL_EXTERNAL_AHRS_ENABLED', r'AP_ExternalAHRS::init\b',),
('AP_EXTERNAL_AHRS_{type}_ENABLED', r'AP_ExternalAHRS_{type}::healthy\b',),
('HAL_INS_TEMPERATURE_CAL_ENABLE', 'AP_InertialSensor::TCal::Learn::save_calibration',),
('AP_EXTERNAL_AHRS_{type}_ENABLED', r'AP_ExternalAHRS_(?P<type>.*)::healthy\b',),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was not correctly detecting presence of ExternalAHRS_VectorNav

('AP_EXTERNAL_AHRS_{type}_ENABLED', r'AP_ExternalAHRS_{type}::healthy\b',),
('HAL_INS_TEMPERATURE_CAL_ENABLE', 'AP_InertialSensor::TCal::Learn::save_calibration',),
('AP_EXTERNAL_AHRS_{type}_ENABLED', r'AP_ExternalAHRS_(?P<type>.*)::healthy\b',),
('HAL_INS_TEMPERATURE_CAL_ENABLE', 'AP_InertialSensor_TCal::Learn::save_calibration',),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was not detecting presence of Inertial Sensor TCal

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops.

@@ -142,7 +143,7 @@ def __init__(self, filename, nm="arm-none-eabi-nm", strings="strings"):

('HAL_PARACHUTE_ENABLED', 'AP_Parachute::update',),
('AP_FENCE_ENABLED', r'AC_Fence::check\b',),
('HAL_RALLY_ENABLED', r'AP_Rally::get_rally_max\b',),
('HAL_RALLY_ENABLED', 'AP_Rally::find_nearest_rally_point',),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed Rally was not being detected by default? get_rally_max is not showing when running arm-none-eabi-nm --demangle --print-size - so I've moved this to a function that is visible and used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Compiler was probably inlining; you could try recompiling with a different optimisation level to see if that's true. But it can't possibly be being elided given where it is used!

@@ -257,7 +258,7 @@ def __init__(self, filename, nm="arm-none-eabi-nm", strings="strings"):
('FORCE_APJ_DEFAULT_PARAMETERS', 'AP_Param::param_defaults_data'),
('HAL_BUTTON_ENABLED', 'AP_Button::update'),
('HAL_LOGGING_ENABLED', 'AP_Logger::init'),
('AP_COMPASS_CALIBRATION_FIXED_YAW_ENABLED', 'AP_Compass::mag_cal_fixed_yaw'),
('AP_COMPASS_CALIBRATION_FIXED_YAW_ENABLED', 'Compass::mag_cal_fixed_yaw'),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was not detecting properly. The class is Compass, not AP_Compass - perhaps Compass should be moved to AP_Compass at some point?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it should. I made that change for OpticalFlow, I think.

@@ -34,6 +34,7 @@ def __init__(self,
Feature('AHRS', 'MicroStrain5', 'AP_EXTERNAL_AHRS_MICROSTRAIN5_ENABLED', 'Enable MICROSTRAIN 5-series External AHRS', 0, "AHRS_EXT"), # noqa: E501
Feature('AHRS', 'MicroStrain7', 'AP_EXTERNAL_AHRS_MICROSTRAIN7_ENABLED', 'Enable MICROSTRAIN 7-series External AHRS', 0, "AHRS_EXT"), # noqa: E501
Feature('AHRS', 'AHRS_EXT_VECTORNAV', 'AP_EXTERNAL_AHRS_VECTORNAV_ENABLED', 'Enable VectorNav External AHRS', 0, "AHRS_EXT"), # noqa
#Feature('AHRS', 'InertialLabs', 'AP_EXTERNAL_AHRS_INERTIAL_LABS_ENABLED', 'Enable InertialLabs External AHRS', 0, "AHRS_EXT"), # disabled because INERTIAL_LABS is the enable flag
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are 9 instances of AP_EXTERNAL_AHRS_INERTIAL_LABS_ENABLED in the code base - I'd like to change them to AP_EXTERNAL_AHRS_INERTIALLABS_ENABLED so this line can be uncommented and changed correctly.

We can either detect the InertialLabs class correctly, but not use this build_option feature externally, OR, incorrectly detect the feature, but correctly use the build_options to generate a file.

What should it be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, this would potentially break peoples custom build servers...

Could rename the class.

Is there a way to map extracted feature classes to a different define name? I couldn't see one

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this rename

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent. I'll push a patch for that shortly.

@joshanne joshanne requested a review from peterbarker August 9, 2024 03:18
The enable flag is AP_EXTERNAL_AHRS_INERTIAL_LABS_ENABLED, but the extract features can only generate based on the class name, which is InertialLabs.
@joshanne joshanne force-pushed the pr/fix-extract-features branch from 07173e2 to 9e0ed3e Compare August 9, 2024 03:58
@joshanne joshanne changed the title scripts: Fixed extract_features.py not extracting ExternalAHRS or INS Temp Cal properly scripts: Fixed extract_features.py not extracting some features properly Aug 9, 2024
@peterbarker
Copy link
Contributor

Thanks for this. I've just written patches here that allow ./Tools/autotest/test_build_features.py to detect these. Those are lurking in #27777

@peterbarker peterbarker merged commit 154876f into ArduPilot:master Aug 9, 2024
41 checks passed
@peterbarker
Copy link
Contributor

Merged, thanks!

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.

2 participants