Ardupilot开源飞控工程项目编译回顾

1. 源由

最近,有点莫名的连续遇到了2次Ardupilot编译报错。百思不得其解,特地记录下,以便后续不要犯类似的毛病。

问题/现象这里不重复了,请看链接: Build error compiling 4.5.1 Copter with F405 (4.4.x) target #26785

2. 工程编译

正常工作编译,大家可以参考:

好处:中文
坏处:无法与官方项目同步

好处:最新同步文档
坏处:英语不习惯的人,。。。。不多说,反正永远也不会习惯。。。。

3. 命令列表

这里罗列一些日常常用的工程编译命令。

3.1 工作环境设置

注意:请替换自己代理服务器的IP和port。

  1. git代理设置
$ git config --global "url.ssh://git@ssh.github.com:443/.insteadOf" git@github.com:
$ git config --global http.proxy http://192.168.1.9:808
$ git config --global https.proxy http://192.168.1.9:808
  1. http/https代理设置
$ export https_proxy=http://192.168.1.9:808/
$ export http_proxy=http://192.168.1.9:808/
  1. apt代理设置
$ sudo apt-get -o Acquire::http::proxy="http://192.168.1.9:808" update

3.2 获取工程代码

通常git协议容易获取代码,https不是很方便,而且开发角度使用git会更好。

$ git clone git@github.com:ArduPilot/ardupilot.git

3.3 建立编译环境

$ cd ardupilot
$ ./Tools/environment_install/install-prereqs-ubuntu.sh -y

3.4 编译工程代码

$ cd ardupilot
$ ./Tools/gittools/submodule-sync.sh
$ ./Tools/scripts/build_bootloaders.py Aocoda-RC-H743Dual
$ ./waf configure --board Aocoda-RC-H743Dual
$ ./waf copter

3.5 保存编译结果

$ cd ardupilot
$ cd build
$ rm -rf ArduCopter lib libraries modules .dep .wafpickle-linux*
$ zip -r Aocoda-RC-H743Dua.zip Aocoda-RC-H743Dual

3.6 清理编译结果

$ ./waf clean

3.7 编译设备目标

$ ./waf copter  //多旋翼
$ ./waf heli  //直升机
$ ./waf antennatracker  //跟踪天线
$ ./waf blimp  //飞艇
$ ./waf plane  //固定翼
$ ./waf rover  //车
$ ./waf sub   //潜水艇

4. 补充 帮助命令waf

$ ./waf -h
waf [commands] [options]

Main commands (example: ./waf build -j4)
  AP_Periph     : builds AP_Periph programs
  all           : builds all programs of all group
  antennatracker: builds antennatracker programs
  benchmarks    : builds all programs of benchmarks group
  bin           : builds all programs of bin group
  blimp         : builds blimp programs
  bootloader    : builds bootloader programs
  build         : executes the build
  check         : builds all programs and run tests
  check-all     : shortcut for `waf check --alltests`
  clean         : cleans the project
  conf          :
        Decorator: attach new configuration functions to :py:class:`waflib.Build.BuildContext` and
        :py:class:`waflib.Configure.ConfigurationContext`. The methods bound will accept a parameter
        named 'mandatory' to disable the configuration errors::

                def configure(conf):
                        conf.find_program('abc', mandatory=False)

        :param f: method to bind
        :type f: function

  configure     : configures the project
  copter        : builds copter programs
  dist          : makes a tarball for redistributing the sources
  distcheck     : checks if the project compiles (tarball from 'dist')
  distclean     : removes build folders and data
  examples      : builds all programs of examples group
  heli          : builds heli programs
  install       : installs the targets on the system
  iofirmware    : builds iofirmware programs
  list          : lists the targets to execute
  localinstall  : runs install using BLD/install as destdir, where BLD is the build variant directory
  plane         : builds plane programs
  replay        : builds replay programs
  rover         : builds rover programs
  rsync         : runs localinstall and then rsyncs BLD/install with the target system
  step          : executes tasks in a step-by-step fashion, for debugging
  sub           : builds sub programs
  tests         : builds all programs of tests group
  tool          : builds all programs of tool group
  uninstall     : removes the targets installed

