ArduPilot/ardupilot

Make more features configurable

Open

#19,068 opened on Oct 28, 2021

View on GitHub
 (9 comments) (1 reaction) (0 assignees)C++ (15,603 forks)batch import
good first issue

Repository metrics

Stars
 (9,336 stars)
PR merge metrics
 (Avg merge 26d 16h) (166 merged PRs in 30d)

Description

Cleanup request

Our new build server (https://custom.ardupilot.org) allows users to make their own firmwares by selecting and de-selecting features.

Sometimes the amount of code required to run a feature exceeds the flash space available on boards.

The more things we allow users to remove from the compilation the more likely they are to get a firmware that does everything they want.

A good example of this is scripting - users of 1MB boards would love to have it, but it is a large chunk of code and excluded from the 1MB builds by default.

note - each of these libraries can and should be done as a separate Pull Request!

There are many places in the code that we could allow users to exclude chunks of code on a piece-by-piece basis, for example:

  • rangefinder library

  • visual odometry backends

  • AC_Avoid

  • DONE AP_Winch backends

  • DONE GPS backends (@Hwurzburg is currently looking at these)

  • DONE rangefinder backends

  • DONE precision landing library

  • DONE compass backends

  • DONE airspeed backends

  • DONE AP_Mount backends

  • DONE battery monitor backends

  • DONE AP_Winch

  • DONE AP_MSP backends

  • DONE optical flow library

  • DONE optical flow backends

  • DONE RCInput backends (e.g. srxl)

  • DONE FRSky library

  • DONE FRSky backends

The larger the amount of code excised the more useful the change is. nm can be used to show the largest symbols in the compiled code:

pbarker@bluebottle:~/rc/ardupilot(pr/sitl-on-hw)$ arm-none-eabi-nm --demangle --size-sort --print-size build/NucleoH743/bin/ardurover | tail -20
3000de30 00001200 B NavEKF_core_common::nextP
080e58ac 00001264 T NavEKF3_core::FuseDragForces()
3000a484 000013c8 b xsimstate
080e4454 0000144c T NavEKF3_core::FuseSideslip()
080880c8 00001540 T SoloGimbalEKF::predictCovariance()
0810a8cc 0000163c T NavEKF2_core::FuseSideslip()
300183d0 00001658 b supported_frames
30011e20 000017e4 b icm40609
3001be50 000018a0 B SDU1
08111918 00001e78 t __static_initialization_and_destruction_0(int, int)
0810d548 00001f5c T NavEKF2_core::FuseOptFlow()
081330b0 00002014 T AP_Param::param_defaults_data
080e80fc 000022f8 T NavEKF3_core::FuseOptFlow(NavEKF3_core::of_elements const&, bool)
080d4e08 00002814 T NavEKF2_core::FuseMagnetometer()
0805ff8c 000029ee T NavEKF3_core::FuseBodyVel()
081460a4 00002ddb t ap_romfs_0
0805597c 00002edc T NavEKF3_core::FuseMagnetometer()
080df5ac 00004d0c T NavEKF2_core::CovariancePrediction()
0806626c 00005e70 T NavEKF3_core::CovariancePrediction(Vector3<double>*)
30002518 00006740 B rover
pbarker@bluebottle:~/rc/ardupilot(pr/sitl-on-hw)$ 

There are also some large wins available by filling out AP_NavEKF3_features.h with more options. This work will be much more complicated, but the ability to, for example, exclude magnetometers from the EKF's calculations would save a very large amount of code. (see https://github.com/ArduPilot/ardupilot/issues/19070 however)

The pattern we use is AP_<foo>_ENABLED. An example of this is AP_QUADPLANE_ENABLED. Typically the main library header will contain:

#ifndef AP_GPS_NOVA_ENABLED
#define AP_GPS_NOVA_ENABLED 1
#endif

The new option should also be added to the custom build server configuration: https://github.com/ArduPilot/ardupilot/blob/master/Tools/scripts/build_options.py

The code must be tested for compilation and working-ness with and without the option set.

Platform [ X ] All [ ] AntennaTracker [ ] Copter [ ] Plane [ ] Rover [ ] Submarine

Contributor guide