mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-09-24 19:08:21 +08:00
feat(containers): add development container with ROS 2 and Gazebo
Signed-off-by: Beniamino Pozzan <beniamino.pozzan@gmail.com>
This commit is contained in:
committed by
Ramon Roche
parent
9300113ada
commit
cc09df637f
@@ -1,11 +1,13 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Build ROS independently of the changing SIH/Gazebo firmware package.
|
||||
ARG ROS_DISTRO=jazzy
|
||||
ARG INCLUDE_GAZEBO=0
|
||||
FROM ubuntu:22.04 AS ros2-base-humble
|
||||
FROM ubuntu:24.04 AS ros2-base-jazzy
|
||||
FROM ros2-base-${ROS_DISTRO} AS ros2-base
|
||||
|
||||
ARG ROS_DISTRO
|
||||
ARG INCLUDE_GAZEBO
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV ROS_DISTRO=${ROS_DISTRO}
|
||||
ENV LANG=C.UTF-8
|
||||
@@ -18,7 +20,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
--mount=type=bind,source=setup,target=/px4-setup \
|
||||
--mount=type=bind,source=ros2-install-dependencies.sh,target=/ros2-install-dependencies.sh \
|
||||
bash /ros2-install-dependencies.sh
|
||||
bash /ros2-install-dependencies.sh ${INCLUDE_GAZEBO}
|
||||
|
||||
# Keep ROS libraries intact and statically link the same pinned, private
|
||||
# Fast DDS/CDR dependencies into the Agent on both distributions.
|
||||
@@ -131,12 +133,13 @@ ENV RUNS_IN_DOCKER=true
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
ARG ROS_APT_SOURCE_VERSION=1.2.0
|
||||
ARG INCLUDE_GAZEBO=0
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
--mount=type=bind,source=setup,target=/px4-setup \
|
||||
--mount=type=bind,source=ros2-install-dependencies.sh,target=/ros2-install-dependencies.sh \
|
||||
--mount=type=bind,from=ros2-sources,source=/opt/px4_ros2/src,target=/opt/px4_ros2/src \
|
||||
bash /ros2-install-dependencies.sh /opt/px4_ros2/src
|
||||
bash /ros2-install-dependencies.sh ${INCLUDE_GAZEBO} /opt/px4_ros2/src
|
||||
|
||||
# Copy only the staged Agent/logger install, never the builder's pip packages.
|
||||
COPY --from=agent /opt/agent-install/usr/local/ /usr/local/
|
||||
|
||||
@@ -76,3 +76,17 @@ target "ros2-dev" {
|
||||
cache-from = CACHE_GHA ? ["type=gha,scope=ros2-dev-${ROS_DISTRO}-${ARCH}"] : []
|
||||
cache-to = CACHE_GHA ? ["type=gha,mode=max,scope=ros2-dev-${ROS_DISTRO}-${ARCH}"] : []
|
||||
}
|
||||
|
||||
target "ros2-gazebo-dev" {
|
||||
context = "docker-context"
|
||||
platforms = ["linux/${ARCH}"]
|
||||
dockerfile = "Dockerfile.ros2"
|
||||
target = "ros2-dev"
|
||||
args = {
|
||||
ROS_DISTRO = ROS_DISTRO
|
||||
INCLUDE_GAZEBO = 1
|
||||
}
|
||||
tags = ["px4io/px4-dev-ros2-gazebo:main-${ROS_DISTRO}-${ARCH}", "ghcr.io/px4/px4-dev-ros2-gazebo:main-${ROS_DISTRO}-${ARCH}"]
|
||||
cache-from = CACHE_GHA ? ["type=gha,scope=ros2-gazebo-dev-${ROS_DISTRO}-${ARCH}"] : []
|
||||
cache-to = CACHE_GHA ? ["type=gha,mode=max,scope=ros2-gazebo-dev-${ROS_DISTRO}-${ARCH}"] : []
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
INCLUDE_SIM_TOOLS=${1:-0}
|
||||
|
||||
source /etc/os-release
|
||||
case "${VERSION_CODENAME}:${ROS_DISTRO}" in
|
||||
jammy:humble|noble:jazzy) ;;
|
||||
@@ -34,15 +36,20 @@ for dist in distributions():
|
||||
continue
|
||||
print(f"{dist.metadata['Name']}=={dist.version}")
|
||||
PY
|
||||
if [ "${INCLUDE_SIM_TOOLS}" -eq 0 ]; then
|
||||
extra_args="--no-sim-tools"
|
||||
else
|
||||
extra_args=""
|
||||
fi
|
||||
RUNS_IN_DOCKER=true PIP_CONSTRAINT=/px4-python-constraints.txt PIP_NO_CACHE_DIR=1 \
|
||||
bash /px4-setup/ubuntu.sh --no-nuttx --no-sim-tools
|
||||
bash /px4-setup/ubuntu.sh --no-nuttx ${extra_args}
|
||||
rm /px4-python-constraints.txt
|
||||
|
||||
rosdep init
|
||||
rosdep update --rosdistro "${ROS_DISTRO}"
|
||||
if [ "$#" -gt 0 ]; then
|
||||
if [ "$#" -gt 1 ]; then
|
||||
# ROS setup scripts are not nounset-safe.
|
||||
set +u
|
||||
source "/opt/ros/${ROS_DISTRO}/setup.bash"
|
||||
rosdep install --from-paths "$1" --ignore-src --rosdistro "${ROS_DISTRO}" -y
|
||||
rosdep install --from-paths "$2" --ignore-src --rosdistro "${ROS_DISTRO}" -y
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user