mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-06 11:40:05 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 09a9724222 | |||
| d4123a99fd | |||
| 2f7a755478 | |||
| 5c76d5bdd0 | |||
| 88374de5a6 | |||
| 56c4a2a76b |
+12
-31
@@ -6,9 +6,9 @@ set -e
|
||||
## Can also be used in docker.
|
||||
##
|
||||
## Installs:
|
||||
## - Common dependencies and tools for nuttx, jMAVSim, Gazebo
|
||||
## - Common dependencies and tools for nuttx, Gazebo
|
||||
## - NuttX toolchain (omit with arg: --no-nuttx)
|
||||
## - jMAVSim and Gazebo9 simulator (omit with arg: --no-sim-tools)
|
||||
## - Gazebo Harmonic simulator (omit with arg: --no-sim-tools)
|
||||
##
|
||||
|
||||
INSTALL_NUTTX="true"
|
||||
@@ -207,37 +207,18 @@ if [[ $INSTALL_SIM == "true" ]]; then
|
||||
bc \
|
||||
;
|
||||
|
||||
# Gazebo / Gazebo classic installation
|
||||
if [[ "${UBUNTU_RELEASE}" == "18.04" || "${UBUNTU_RELEASE}" == "20.04" ]]; then
|
||||
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
|
||||
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
|
||||
# Update list, since new gazebo-stable.list has been added
|
||||
sudo apt-get update -y --quiet
|
||||
# Gazebo Harmonic installation (Ubuntu 22.04+)
|
||||
echo "[ubuntu.sh] Gazebo (Harmonic) will be installed"
|
||||
# Add Gazebo binary repository
|
||||
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
|
||||
sudo apt-get update -y --quiet
|
||||
|
||||
# Install Gazebo classic
|
||||
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
|
||||
gazebo_classic_version=9
|
||||
gazebo_packages="gazebo$gazebo_classic_version libgazebo$gazebo_classic_version-dev"
|
||||
else
|
||||
# default and Ubuntu 20.04
|
||||
gazebo_classic_version=11
|
||||
gazebo_packages="gazebo$gazebo_classic_version libgazebo$gazebo_classic_version-dev"
|
||||
fi
|
||||
else
|
||||
# Expects Ubuntu 22.04 > by default
|
||||
echo "[ubuntu.sh] Gazebo (Harmonic) will be installed"
|
||||
echo "[ubuntu.sh] Earlier versions will be removed"
|
||||
# Add Gazebo binary repository
|
||||
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
|
||||
sudo apt-get update -y --quiet
|
||||
# Install Gazebo
|
||||
gazebo_packages="gz-harmonic libunwind-dev"
|
||||
|
||||
# Install Gazebo
|
||||
gazebo_packages="gz-harmonic libunwind-dev"
|
||||
|
||||
if [[ "${UBUNTU_RELEASE}" == "24.04" ]]; then
|
||||
gazebo_packages="$gazebo_packages cppzmq-dev"
|
||||
fi
|
||||
if [[ "${UBUNTU_RELEASE}" == "24.04" ]]; then
|
||||
gazebo_packages="$gazebo_packages cppzmq-dev"
|
||||
fi
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
|
||||
@@ -39,15 +39,6 @@ Navigate into the **PX4-Autopilot** directory and start [Gazebo SITL](../sim_gaz
|
||||
make px4_sitl gz_x500
|
||||
```
|
||||
|
||||
::: details If you installed Gazebo Classic
|
||||
Start [Gazebo Classic SITL](../sim_gazebo_classic/index.md) using the following command:
|
||||
|
||||
```sh
|
||||
make px4_sitl gazebo-classic
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
This will bring up the PX4 console:
|
||||
|
||||

|
||||
@@ -88,6 +79,16 @@ cd PX4-Autopilot
|
||||
make px4_fmu-v5_default
|
||||
```
|
||||
|
||||
:::tip
|
||||
You can also build using the [px4-dev Docker container](../test_and_ci/docker.md) without installing the toolchain locally.
|
||||
From the PX4-Autopilot directory:
|
||||
|
||||
```sh
|
||||
./Tools/docker_run.sh 'make px4_fmu-v5_default'
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
A successful run will end with similar output to:
|
||||
|
||||
```sh
|
||||
@@ -126,7 +127,7 @@ The following list shows the build commands for the [Pixhawk standard](../flight
|
||||
- [Pixhawk 1 (FMUv2)](../flight_controller/pixhawk.md): `make px4_fmu-v2_default`
|
||||
|
||||
:::warning
|
||||
You **must** use a supported version of GCC to build this board (e.g. the same as used by [CI/docker](../test_and_ci/docker.md)) or remove modules from the build. Building with an unsupported GCC may fail, as PX4 is close to the board's 1MB flash limit.
|
||||
You **must** use a supported version of GCC to build this board (e.g. the `gcc-arm-none-eabi` package from the current Ubuntu LTS, which is the same toolchain used by CI) or remove modules from the build. Building with an unsupported GCC may fail, as PX4 is close to the board's 1MB flash limit.
|
||||
:::
|
||||
|
||||
- Pixhawk 1 with 2 MB flash: `make px4_fmu-v3_default`
|
||||
@@ -191,7 +192,7 @@ The `region 'flash' overflowed by XXXX bytes` error indicates that the firmware
|
||||
This is common for `make px4_fmu-v2_default` builds, where the flash size is limited to 1MB.
|
||||
|
||||
If you're building the _vanilla_ master branch, the most likely cause is using an unsupported version of GCC.
|
||||
In this case, install the version specified in the [Developer Toolchain](../dev_setup/dev_env.md) instructions.
|
||||
In this case, install the `gcc-arm-none-eabi` package from the current Ubuntu LTS as described in the [Developer Toolchain](../dev_setup/dev_env.md) instructions.
|
||||
|
||||
If building your own branch, it is possible that you have increased the firmware size over the 1MB limit.
|
||||
In this case you will need to remove any drivers/modules that you don't need from the build.
|
||||
@@ -204,7 +205,7 @@ The PX4 build system opens a large number of files, so you may exceed this numbe
|
||||
The build toolchain will then report `Too many open files` for many files, as shown below:
|
||||
|
||||
```sh
|
||||
/usr/local/Cellar/gcc-arm-none-eabi/20171218/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld: cannot find NuttX/nuttx/fs/libfs.a: Too many open files
|
||||
arm-none-eabi-ld: cannot find NuttX/nuttx/fs/libfs.a: Too many open files
|
||||
```
|
||||
|
||||
The solution is to increase the maximum allowed number of open files (e.g. to 300).
|
||||
@@ -227,31 +228,6 @@ xcode-select --install
|
||||
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
|
||||
```
|
||||
|
||||
### Ubuntu 18.04: Compile errors involving arm_none_eabi_gcc
|
||||
|
||||
Build issues related to `arm_none_eabi_gcc`may be due to a broken g++ toolchain installation.
|
||||
You can verify that this is the case by checking for missing dependencies using:
|
||||
|
||||
```sh
|
||||
arm-none-eabi-gcc --version
|
||||
arm-none-eabi-g++ --version
|
||||
arm-none-eabi-gdb --version
|
||||
arm-none-eabi-size --version
|
||||
```
|
||||
|
||||
Example of bash output with missing dependencies:
|
||||
|
||||
```sh
|
||||
arm-none-eabi-gdb --version
|
||||
arm-none-eabi-gdb: command not found
|
||||
```
|
||||
|
||||
This can be resolved by removing and [reinstalling the compiler](https://askubuntu.com/questions/1243252/how-to-install-arm-none-eabi-gdb-on-ubuntu-20-04-lts-focal-fossa).
|
||||
|
||||
### Ubuntu 18.04: Visual Studio Code is unable to watch for file changes in this large workspace
|
||||
|
||||
See [Visual Studio Code IDE (VSCode) > Troubleshooting](../dev_setup/vscode.md#troubleshooting).
|
||||
|
||||
### Failed to import Python packages
|
||||
|
||||
"Failed to import" errors when running the `make px4_sitl jmavsim` command indicates that some Python packages are not installed (where expected).
|
||||
|
||||
@@ -39,8 +39,9 @@ You may want to also install `python-pip` and `screen`.
|
||||
Execute the script below to install GCC 7-2017-q4:
|
||||
|
||||
:::warning
|
||||
This version of GCC is out of date.
|
||||
At time of writing the current version on Ubuntu is `9-2020-q2-update` (see [focal nuttx docker file](https://github.com/PX4/PX4-containers/blob/master/docker/Dockerfile_nuttx-focal#L28))
|
||||
This version of GCC is very outdated.
|
||||
PX4 now uses the `gcc-arm-none-eabi` package from the current Ubuntu LTS (GCC 13.2.1 on Ubuntu 24.04).
|
||||
This CentOS guide is community-maintained and may not produce working builds.
|
||||
:::
|
||||
|
||||
```sh
|
||||
|
||||
@@ -4,20 +4,14 @@ The following instructions use a bash script to set up the PX4 development envir
|
||||
|
||||
The environment includes:
|
||||
|
||||
- [Gazebo Simulator](../sim_gazebo_gz/index.md) ("Harmonic")
|
||||
- [Build toolchain for Pixhawk (and other NuttX-based hardware)](../dev_setup/building_px4.md#nuttx-pixhawk-based-boards).
|
||||
|
||||
On Ubuntu 22.04:
|
||||
|
||||
- [Gazebo Classic Simulator](../sim_gazebo_classic/index.md) can be used instead of Gazebo.
|
||||
Gazebo is nearing feature-parity with Gazebo-Classic on PX4, and will soon replace it for all use cases.
|
||||
- [Gazebo Simulator](../sim_gazebo_gz/index.md) (Gazebo Harmonic)
|
||||
- [Build toolchain for Pixhawk (and other NuttX-based hardware)](../dev_setup/building_px4.md#nuttx-pixhawk-based-boards) using the `gcc-arm-none-eabi` compiler from the Ubuntu package manager.
|
||||
|
||||
The build toolchain for other flight controllers, simulators, and working with ROS are discussed in the [Other Targets](#other-targets) section below.
|
||||
|
||||
::: details Can I use an older version of Ubuntu?
|
||||
PX4 supports the current and last Ubuntu LTS release where possible.
|
||||
Older releases are not supported (so you can't raise defects against them), but may still work.
|
||||
For example, Gazebo Classic setup is included in our standard build instructions for macOS, Ubuntu 18.04 and 20.04, and Windows on WSL2 for the same hosts.
|
||||
:::info
|
||||
PX4 targets the **current Ubuntu LTS** (24.04) for CI and release builds, with the **previous LTS** (22.04) also supported.
|
||||
Older Ubuntu versions are not supported and may not work.
|
||||
:::
|
||||
|
||||
## Simulation and NuttX (Pixhawk) Targets
|
||||
@@ -50,19 +44,18 @@ To install the toolchain:
|
||||
- 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.
|
||||
|
||||
3. If you need Gazebo Classic (Ubuntu 22.04 only) then you can manually remove Gazebo and install it by following the instructions in [Gazebo Classic > Installation](../sim_gazebo_classic/index.md#installation).
|
||||
|
||||
4. Restart the computer on completion.
|
||||
3. Restart the computer on completion.
|
||||
|
||||
:::details Additional notes
|
||||
These notes are provided "for information only":
|
||||
|
||||
- This setup is supported by the PX4 Dev Team.
|
||||
The instructions may also work on other Debian Linux based systems.
|
||||
- You can verify the NuttX installation by confirming the `gcc` version as shown:
|
||||
- You can verify the NuttX installation by confirming `gcc` is available.
|
||||
The version depends on your Ubuntu release (e.g. GCC 13.2.1 on Ubuntu 24.04):
|
||||
|
||||
```sh
|
||||
$arm-none-eabi-gcc --version
|
||||
$ arm-none-eabi-gcc --version
|
||||
|
||||
arm-none-eabi-gcc (15:13.2.rel1-2) 13.2.1 20231009
|
||||
Copyright (C) 2023 Free Software Foundation, Inc.
|
||||
|
||||
@@ -124,10 +124,10 @@ Once that is done you don't need to do anything else; the toolchain will automat
|
||||
|
||||
This section includes guidance on setup and build errors.
|
||||
|
||||
### Ubuntu 18.04: "Visual Studio Code is unable to watch for file changes in this large workspace"
|
||||
### "Visual Studio Code is unable to watch for file changes in this large workspace"
|
||||
|
||||
This error surfaces on startup.
|
||||
On some systems, there is an upper-limit of 8192 file handles imposed on applications, which means that VSCode might not be able to detect file modifications in `/PX4-Autopilot`.
|
||||
On some systems, there is an upper-limit on file handles imposed on applications, which means that VSCode might not be able to detect file modifications in `/PX4-Autopilot`.
|
||||
|
||||
You can increase this limit to avoid the error, at the expense of memory consumption.
|
||||
Follow the [instructions here](https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc).
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
# PX4 Docker Containers
|
||||
|
||||
Docker containers are provided for the complete [PX4 development toolchain](../dev_setup/dev_env.md#supported-targets) including NuttX and Linux based hardware, [Gazebo Classic](../sim_gazebo_classic/index.md) simulation, and [ROS](../simulation/ros_interface.md).
|
||||
Docker containers are provided for the complete [PX4 development toolchain](../dev_setup/dev_env.md#supported-targets) including NuttX and Linux based hardware, [Gazebo](../sim_gazebo_gz/index.md) simulation, and [ROS 2](../ros2/user_guide.md).
|
||||
|
||||
This topic shows how to use the [available docker containers](#px4_containers) to access the build environment in a local Linux computer.
|
||||
|
||||
::: info
|
||||
Dockerfiles and README can be found on [Github here](https://github.com/PX4/PX4-containers/tree/master?tab=readme-ov-file#container-hierarchy).
|
||||
They are built automatically on [Docker Hub](https://hub.docker.com/u/px4io/).
|
||||
The recommended `px4-dev` container is built from the [Dockerfile in the PX4-Autopilot source tree](https://github.com/PX4/PX4-Autopilot/blob/main/Tools/setup/Dockerfile) by the [Container build workflow](https://github.com/PX4/PX4-Autopilot/actions/workflows/dev_container.yml).
|
||||
:::
|
||||
|
||||
## Prerequisites
|
||||
@@ -35,33 +34,36 @@ sudo usermod -aG docker $USER
|
||||
# Log in/out again before using docker!
|
||||
```
|
||||
|
||||
## Container Hierarchy {#px4_containers}
|
||||
## px4-dev Container (Recommended) {#px4_containers}
|
||||
|
||||
The available containers are on [GitHub here](https://github.com/PX4/PX4-containers/tree/master?tab=readme-ov-file#container-hierarchy).
|
||||
The **`px4-dev`** container is the recommended container for building PX4 firmware.
|
||||
It is a single, multi-architecture container (linux/amd64 and linux/arm64) based on Ubuntu 24.04 that includes everything needed to build PX4 for NuttX hardware targets.
|
||||
|
||||
These allow testing of various build targets and configurations (the included tools can be inferred from their names).
|
||||
The containers are hierarchical, such that containers have the functionality of their parents.
|
||||
For example, the partial hierarchy below shows that the docker container with NuttX build tools (`px4-dev-nuttx-focal`) does not include ROS 2, while the simulation containers do:
|
||||
It is published to both registries simultaneously:
|
||||
|
||||
```plain
|
||||
- px4io/px4-dev-base-focal
|
||||
- px4io/px4-dev-nuttx-focal
|
||||
- px4io/px4-dev-simulation-focal
|
||||
- px4io/px4-dev-ros-noetic
|
||||
- px4io/px4-dev-ros2-foxy
|
||||
- px4io/px4-dev-ros2-rolling
|
||||
- px4io/px4-dev-base-jammy
|
||||
- px4io/px4-dev-nuttx-jammy
|
||||
```
|
||||
- **GitHub Container Registry:** [ghcr.io/px4/px4-dev](https://github.com/PX4/PX4-Autopilot/pkgs/container/px4-dev)
|
||||
- **Docker Hub:** [px4io/px4-dev](https://hub.docker.com/r/px4io/px4-dev)
|
||||
|
||||
The most recent version can be accessed using the `latest` tag: `px4io/px4-dev-nuttx-focal:latest`
|
||||
(available tags are listed for each container on _hub.docker.com_.
|
||||
For example, the `px4io/px4-dev-nuttx-focal` tags can be found on [hub.docker.com here](https://hub.docker.com/r/px4io/px4-dev-nuttx-focal/tags?page=1&ordering=last_updated)).
|
||||
The container includes:
|
||||
|
||||
- Ubuntu 24.04 base
|
||||
- ARM cross-compiler (`gcc-arm-none-eabi`) and Xtensa compiler (for ESP32 targets)
|
||||
- Build tools: `cmake`, `ninja`, `ccache`, `make`
|
||||
- Python 3 with PX4 build dependencies
|
||||
- NuttX toolchain libraries (`libnewlib-arm-none-eabi`, etc.)
|
||||
|
||||
The container is built from the [Dockerfile](https://github.com/PX4/PX4-Autopilot/blob/main/Tools/setup/Dockerfile) in the PX4 source tree using the [Container build workflow](https://github.com/PX4/PX4-Autopilot/actions/workflows/dev_container.yml).
|
||||
Images are tagged with the PX4 version (e.g. `px4io/px4-dev:v1.16.0`).
|
||||
|
||||
:::tip
|
||||
Typically you should use a recent container, but not necessarily the `latest` (as this changes too often).
|
||||
A `px4-sim` container with simulation tools (Gazebo Harmonic) is planned to complement `px4-dev` for simulation workflows.
|
||||
:::
|
||||
|
||||
### Legacy Containers
|
||||
|
||||
The older per-distro containers from [PX4/PX4-containers](https://github.com/PX4/PX4-containers) (e.g. `px4-dev-nuttx-jammy`, `px4-dev-ros2-humble`, etc.) are no longer recommended.
|
||||
They will be replaced by `px4-dev` (for builds) and the upcoming `px4-sim` (for simulation).
|
||||
|
||||
## Use the Docker Container
|
||||
|
||||
The following instructions show how to build PX4 source code on the host computer using a toolchain running in a docker container.
|
||||
@@ -121,7 +123,7 @@ Where,
|
||||
- `<host_src>`: The host computer directory to be mapped to `<container_src>` in the container. This should normally be the **PX4-Autopilot** directory.
|
||||
- `<container_src>`: The location of the shared (source) directory when inside the container.
|
||||
- `<local_container_name>`: A name for the docker container being created. This can later be used if we need to reference the container again.
|
||||
- `<container>:<tag>`: The container with version tag to start - e.g.: `px4io/px4-dev-ros:2017-10-23`.
|
||||
- `<container>:<tag>`: The container with version tag to start - e.g.: `px4io/px4-dev:v1.16.0`.
|
||||
- `<build_command>`: The command to invoke on the new container. E.g. `bash` is used to open a bash shell in the container.
|
||||
|
||||
The concrete example below shows how to open a bash shell and share the directory **~/src/PX4-Autopilot** on the host computer.
|
||||
@@ -137,7 +139,7 @@ docker run -it --privileged \
|
||||
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
|
||||
-e DISPLAY=:0 \
|
||||
--network host \
|
||||
--name=px4-ros px4io/px4-dev-ros2-foxy:2022-07-31 bash
|
||||
--name=px4-dev px4io/px4-dev:v1.16.0 bash
|
||||
```
|
||||
|
||||
::: info
|
||||
@@ -155,7 +157,7 @@ Verify if everything works by running, for example, SITL:
|
||||
|
||||
```sh
|
||||
cd src/PX4-Autopilot #This is <container_src>
|
||||
make px4_sitl_default gazebo-classic
|
||||
make px4_sitl gz_x500
|
||||
```
|
||||
|
||||
### Re-enter the Container
|
||||
@@ -219,7 +221,7 @@ This ensures that all files created within the container will be accessible on t
|
||||
|
||||
#### Graphics Driver Issues
|
||||
|
||||
It's possible that running Gazebo Classic will result in a similar error message like the following:
|
||||
It's possible that running Gazebo will result in a similar error message like the following:
|
||||
|
||||
```sh
|
||||
libGL error: failed to load driver: swrast
|
||||
@@ -239,7 +241,7 @@ Any recent Linux distribution should work.
|
||||
|
||||
The following configuration is tested:
|
||||
|
||||
- OS X with VMWare Fusion and Ubuntu 14.04 (Docker container with GUI support on Parallels make the X-Server crash).
|
||||
- OS X with VMWare Fusion and Ubuntu 22.04 (Docker container with GUI support on Parallels make the X-Server crash).
|
||||
|
||||
**Memory**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user