MacOS Setup
The following instructions set up a PX4 development environment for macOS. This environment can be used to build PX4 for:
Pixhawk and other NuttX-based hardware
:::details Apple M1 Macbook users! If you have an Apple M1 Macbook, make sure to run the terminal as x86 by setting up an x86 terminal:
Locate the Terminal application within the Utilities folder (Finder > Go menu > Utilities)
Select Terminal.app and right-click on it, then choose Duplicate.
Rename the duplicated Terminal app, e.g. to x86 Terminal
Now select the renamed x86 Terminal app and right-click and choose *Get Info
Check the box for Open using Rosetta, then close the window
Run the x86 Terminal` as usual, which will fully support the current PX4 toolchain :::
This setup is supported by the PX4 dev team. To build other targets you will need to use a different OS (or an unsupported development environment).
Video Guide
Homebrew Installation
The installation of Homebrew is quick and easy: installation instructions.
Enable more open files (Handle "LD: too many open files" error)
Create the ~/.zshenv
file or append it (by running open ~/.zshenv
on the terminal) and add this line:
Enforce Python Version
If not already existing, create the file ~/.zshrc
and add these lines:
Common Tools
After installing Homebrew, run these commands in your shell to install the common tools:
Install the required Python packages
Gazebo Simulation
First run the following commands:
September 2021: The commands above are a workaround to this bug: PX4-Autopilot#17644. They can be removed once it is fixed (along with this note).
To install SITL simulation with Gazebo:
jMAVSim Simulation
To use SITL simulation with jMAVSim you need to install a recent version of Java (e.g. Java 15). You can download Java 15 (or later) from Oracle or use the AdoptOpenJDK tap:
jMAVSim for PX4 v1.11 and beyond we require at least JDK 15.
For earlier versions macOS users might see the error Exception in thread "main" java.lang.UnsupportedClassVersionError:
. You can find the fix in the jMAVSim with SITL > Troubleshooting).
Next Steps
Once you have finished setting up the command-line toolchain:
Install VSCode (if you prefer using an IDE to the command line).
Install the QGroundControl Daily Build
The daily build includes development tools that are hidden in release builds. It may also provide access to new PX4 features that are not yet supported in release builds.
- Continue to the [build instructions](../dev_setup/building_px4.md).
Last updated