Options:
  --version             show program's version number and exit
  -c COLORS, --color=COLORS
                        whether to use colors (yes/no/auto) [default: auto]
  -j JOBS, --jobs=JOBS  amount of parallel jobs (2)
  -k, --keep            continue despite errors (-kk to try harder)
  -v, --verbose         verbosity level -v -vv or -vvv [default: 0]
  --zones=ZONES         debugging zones (task_gen, deps, tasks, etc)
  -h, --help            show this help message and exit
  --notests             Exec no unit tests
  --alltests            Exec all unit tests
  --clear-failed        Force failed unit tests to run again next time
  --testcmd=TESTCMD     Run the unit tests using the test-cmd string example "--testcmd="valgrind --error-exitcode=1 %s" to run under valgrind
  --dump-test-scripts   Create python scripts to help debug tests

  Configuration options:
    -o OUT, --out=OUT   build dir for the project
    -t TOP, --top=TOP   src dir for the project
    --check-cxx-compiler=CHECK_CXX_COMPILER
                        list of C++ compilers to try [g++ clang++ icpc]
    --check-c-compiler=CHECK_C_COMPILER
                        list of C compilers to try [gcc clang icc]

  Build and installation options:
    -p, --progress      -p: progress bar; -pp: ide output
    --targets=TARGETS   task generators, e.g. "target1,target2"

  Step options:
    --files=FILES       files to process, by regexp, e.g. "*/main.c,*/test/main.o"

  Installation and uninstallation options:
    -f, --force         force file installation
    --distcheck-args=ARGS
                        arguments to pass to distcheck

  Python Options:
    --nopyc             Do not install bytecode compiled .pyc files (configuration) [Default:install]
    --nopyo             Do not install optimised compiled .pyo files (configuration) [Default:install]
    --nopycache         Do not use __pycache__ directory to install objects [Default:auto]
    --python=PYTHON     python binary to be used [Default: /usr/bin/python3]
    --pythondir=PYTHONDIR
                        Installation path for python modules (py, platform-independent .py and .pyc files)
    --pythonarchdir=PYTHONARCHDIR
                        Installation path for python extension (pyext, platform-dependent .so or .dylib files)

  Ardupilot configure options:
    --board=BOARD       Target board to build, choices are ACNS-CM4Pilot, ACNS-F405AIO, aero, AeroFox-Airspeed, AeroFox-Airspeed-DLVR, AeroFox-GNSS_F9P, AeroFox-PMU,
                        airbotf4, AIRLink, Airvolute-DCS2, AnyleafH7, Aocoda-RC-H743Dual, AR-F407SmartBat, ARK_CANNODE, ARK_GPS, ARK_RTK_GPS, ARKV6X, AtomRCF405NAVI,
                        bbbmini, BeastF7, BeastF7v2, BeastH7, BeastH7v2, bebop, BETAFPV-F405, bhat, BirdCANdy, BlitzF745, BlitzF745AIO, BlitzH743Pro, BlitzMiniF745,
                        BlitzWingH743, blue, C-RTK2-HP, canzero, CarbonixF405, CarbonixL496, crazyflie2, CUAV-Nora, CUAV-Nora-bdshot, CUAV-X7, CUAV-X7-bdshot, CUAV_GPS,
                        CUAVv5, CUAVv5-bdshot, CUAVv5Nano, CUAVv5Nano-bdshot, CubeBlack, CubeBlack+, CubeBlack-periph, CubeGreen-solo, CubeOrange, CubeOrange-bdshot,
                        CubeOrange-joey, CubeOrange-ODID, CubeOrange-periph, CubeOrange-periph-heavy, CubeOrange-SimOnHardWare, CubeOrangePlus, CubeOrangePlus-bdshot,
                        CubeOrangePlus-SimOnHardWare, CubePilot-CANMod, CubePilot-PPPGW, CubePurple, CubeRedPrimary, CubeRedPrimary-PPPGW, CubeRedSecondary, CubeSolo,
                        CubeYellow, CubeYellow-bdshot, dark, DevEBoxH7v2, disco, DrotekP3Pro, Durandal, Durandal-bdshot, edge, erleboard, erlebrain2, esp32buzz,
                        esp32diy, esp32empty, esp32icarus, esp32nick, esp32s3devkit, esp32s3empty, esp32tomte76, f103-ADSB, f103-Airspeed, f103-GPS, f103-HWESC,
                        f103-QiotekPeriph, f103-RangeFinder, f103-Trigger, f303-GPS, f303-HWESC, f303-M10025, f303-M10070, f303-MatekGPS, f303-PWM, f303-TempSensor,
                        f303-Universal, F35Lightning, f405-MatekAirspeed, f405-MatekGPS, F4BY, FlyingMoonF407, FlyingMoonF427, FlyingMoonH743, FlywooF405Pro,
                        FlywooF405S-AIO, FlywooF745, FlywooF745Nano, fmuv2, fmuv3, fmuv3-bdshot, fmuv5, FoxeerF405v2, FoxeerH743v1, FreeflyRTK, G4-ESC, H757I_EVAL,
                        H757I_EVAL_intf, HEEWING-F405, HEEWING-F405v2, Here4AP, Here4FC, HerePro, Hitec-Airspeed, HitecMosaic, HolybroG4_Compass, HolybroG4_GPS,
                        HolybroGPS, iomcu, iomcu-dshot, iomcu-f103, iomcu-f103-dshot, iomcu_f103_8MHz, JFB100, JFB110, JHEMCU-GSF405A, JHEMCU-GSF405A-RX2, KakuteF4,
                        KakuteF4Mini, KakuteF7, KakuteF7-bdshot, KakuteF7Mini, KakuteH7, KakuteH7-bdshot, KakuteH7-Wing, KakuteH7Mini, KakuteH7Mini-Nand, KakuteH7v2,
                        kha_eth, linux, luminousbee4, luminousbee5, MambaF405-2022, MambaF405US-I2C, MambaF405v2, MambaH743v4, MatekF405, MatekF405-bdshot,
                        MatekF405-CAN, MatekF405-STD, MatekF405-TE, MatekF405-TE-bdshot, MatekF405-Wing, MatekF405-Wing-bdshot, MatekF765-SE, MatekF765-Wing,
                        MatekF765-Wing-bdshot, MatekH743, MatekH743-bdshot, MatekH743-periph, MatekL431-ADSB, MatekL431-Airspeed, MatekL431-BattMon, MatekL431-bdshot,
                        MatekL431-DShot, MatekL431-EFI, MatekL431-GPS, MatekL431-HWTelem, MatekL431-Periph, MatekL431-Proximity, MatekL431-Rangefinder, MatekL431-RC,
                        MatekL431-Serial, MazzyStarDrone, MicoAir405v2, mindpx-v2, mini-pix, modalai_fc-v1, mRo-M10095, mRoCANPWM-M10126, mRoControlZeroClassic,
                        mRoControlZeroF7, mRoControlZeroH7, mRoControlZeroH7-bdshot, mRoControlZeroOEMH7, mRoCZeroOEMH7-bdshot, mRoNexus, mRoPixracerPro,
                        mRoPixracerPro-bdshot, mRoX21, mRoX21-777, navigator, navio, navio2, Nucleo-G491, Nucleo-L476, Nucleo-L496, NucleoH743, NucleoH755, obal,
                        ocpoc_zynq, omnibusf4, omnibusf4pro, omnibusf4pro-bdshot, omnibusf4pro-one, omnibusf4v6, OMNIBUSF7V2, OmnibusNanoV6, OmnibusNanoV6-bdshot,
                        OrqaF405Pro, PH4-mini, PH4-mini-bdshot, Pix32v5, PixC4-Jetson, PixFlamingo, PixFlamingo-F767, Pixhawk1, Pixhawk1-1M, Pixhawk1-1M-bdshot,
                        Pixhawk1-bdshot, Pixhawk4, Pixhawk4-bdshot, Pixhawk5X, Pixhawk6C, Pixhawk6C-bdshot, Pixhawk6X, Pixhawk6X-bdshot, Pixhawk6X-ODID,
                        Pixhawk6X-PPPGW, PixPilot-C3, PixPilot-V3, PixPilot-V6, Pixracer, Pixracer-bdshot, Pixracer-periph, PixSurveyA1, PixSurveyA1-IND, PixSurveyA2,
                        pocket, pxf, pxfmini, QioTekAdeptF407, QioTekZealotF427, QioTekZealotH743, QioTekZealotH743-bdshot, R9Pilot, RADIX2HD, ReaperF745, revo-mini,
                        revo-mini-bdshot, revo-mini-i2c, revo-mini-i2c-bdshot, revo-mini-sd, rFCU, rGNSS, rst_zynq, SDMODELH7V1, SDMODELH7V2, Sierra-F405, Sierra-F412,
                        Sierra-F9P, Sierra-L431, Sierra-PrecisionPoint, Sierra-TrueNavIC, Sierra-TrueNavPro, Sierra-TrueNavPro-G4, Sierra-TrueNorth, Sierra-TrueSpeed,
                        sitl, SITL_arm_linux_gnueabihf, sitl_periph, sitl_periph_gps, sitl_periph_universal, SITL_static, SITL_x86_64_linux_gnu, SIYI_N7, SkystarsH7HD,
                        SkystarsH7HD-bdshot, skyviper-f412-rev1, skyviper-journey, skyviper-v2450, sparky2, speedybeef4, SpeedyBeeF405Mini, SpeedyBeeF405WING,
                        speedybeef4v3, speedybeef4v4, SPRacingH7, SPRacingH7RF, SuccexF4, sw-nav-f405, sw-spar-f407, Swan-K1, TBS-Colibri-F7, thepeach-k1, thepeach-r1,
                        TMotorH743, vnav, VRBrain-v51, VRBrain-v52, VRBrain-v54, VRCore-v10, VRUBrain-v51, YJUAV_A6, YJUAV_A6SE, YJUAV_A6SE_H743, YJUAV_A6Ultra,
                        ZubaxGNSS, zynq.
    --debug             Configure as debug variant.
    -g, --debug-symbols
                        Add debug symbolds to build.
    --disable-watchdog  Build with watchdog disabled.
    --coverage          Configure coverage flags.
    --Werror            build with -Werror.
    --disable-Werror    Disable -Werror.
    --toolchain=TOOLCHAIN
                        Override default toolchain used for the board. Use "native" for using the host toolchain.
    --disable-gccdeps   Disable the use of GCC dependencies output method and use waf default method.
    --enable-asserts    enable OS level asserts.
    --save-temps        save compiler temporary files.
    --enable-malloc-guard
                        enable malloc guard regions.
    --enable-stats      enable OS level thread statistics.
    --enable-ppp        enable PPP networking.
    --bootloader        Configure for building a bootloader.
    --signed-fw         Configure for signed firmware support.
    --private-key=PRIVATE_KEY
                        path to private key for signing firmware.
    --no-autoconfig     Disable autoconfiguration feature. By default, the build system triggers a reconfiguration whenever it thinks it's necessary - this option
                        disables that.
    --no-submodule-update
                        Don't update git submodules. Useful for building with submodules at specific revisions.
    --enable-header-checks
                        Enable checking of headers
    --default-parameters=DEFAULT_PARAMETERS
                        set default parameters to embed in the firmware
    --enable-math-check-indexes
                        Enable checking of math indexes
    --disable-scripting
                        Disable onboard scripting engine
    --enable-scripting  Enable onboard scripting engine
    --no-gcs            Disable GCS code
    --scripting-checks  Enable runtime scripting sanity checks
    --enable-onvif      Enables and sets up ONVIF camera control
    --scripting-docs    enable generation of scripting documentation
    --enable-opendroneid
                        Enables OpenDroneID
    --enable-check-firmware
                        Enables firmware ID checking on boot
    --enable-custom-controller
                        Enables custom controller
    --enable-gps-logging
                        Enables GPS logging
    --enable-dds        Enable the dds client to connect with ROS2/DDS.
    --disable-networking
                        Disable the networking API code
    --enable-networking-tests
                        Enable the networking test code. Automatically enables networking.
    --enable-dronecan-tests
                        Enables DroneCAN tests in sitl

  Linux boards configure options:
    --prefix=PREFIX     installation prefix [default: '/usr/']
    --destdir=DESTDIR   installation root [default: '']
    --bindir=BINDIR     bindir
    --libdir=LIBDIR     libdir
    --apstatedir=APSTATEDIR
                        Where to save data like parameters, log and terrain. This is the --localstatedir + ArduPilots subdirectory [default: board-dependent, usually
                        /var/lib/ardupilot]
    --rsync-dest=RSYNC_DEST
                        Destination for the rsync Waf command. It can be passed during configuration in order to save typing.
    --enable-benchmarks
                        Enable benchmarks.
    --enable-lttng      Enable lttng integration
    --disable-libiio    Don't use libiio even if supported by board and dependencies available
    --disable-tests     Disable compilation and test execution
    --enable-sfml       Enable SFML graphics library
    --enable-sfml-joystick
                        Enable SFML joystick input library
    --enable-sfml-audio
                        Enable SFML audio library
    --osd               Enable OSD support
    --osd-fonts         Enable OSD support with fonts
    --sitl-osd          Enable SITL OSD
    --sitl-rgbled       Enable SITL RGBLed
    --force-32bit       Force 32bit build
    --build-dates       Include build date in binaries.  Appears in AUTOPILOT_VERSION.os_sw_version
    --sitl-flash-storage
                        Use flash storage emulation.
    --enable-ekf2       Configure with EKF2.
    --disable-ekf3      Configure without EKF3.
    --ekf-double        Configure EKF as double precision.
    --ekf-single        Configure EKF as single precision.
    --static            Force a static build
    --postype-single    force single precision postype_t
    --consistent-builds
                        force consistent build outputs for things like __LINE__
    --extra-hwdef=EXTRA_HWDEF
                        Extra hwdef.dat file for custom build.
    --assert-cc-version=ASSERT_CC_VERSION
                        fail configure if not using the specified gcc version
    --num-aux-imus=NUM_AUX_IMUS
                        number of auxiliary IMUs
    --board-start-time=BOARD_START_TIME
                        zero time on boot in microseconds

  Ardupilot build options:
    --program-group=PROGRAM_GROUP
                        Select all programs that go in <PROGRAM_GROUP>/ for the build. Example: `waf --program-group examples` builds all examples. The special group
                        "all" selects all programs.
    --upload            Upload applicable targets to a connected device. Not all platforms may support this. Example: `waf copter --upload` means "build arducopter and
                        upload it to my board".
    --upload-port=UPLOAD_PORT
                        Specify the port to be used with the --upload option. For example a port of /dev/ttyS10 indicates that serial port 10 shuld be used.
    --upload-force      Override board type check and continue loading. Same as using uploader.py --force.
    --summary-all       Print build summary for all targets. By default, only information about the first 20 targets will be printed.

  Ardupilot check options:
    --check-verbose     Output all test programs.
    --define=DEFINE     Add C++ define to build.

  Ardupilot clean options:
    --clean-all-sigs    Clean signatures for all tasks. By default, tasks that scan for implicit dependencies (like the compilation tasks) keep the dependency
                        information across clean commands, so that that information is changed only when really necessary. Also, some tasks that don't really produce
                        files persist their signature. This option avoids that behavior when cleaning the build.
    --asan              Build using the macOS clang Address Sanitizer. In order to run with Address Sanitizer support llvm-symbolizer is required to be on the PATH.
                        This option is only supported on macOS versions of clang.
    --ubsan             Build using the gcc undefined behaviour sanitizer
    --ubsan-abort       Build using the gcc undefined behaviour sanitizer and abort on error
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值