apm ardupilot 编译

https://ardupilot.org/dev/docs/building-setup-linux.html#building-setup-linux

 

Setting up the Build Environment (Linux/Ubuntu)

This article shows how to setup your build environment on Linux/Ubuntu machines.

Setup on Ubuntu

Get git

Git is a free and open source distributed version control system that is used to manage ArduPilot codebase. Git is available on all major OS platforms, and a variety of tools exist to make it easier to get started.

Git command line

Ubuntu

Linux/Ubuntu users can install with apt :

  • sudo apt-get update
  • sudo apt-get install git
  • sudo apt-get install gitk git-gui

 

Windows and other Systems

Recommended GUI Tools

The git command line, gitk and git-gui tools are the basics that all users should have installed and are available from a few places.

A comprehensive list of GUI tools are listed here on git-scm.com but here are a few of the developer favourites:

  • GitHub Desktop for Windows and Mac is an easy to use tool with good GitHub integration but has fewer features than other clients.
  • Sourcetree for Windows and Mac OSX is a full featured tool with a nice interface with many features including allowing individual lines from a file to be included in a new commit (simpler tools only allow the entire file to be included)
  • GitKraken is a a full featured tool for Windows, Mac and Linux

Clone ArduPilot repository

“Cloning” is git’s term for making a local copy of a remote repository (i.e. one held on the GitHub servers).

Developers should clone the main ArduPilot repository (if they simply want to download and compile the latest code) or their own fork (if they want to make changes to the source code and potentially submit changes back).

Instructions for commonly used tools are below but whichever tool is used, the URL for the source repo will be required. This can be found on the right side of the screen on each Github repository home page but in general the URL is:

  • https://github.com/ArduPilot/ardupilot.git for the main ardupilot repo
  • https://github.com/your-github-account/ardupilot for your fork of the ardupilot repo

 

Cloning with the command line

  • open a terminal and navigate to the directory where you would like the clone to be stored

  • clone your fork:

    git clone https://github.com/your-github-userid/ardupilot
    cd ardupilot
    git submodule update --init --recursive
    

 

Note

in case some firewalls do not allow ssh access which can cause the above submodule updates to fail, in this instance you can tell git to unilaterally use https through the following command:

git config --global url."https://"

to use https protocols instead of the default git:// prefix.

Install some required packages

If you are on a debian based system (such as Ubuntu or Mint), we provide a script that will do it for you. From ardupilot directory :

Tools/environment_install/install-prereqs-ubuntu.sh -y

Reload the path (log-out and log-in to make permanent):

. ~/.profile

Now you should be able to build with waf as described in BUILD.md.

Note

At this point you have already installed the MAVProxy Ground Control Station (MAVProxy GCS) and are also ready to do Software In the Loop (SITL) simulations of the vehicle code. See SITL Simulator (Software in the Loop) and Setting up SITL on Linux . You are ready to not only build the code, but run your build in the Ardupilot SITL simulator.

 

Cleaning

If there have been updates to some git submodules you may need to do a full clean build. To do that use:

./waf clean

that will remove the build artifacts so you can do a build from scratch


Setup for other Distributions Using the STM Toolchain

Add some directories to your search path (Facultative)

Note

ONLY if you didn’t run the install-prereqs script from previous step.

Add the following lines to the end of your “.bashrc” in your home directory (notice the . on the start of that filename. Also, this is a hidden file, so if you’re using a file manager, make sure to turn on “show hidden files”).

export PATH=$PATH:$HOME/ardupilot/Tools/autotest
export PATH=/usr/lib/ccache:$PATH

Then reload your PATH by using the “dot” command in a terminal

. ~/.bashrc

Warning

Do not use this if you have already use the install-prereqs-ubuntu.sh script !

To build for a autopilot target on Linux you need the following tools and git repositories:

  • The gcc-arm cross-compiler from here (ArduPilot is only built and tested on these specific versions of gcc-arm; if installed with apt-get gcc-arm will not produce a working binary in many cases)
  • gnu make, gawk and associated standard Linux build tools
  • On a 64 bit system you will also need to have installed libc6-i386.

Also, it’s worth mentioning here that you want to ensure that the modemmanager package is not installed and the modem-manager process is not running.

Compiler

You need the specific gcc-arm cross-compiler linked above. You need to unpack it where you want, for now let’s call this location TARGET_DIR:

cd TARGET_DIR
tar -xjvf gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2

and then add the bin directory from the tarball to your $PATH by editing the $HOME/.bashrc file and adding a line like this to the end. TARGET_DIR is the location choose previouly where you unpack the toolchain:

export PATH=$PATH:TARGET_DIR/gcc-arm-none-eabi-6-2017-q2/bin

Permissions

You need to make your user a member of the dialout group:

sudo usermod -a -G dialout $USER

You will need to log out and then log back in for the group change to take effect.

Now you should be able to build with waf as described in BUILD.md.

ccache for faster builds

Installing ccache will speed up your builds a lot. Once you install it (for example with “sudo apt-get install ccache”) you should link the compiler into /usr/lib/ccache like this:

cd /usr/lib/ccache
sudo ln -s /usr/bin/ccache arm-none-eabi-g++
sudo ln -s /usr/bin/ccache arm-none-eabi-gcc

Then add /usr/lib/ccache to the front of your $PATH


Additional Steps for macOS mojave

Due to some changes binutils installed via brew have stopped working for macOS mojave leading to crashing builds. So if installed, remove via following command:

brew uninstall binutils

Also you will need to install the c++ include headers to /usr/include to do that. Run the following in commandline and follow the installation routine:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Setup using Docker

Clone ArduPilot repository

“Cloning” is git’s term for making a local copy of a remote repository (i.e. one held on the GitHub servers).

Developers should clone the main ArduPilot repository (if they simply want to download and compile the latest code) or their own fork (if they want to make changes to the source code and potentially submit changes back).

Instructions for commonly used tools are below but whichever tool is used, the URL for the source repo will be required. This can be found on the right side of the screen on each Github repository home page but in general the URL is:

  • https://github.com/ArduPilot/ardupilot.git for the main ardupilot repo
  • https://github.com/your-github-account/ardupilot for your fork of the ardupilot repo

 

Cloning with the command line

  • open a terminal and navigate to the directory where you would like the clone to be stored

  • clone your fork:

    git clone https://github.com/your-github-userid/ardupilot
    cd ardupilot
    git submodule update --init --recursive
    

 

How to Build the Docker Image

Build the docker image and tag it with the name ardupilot:

docker build . -t ardupilot

Run ArduPilot Container

The following command runs the docker container, linking your current directory with the ardupilot source, and launches an interactive shell inside the container. From here you can build ardupilot:

docker run --rm -it -v `pwd`:/ardupilot ardupilot:latest bash
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值