Development Environment on Ubuntu LTS / Debian Linux

Ubuntu Linux LTS 16.04 is the standard/preferred Linux development OS. It allows you to build for the most PX4 targets (NuttX based hardware, Qualcomm Snapdragon Flight hardware, Linux-based hardware, Simulation).

Bash scripts are provided to help make it easy to install development environment for different target platforms:

The scripts have been tested on clean Ubuntu 16.04 and 18.04 LTS installations. They may not work as expected if installed on top of an existing system or a different Ubuntu release.

The instructions below explain how to download and use the scripts.

Gazebo, JMAVSim and NuttX (Pixhawk) Targets

Use the ubuntu.sh script to set up a development environment that includes Gazebo 9 and jMAVSim simulators, and/or the NuttX/Pixhawk toolchain.

To install the toolchain:

  1. Download ubuntu.sh and requirements.txt from the PX4 source repository (/Tools/setup/):
    wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/ubuntu.sh
    wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/requirements.txt
  2. Run the ubuntu.sh with no arguments (in a bash shell) to install everything:
    source ubuntu.sh
    
    • Acknowledge any prompts as the script progress.
    • You can use the --no-nuttx and --no-sim-tools to omit the nuttx and/or simulation tools.
  3. Restart the computer on completion.

You can alternatively Download PX4 Source Code and run the scripts in place:

  git clone https://github.com/PX4/Firmware.git
  source Firmware/Tools/setup/ubuntu.sh

Notes:

  • PX4 works with Gazebo 7, 8, and 9. The script uses gazebosim.org instructions to install Gazebo9.
  • If you're going work with ROS then follow the ROS/Gazebo instructions instead (these install Gazebo automatically, as part of the ROS installation).
  • You can verify the the NuttX installation by confirming the gcc version as shown:

     $arm-none-eabi-gcc --version
    
     arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]
     Copyright (C) 2017 Free Software Foundation, Inc.
     This is free software; see the source for copying conditions.  There is NO
     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

Raspberry Pi

To get the build toolchain for Raspberry Pi:

  1. Download ubuntu.sh and requirements.txt from the PX4 source repository (/Tools/setup/):
    wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/ubuntu.sh
    wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/requirements.txt
  2. Run ubuntu.sh in a terminal to get just the common dependencies:
    source ubuntu.sh --no-nuttx --no-sim-tools
    
  3. Then setup an ARMv7 cross-compiler (either GCC or clang) as described in the following sections.

GCC

The current recommended toolchain for raspbian can be cloned from https://github.com/raspberrypi/tools.git (at time of writing 4.9.3). The PATH environmental variable should include the path to the gcc cross-compiler collection of tools (e.g. gcc, g++, strip) prefixed with arm-linux-gnueabihf-.

git clone https://github.com/raspberrypi/tools.git ${HOME}/rpi-tools

# test compiler
$HOME/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc -v

# permanently update PATH variable by modifying ~/.profile
echo 'export PATH=$PATH:$HOME/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin' >> ~/.profile

# update PATH variable only for this session
export PATH=$PATH:$HOME/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin

Clang

In order to use clang, you also need GCC.

Download clang for your specific distribution from LLVM Download page and unpack it. Assuming that you've unpacked clang to CLANG_DIR, and clang binary is available in CLANG_DIR/bin, and you have the GCC cross-compiler in GCC_DIR, you will need to setup the symlinks for clang in the GCC_DIR bin dir, and add GCC_DIR/bin to PATH.

Example below for building PX4 firmware out of tree, using CMake.

ln -s <CLANG_DIR>/bin/clang <GCC_DIR>/bin/clang
ln -s <CLANG_DIR>/bin/clang++ <GCC_DIR>/bin/clang++
export PATH=<GCC_DIR>/bin:$PATH

cd <PATH-TO-PX4-SRC>
mkdir build/posix_rpi_cross_clang
cd build/posix_rpi_cross_clang
cmake \
-G"Unix Makefiles" \
-DCONFIG=posix_rpi_cross \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
..

Native Builds

Additional developer information for using PX4 on Raspberry Pi (including building PX4 natively) can be found here: Raspberry Pi 2/3 Navio2 Autopilot.

Parrot Bebop

Developers working with the Parrot Bebop should first install the Raspberry Pi Linux Toolchain as described above.

Then install ADB:

sudo apt-get install android-tools-adb -y

ROS/Gazebo

This section explains how to install ROS/Gazebo ("Melodic") for use with PX4.

PX4 is tested with ROS Melodic on Ubuntu 18.04 LTS. ROS Melodic does not work on Ubuntu 16.04.

To install the development toolchain:

  1. Download the script in a bash shell:
    wget https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_ros_melodic.sh
  2. Run the script:
    source ubuntu_sim_ros_melodic.sh
    
    You may need to acknowledge some prompts as the script progresses.

Note:

  • ROS Melodic is installed with Gazebo9 by default.
  • Your catkin (ROS build system) workspace is created at ~/catkin_ws/.
  • The script uses instructions from the ROS Wiki "Melodic" Ubuntu page.

Snapdragon Flight

Setup instructions for Snapdragon Flight are provided in the PX4 User Guide:

FastRTPS installation

eProsima Fast RTPS is a C++ implementation of the RTPS (Real Time Publish Subscribe) protocol. FastRTPS is used, via the RTPS/ROS2 Interface: PX4-FastRTPS Bridge, to allow PX4 uORB topics to be shared with offboard components.

The following instructions can be used to install the FastRTPS 1.7.1 binaries to your home directory.

wget https://www.eprosima.com/index.php/component/ars/repository/eprosima-fast-rtps/eprosima-fast-rtps-1-7-1/eprosima_fastrtps-1-7-1-linux-tar-gz -O eprosima_fastrtps-1-7-1-linux.tar.gz
tar -xzf eprosima_fastrtps-1-7-1-linux.tar.gz eProsima_FastRTPS-1.7.1-Linux/
tar -xzf eprosima_fastrtps-1-7-1-linux.tar.gz requiredcomponents
tar -xzf requiredcomponents/eProsima_FastCDR-1.0.8-Linux.tar.gz

In the following lines where we compile the FastCDR and FastRTPS libraries, the make command is issued with the -j2 option. This option defines the number of parallel threads (or jobs) that are used to compile the source code. Change -j2 to -j<number_of_cpu_cores_in_your_system> to speed up the compilation of the libraries.

(cd eProsima_FastCDR-1.0.8-Linux && ./configure --libdir=/usr/lib && make -j2 && sudo make install)
(cd eProsima_FastRTPS-1.7.1-Linux && ./configure --libdir=/usr/lib && make -j2 && sudo make install)
rm -rf requiredcomponents eprosima_fastrtps-1-7-1-linux.tar.gz

More "generic" instructions, which additionally cover installation from source, can be found here: Fast RTPS installation.

Additional Tools

After setting up the build/simulation toolchain, see Additional Tools for information about other useful tools.

Next Steps

Once you have finished setting up the environment, continue to the build instructions.

results matching ""

    No results matching ""