!REDIRECT “https://docs.px4.io/master/zh/dev_setup/dev_env_mac.html“
Mac 上的开发环境
MacOS 是受支持的 PX4 开发平台。 根据本文的指示构建的开发环境可以用编译:
- 基于 NuttX 的硬件 (Pixhawk等)
- jMAVSim 仿真模拟
- Gazebo Simulation
Note To build other targets see: Toolchain Installation > Supported Targets.
Tip A video tutorial can be found here: Setting up your PX4 development environment on macOS.
Homebrew Installation
The installation of Homebrew is quick and easy: installation instructions.
Enable more open files (Handle “LD: too many open files” error)
The PX4 toolchain requires the usage of the ZSH shell. If you are using the shell, add this line to your shell profile:
Create this file or append it: ~/.zshenv
and add this line:
ulimit -S -n 2048
Ensuring Python points to Homebrew
If not already existing, create the file ~/.zshrc
and add these lines:
# Point python to python 3 from Homebrew
alias python=/usr/local/bin/python3
# Point pip to python 3 pip
alias pip=/usr/local/bin/pip3
Common Tools
After installing Homebrew, run these commands in your shell to install the common tools:
brew tap PX4/px4
brew install px4-dev
Install the required Python packages
# install required packages using pip3
python3 -m pip install --user pyserial empy toml numpy pandas jinja2 pyyaml pyros-genmsg packaging
# if this fails with a permissions error, your Python install is in a system path - use this command instead:
sudo -H python3 -m pip install --user pyserial empy toml numpy pandas jinja2 pyyaml pyros-genmsg packaging
Gazebo Simulation
To install SITL simulation with Gazebo:
brew cask install xquartz
brew install px4-sim-gazebo
jMAVSim Simulation
To use SITL simulation with jMAVSim you need to install a recent version of Java (e.g. Java 14). You can either download Java 14 from Oracle or use the AdoptOpenJDK tap:
brew tap AdoptOpenJDK/openjdk
brew cask install adoptopenjdk14
brew install px4-sim-jmavsim
Note jMAVSim for PX4 v1.11 and earlier required Java 8.
Additional Tools
See Additional Tools for information about other useful development tools that are not part of the build toolchain (for example IDEs and GCSs).
Next Steps
Once you have finished setting up the environment, continue to the build instructions.