Ubuntu Setup
Last updated
Last updated
The following instructions set up a PX4 development environment on the versions supported by PX4. This includes: 18.04 (Bionic Beaver), 20.04 (Focal Fossa), and Ubuntu 22.04 (Jammy Jellyfish).
Bash scripts are provided to simplify the process. They are intended to be run on clean Ubuntu LTS installations, and may not work if run "on top" of an existing system, or on a different Ubuntu release.
The are:
. This includes: , , , ).
(Robotics Operating System)
(Robotics Operating System)
:::tip This setup is supported by the PX4 dev team. The instructions may also work on other Debian Linux based systems. :::
This video shows how to install the toolchain for NuttX and simulation targets () along with the basic testing covered in .
@.
:::warning ROS users should first read/skip ahead to the or sections. :::
Use the script to set up a development environment that allows you to build for simulators and/or the toolchain. The script installs on all targets, 9 on Ubuntu 18.04, Gazebo Classic 11 on Ubuntu 20.04, and "Garden" on Ubuntu 22.04.
To install the toolchain:
Run the ubuntu.sh with no arguments (in a bash shell) to install everything:
Acknowledge any prompts as the script progress.
You can use the --no-nuttx
and --no-sim-tools
options to omit the NuttX and/or simulation tools.
Restart the computer on completion.
:::details Additional notes These notes are provided "for information only":
You can verify the NuttX installation by confirming the gcc version as shown:
:::
The following instructions explain how to set up a build toolchain for RasPi on Ubuntu 18.04.
To get the common dependencies for Raspberry Pi:
Run ubuntu.sh in a terminal to get just the common dependencies:
Then setup an cross-compiler (either GCC or clang) as described in the following sections.
Ubuntu software repository provides a set of pre-compiled toolchains. Note that Ubuntu Focal comes up with gcc-9-arm-linux-gnueabihf
as its default installation which is not fully supported, so we must manually install gcc-8-arm-linux-gnueabihf
and set it as the default toolchain. This guide also applies to earlier Ubuntu releases (Bionic). The following instruction assumes you haven't installed any version of arm-linux-gnueabihf, and will set up the default executable with update-alternatives
. Install them with the terminal command:
Set them as default:
If you want to build PX4 for ARM64 devices, this section is required.
First install GCC (needed to use clang).
We recommend you to get clang from the Ubuntu software repository, as shown below:
Example below for building PX4 firmware out of tree, using CMake.
Additional developer information for using PX4 on Raspberry Pi (including building PX4 natively) can be found here:
Generally speaking if you're working with hardware and don't need to modify PX4 itself, then you do not need a PX4 development environment (dependencies for working with ROS 2 are included and built into PX4 firmware by default).
Install PX4 without the simulator toolchain:
Run the ubuntu.sh the --no-sim-tools
(and optionally --no-nuttx
):
Acknowledge any prompts as the script progress.
Restart the computer on completion.
You may need to install the following additional dependencies:
If you're working with ROS "Melodic on Ubuntu 18.04:
Run the script:
You may need to acknowledge some prompts as the script progresses.
:::note
ROS Melodic is installed with Gazebo (Classic) 9 by default.
Your catkin (ROS build system) workspace is created at ~/catkin_ws/.
Once you have finished setting up the command-line toolchain:
:
:::note The environment setup scripts in the source usually work for recent PX4 releases. If working with an older version of PX4 you may need to . :::
If you want to use Gazebo on Ubuntu 20.04 you can add it manually. See .
You're going to need the PX4 source code anyway. But if you just wanted to set up the development environment without getting all the source code you could instead just download and and then run ubuntu.sh:
:::warning To build for Ubuntu 20.04 (focal) you must use docker (the GCC toolchain on Ubuntu 20.04 can build PX4, but the generated binary files are too new to run on actual Pi). For more information see . :::
Download and from the PX4 source repository (/Tools/setup/):
.
.
Information about ROS 2 setup and development with PX4 can be found in the .
You will need to install the normal development in order to work with the PX4 simulator.
This section explains how to install with PX4. ROS 1 full desktop builds come with Gazebo Classic, so normally you will not install PX4 simulator dependencies yourself!
If you're working with on Ubuntu 20.04:
:
Follow the (ros-noetic-desktop-full is recommended).
Intall MAVROS by following the .
Download the script in a bash shell:
The script uses instructions from the ROS Wiki "Melodic" . :::
Install (if you prefer using an IDE to the command line).
Install the :::tip The daily build includes development tools that hidden in release builds. It may also provide access to new PX4 features that are not yet supported in release builds. :::
Continue to the .