Skip to the content
FixTheRobot Explore Robotics / UAV / Module 6 / M6-L1

UAV Systems Engineering · M6-L1 · Hands-on lab (runs on your machine)

Install PX4

Get a working PX4 build environment, the foundation for every simulation lab that follows.

  • UAV Software and Flight-Controller Integration
  • Implementation-specific
  • About 60 minutes

What you will do

You will clone PX4-Autopilot, run its Ubuntu setup script, and build the SITL target. PX4 documents which Ubuntu releases and simulators are supported for each release: check the “Development environment” page of the PX4 documentation for your version first and follow it where it differs from the commands below, which reflect the documented flow for recent releases.

Before you start

  • A 64-bit Ubuntu machine, VM or container with at least 20 GB free disk and a few GB of RAM (check the PX4 docs for the supported Ubuntu version).
  • git, a stable internet connection and sudo rights for the setup script.
  • Lessons M6-T1 and M6-T3 (what PX4 is and its architecture) are recommended.

Steps

  1. Clone the repository with its submodules: git clone https://github.com/PX4/PX4-Autopilot.git --recursive.
  2. Run the setup script: bash ./PX4-Autopilot/Tools/setup/ubuntu.sh. It installs the toolchain and, by default, the simulator dependencies. Log out and back in (or reboot) when it tells you to.
  3. Check out the release tag you want to work with (git checkout v1.15.0 for example, or the tag you choose), then git submodule update --init --recursive. Record the tag: you will need it for px4_msgs.
  4. Build the SITL target: cd PX4-Autopilot && make px4_sitl.
git clone https://github.com/PX4/PX4-Autopilot.git --recursive
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh
cd PX4-Autopilot
git describe --tags            # note the version you are on
make px4_sitl                  # builds the SITL firmware (first build takes several minutes)
Documented flow for recent PX4 releases. Pin a release tag for reproducibility.

How to know it worked

  • make px4_sitl finishes without errors and the build directory build/px4_sitl_default exists.
  • You have written down the exact PX4 tag or commit and your Ubuntu version.
  • You can state which simulator your PX4 version uses by default (the next lab runs it).

If it does not work

Troubleshooting
SymptomLikely causeWhat to check
Setup script fails on dependenciesUnsupported Ubuntu release or missing sudoCompare with the supported releases in the PX4 documentation; use a supported version or container
Out of disk or memory during buildBuild needs several GBFree space; reduce parallel jobs
Submodule errorsInterrupted clone or wrong tagRun git submodule update --init --recursive on the checked-out tag
Python or CMake version errorsMixed system and user packagesUse the versions installed by the setup script; open a fresh shell after setup

References

Record your progress

Saved in this browser. This lab runs on your own machine, so the site cannot check it for you.