init commit

This commit is contained in:
EricX-Zhao
2026-02-11 17:54:06 +03:00
commit c15a3552ae
18 changed files with 1593 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
FROM ubuntu:22.04 AS cc_base
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
build-essential \
wget \
git \
python3 \
software-properties-common \
curl \
pkg-config \
vim \
&& add-apt-repository universe \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
RUN apt update && apt install -y \
python3-flake8-blind-except \
python3-flake8-class-newline \
python3-flake8-deprecated \
python3-mypy \
python3-pip \
python3-future \
python3-pytest \
python3-pytest-cov \
python3-pytest-mock \
python3-pytest-repeat \
python3-pytest-rerunfailures \
python3-pytest-runner \
python3-pytest-timeout \
python3-future \
python3-argcomplete \
autoconf automake libtool patchelf ninja-build python3.10-venv \
ros-dev-tools
+5
View File
@@ -0,0 +1,5 @@
# Build Cross Compiled Develop Image
```bash
PLATFORM=rk3588 docker compose build
```
+44
View File
@@ -0,0 +1,44 @@
#
services:
# 第一步:编译基础镜像
cc-base:
build:
context: .
dockerfile: Dockerfile.cc_base
image: cc-base:latest
# 第二步:编译针对 RK3588 的镜像
cc-platform:
build:
context: . # 上下文设为根目录,这样才能同时访问 rk3588 文件夹
dockerfile: ${PLATFORM}/Dockerfile.cc_${PLATFORM}
args:
- BASE_TAG=latest
image: cc-${PLATFORM}:latest
depends_on:
- cc-base
# 第三步:编译最终的供应商包镜像
vendor_packages:
build:
context: .
dockerfile: vendor_packages/Dockerfile.vendor_packages
args:
- BASE_IMAGE=cc-${PLATFORM}:latest
image: vendor-packages:${PLATFORM}
depends_on:
- cc-platform
ros2:
build:
context: .
dockerfile: ros2/Dockerfile.ros_${ROS_DISTRO}
args:
- ROS_DISTRO=rolling
- PLATFORM=${PLATFORM}
- CC_PLATFORM_IMAGE=cc-${PLATFORM}:latest
- VENDOR_PACKAGES=vendor-packages:${PLATFORM}
image: cc-ros-${ROS_DISTRO}:${PLATFORM}
depends_on:
- vendor_packages
+16
View File
@@ -0,0 +1,16 @@
FROM cc-base:latest as cc_rk3588
WORKDIR /opt
COPY rk3588/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.gz /opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.gz
RUN tar -zxf gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.gz \
&& rm /opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.gz
COPY rk3588/rk3588.toolchain.cmake /opt/cmake/
ENV PATH="/opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin:${PATH}"
ENV CC_TOOLCHAIN_FILE=/opt/cmake/rk3588.toolchain.cmake
ENV TARGET_SYSROOT=/opt/rk3588
WORKDIR /root
@@ -0,0 +1,31 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(SYSROOT /opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu)
set(CMAKE_SYSROOT
${SYSROOT}/aarch64-none-linux-gnu/libc
)
set(CMAKE_C_COMPILER ${SYSROOT}/bin/aarch64-none-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${SYSROOT}/bin/aarch64-none-linux-gnu-g++)
list(APPEND CMAKE_FIND_ROOT_PATH
$ENV{TARGET_SYSROOT}
${CMAKE_INSTALL_PREFIX}
)
# Set compile flags which are overwritter by android.toolchain.cmake
# set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG -Wno-error=unused-variable")
# set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -Wno-error=unused-variable")
# add_link_options("LINKER:-rpath-link,$ENV{TARGET_SYSROOT}/lib")
set(Python3_EXECUTABLE /usr/bin/python3)
set(Python3_NumPy_INCLUDE_DIR $ENV{TARGET_SYSROOT}/lib/python3.10/site-packages/numpy/core/include)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+20
View File
@@ -0,0 +1,20 @@
ARG CC_PLATFORM_IMAGE
ARG VENDOR_PACKAGES
ARG PLATFORM
FROM ${CC_PLATFORM_IMAGE} as ros_src
ARG ROS_DISTRO
WORKDIR /workspace
RUN mkdir -p /workspace/src
COPY ros2/ros_rolling.repos .
RUN vcs import --input ros_${ROS_DISTRO}.repos src
RUN echo "Build ros ${ROS_DISTRO}"
FROM vendor-packages:${PLATFORM} AS vendor_images
FROM ${CC_PLATFORM_IMAGE} as ros_builder
COPY --from=ros_src /workspace /workspace
COPY --from=vendor_images ${TARGET_SYSROOT} ${TARGET_SYSROOT}
+417
View File
@@ -0,0 +1,417 @@
repositories:
ament/ament_cmake:
type: git
url: https://github.com/ament/ament_cmake.git
version: rolling
ament/ament_index:
type: git
url: https://github.com/ament/ament_index.git
version: rolling
ament/ament_lint:
type: git
url: https://github.com/ament/ament_lint.git
version: rolling
ament/ament_package:
type: git
url: https://github.com/ament/ament_package.git
version: rolling
ament/google_benchmark_vendor:
type: git
url: https://github.com/ament/google_benchmark_vendor.git
version: rolling
ament/googletest:
type: git
url: https://github.com/ament/googletest.git
version: rolling
diagnostics:
type: git
url: https://github.com/ros/diagnostics.git
version: ros2
eProsima/Fast-CDR:
type: git
url: https://github.com/eProsima/Fast-CDR.git
version: 2.3.x
eProsima/Fast-DDS:
type: git
url: https://github.com/eProsima/Fast-DDS.git
version: 3.4.x
eProsima/foonathan_memory_vendor:
type: git
url: https://github.com/eProsima/foonathan_memory_vendor.git
version: master
ffmpeg_image_transport_msgs:
type: git
url: https://github.com/ros-misc-utilities/ffmpeg_image_transport_msgs.git
version: rolling
ros-perception/image_transport_plugins:
type: git
url: https://github.com/ros-perception/image_transport_plugins.git
version: rolling
osrf/osrf_pycommon:
type: git
url: https://github.com/osrf/osrf_pycommon.git
version: master
osrf/osrf_testing_tools_cpp:
type: git
url: https://github.com/osrf/osrf_testing_tools_cpp.git
version: rolling
ros-perception/pcl_msgs:
type: git
url: https://github.com/ros-perception/pcl_msgs.git
version: ros2
ros-perception/image_common:
type: git
url: https://github.com/ros-perception/image_common.git
version: rolling
ros-perception/laser_geometry:
type: git
url: https://github.com/ros-perception/laser_geometry.git
version: rolling
ros-perception/perception_pcl:
type: git
url: https://github.com/ros-perception/perception_pcl.git
version: ros2
ros-perception/point_cloud_transport:
type: git
url: https://github.com/ros-perception/point_cloud_transport.git
version: rolling
ros-planning/navigation_msgs:
type: git
url: https://github.com/ros-planning/navigation_msgs.git
version: rolling
ros-tooling/keyboard_handler:
type: git
url: https://github.com/ros-tooling/keyboard_handler.git
version: rolling
ros-tooling/libstatistics_collector:
type: git
url: https://github.com/ros-tooling/libstatistics_collector.git
version: rolling
ros-visualization/interactive_markers:
type: git
url: https://github.com/ros-visualization/interactive_markers.git
version: rolling
ros-visualization/python_qt_binding:
type: git
url: https://github.com/ros-visualization/python_qt_binding.git
version: rolling
ros-visualization/qt_gui_core:
type: git
url: https://github.com/ros-visualization/qt_gui_core.git
version: rolling
ros-visualization/rqt:
type: git
url: https://github.com/ros-visualization/rqt.git
version: rolling
ros-visualization/rqt_action:
type: git
url: https://github.com/ros-visualization/rqt_action.git
version: rolling
ros-visualization/rqt_bag:
type: git
url: https://github.com/ros-visualization/rqt_bag.git
version: rolling
ros-visualization/rqt_console:
type: git
url: https://github.com/ros-visualization/rqt_console.git
version: rolling
ros-visualization/rqt_graph:
type: git
url: https://github.com/ros-visualization/rqt_graph.git
version: rolling
ros-visualization/rqt_msg:
type: git
url: https://github.com/ros-visualization/rqt_msg.git
version: rolling
ros-visualization/rqt_plot:
type: git
url: https://github.com/ros-visualization/rqt_plot.git
version: rolling
ros-visualization/rqt_publisher:
type: git
url: https://github.com/ros-visualization/rqt_publisher.git
version: rolling
ros-visualization/rqt_py_console:
type: git
url: https://github.com/ros-visualization/rqt_py_console.git
version: rolling
ros-visualization/rqt_reconfigure:
type: git
url: https://github.com/ros-visualization/rqt_reconfigure.git
version: rolling
ros-visualization/rqt_service_caller:
type: git
url: https://github.com/ros-visualization/rqt_service_caller.git
version: rolling
ros-visualization/rqt_shell:
type: git
url: https://github.com/ros-visualization/rqt_shell.git
version: rolling
ros-visualization/rqt_srv:
type: git
url: https://github.com/ros-visualization/rqt_srv.git
version: rolling
ros-visualization/rqt_topic:
type: git
url: https://github.com/ros-visualization/rqt_topic.git
version: rolling
ros-visualization/tango_icons_vendor:
type: git
url: https://github.com/ros-visualization/tango_icons_vendor.git
version: rolling
ros/class_loader:
type: git
url: https://github.com/ros/class_loader.git
version: rolling
ros/kdl_parser:
type: git
url: https://github.com/ros/kdl_parser.git
version: rolling
ros/pluginlib:
type: git
url: https://github.com/ros/pluginlib.git
version: rolling
ros/resource_retriever:
type: git
url: https://github.com/ros/resource_retriever.git
version: rolling
ros/robot_state_publisher:
type: git
url: https://github.com/ros/robot_state_publisher.git
version: rolling
ros/ros_environment:
type: git
url: https://github.com/ros/ros_environment.git
version: rolling
ros/ros_tutorials:
type: git
url: https://github.com/ros/ros_tutorials.git
version: rolling
ros/urdfdom:
type: git
url: https://github.com/ros/urdfdom.git
version: rolling
ros/urdfdom_headers:
type: git
url: https://github.com/ros/urdfdom_headers.git
version: rolling
ros/eigen_stl_containers:
type: git
url: https://github.com/ros/eigen_stl_containers.git
version: ros2
ros/angles:
type: git
url: https://github.com/ros/angles.git
version: ros2
ros-geographic-info:
type: git
url: https://github.com/ros-geographic-info/geographic_info.git
version: ros2
ros2/ament_cmake_ros:
type: git
url: https://github.com/ros2/ament_cmake_ros.git
version: rolling
ros2/common_interfaces:
type: git
url: https://github.com/ros2/common_interfaces.git
version: rolling
ros2/demos:
type: git
url: https://github.com/ros2/demos.git
version: rolling
ros2/eigen3_cmake_module:
type: git
url: https://github.com/ros2/eigen3_cmake_module.git
version: rolling
ros2/example_interfaces:
type: git
url: https://github.com/ros2/example_interfaces.git
version: rolling
ros2/examples:
type: git
url: https://github.com/ros2/examples.git
version: rolling
ros2/geometry2:
type: git
url: https://github.com/ros2/geometry2.git
version: rolling
ros2/launch:
type: git
url: https://github.com/ros2/launch.git
version: rolling
ros2/launch_ros:
type: git
url: https://github.com/ros2/launch_ros.git
version: rolling
ros2/message_filters:
type: git
url: https://github.com/ros2/message_filters.git
version: rolling
ros2/performance_test_fixture:
type: git
url: https://github.com/ros2/performance_test_fixture.git
version: rolling
ros2/python_cmake_module:
type: git
url: https://github.com/ros2/python_cmake_module.git
version: rolling
ros2/rcl:
type: git
url: https://github.com/ros2/rcl.git
version: rolling
ros2/rcl_interfaces:
type: git
url: https://github.com/ros2/rcl_interfaces.git
version: rolling
ros2/rcl_logging:
type: git
url: https://github.com/ros2/rcl_logging.git
version: rolling
ros2/rclcpp:
type: git
url: https://github.com/ros2/rclcpp.git
version: rolling
ros2/rclpy:
type: git
url: https://github.com/ros2/rclpy.git
version: rolling
ros2/rcpputils:
type: git
url: https://github.com/ros2/rcpputils.git
version: rolling
ros2/rcutils:
type: git
url: https://github.com/ros2/rcutils.git
version: rolling
ros2/realtime_support:
type: git
url: https://github.com/ros2/realtime_support.git
version: rolling
ros2/rmw:
type: git
url: https://github.com/ros2/rmw.git
version: rolling
ros2/rmw_connextdds:
type: git
url: https://github.com/ros2/rmw_connextdds.git
version: rolling
ros2/rmw_cyclonedds:
type: git
url: https://github.com/ros2/rmw_cyclonedds.git
version: rolling
ros2/rmw_dds_common:
type: git
url: https://github.com/ros2/rmw_dds_common.git
version: rolling
ros2/rmw_fastrtps:
type: git
url: https://github.com/ros2/rmw_fastrtps.git
version: rolling
ros2/rmw_implementation:
type: git
url: https://github.com/ros2/rmw_implementation.git
version: rolling
ros2/ros2_tracing:
type: git
url: https://github.com/ros2/ros2_tracing.git
version: rolling
ros2/ros2cli:
type: git
url: https://github.com/ros2/ros2cli.git
version: rolling
ros2/ros2cli_common_extensions:
type: git
url: https://github.com/ros2/ros2cli_common_extensions.git
version: rolling
ros2/ros_testing:
type: git
url: https://github.com/ros2/ros_testing.git
version: rolling
ros2/rosbag2:
type: git
url: https://github.com/ros2/rosbag2.git
version: rolling
ros2/rosidl:
type: git
url: https://github.com/ros2/rosidl.git
version: rolling
ros2/rosidl_core:
type: git
url: https://github.com/ros2/rosidl_core.git
version: rolling
ros2/rosidl_dds:
type: git
url: https://github.com/ros2/rosidl_dds.git
version: rolling
ros2/rosidl_defaults:
type: git
url: https://github.com/ros2/rosidl_defaults.git
version: rolling
ros2/rosidl_dynamic_typesupport:
type: git
url: https://github.com/ros2/rosidl_dynamic_typesupport.git
version: rolling
ros2/rosidl_dynamic_typesupport_fastrtps:
type: git
url: https://github.com/ros2/rosidl_dynamic_typesupport_fastrtps.git
version: rolling
ros2/rosidl_python:
type: git
url: https://github.com/ros2/rosidl_python.git
version: rolling
ros2/rosidl_runtime_py:
type: git
url: https://github.com/ros2/rosidl_runtime_py.git
version: rolling
ros2/rosidl_typesupport:
type: git
url: https://github.com/ros2/rosidl_typesupport.git
version: rolling
ros2/rosidl_typesupport_fastrtps:
type: git
url: https://github.com/ros2/rosidl_typesupport_fastrtps.git
version: rolling
ros2/rpyutils:
type: git
url: https://github.com/ros2/rpyutils.git
version: rolling
ros2/rviz:
type: git
url: https://github.com/ros2/rviz.git
version: rolling
ros2/sros2:
type: git
url: https://github.com/ros2/sros2.git
version: rolling
ros2/system_tests:
type: git
url: https://github.com/ros2/system_tests.git
version: rolling
ros2/test_interface_files:
type: git
url: https://github.com/ros2/test_interface_files.git
version: rolling
ros2/tlsf:
type: git
url: https://github.com/ros2/tlsf.git
version: rolling
ros2/unique_identifier_msgs:
type: git
url: https://github.com/ros2/unique_identifier_msgs.git
version: rolling
ros2/urdf:
type: git
url: https://github.com/ros2/urdf.git
version: rolling
variants:
type: git
url: https://github.com/ros2/variants.git
version: rolling
vision_msgs:
type: git
url: https://github.com/ros-perception/vision_msgs.git
version: ros2
vision_opencv:
type: git
url: https://github.com/ros-perception/vision_opencv.git
version: rolling
@@ -0,0 +1,145 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE} as vendor_packages_src
# RUN mkdir -p workspace/src
# COPY vendor_packages workspace/src/
RUN mkdir -p workspace/src \
&& cd workspace/src \
&& git clone https://github.com/EricX-Zhao/vendor_packages.git
FROM vendor_packages_src as system_packages
RUN cd workspace \
&& colcon build \
--install-base ${TARGET_SYSROOT} \
--merge-install \
--packages-up-to system_vendor_packages \
--cmake-force-configure \
--cmake-args \
--no-warn-unused-cli \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DCMAKE_TOOLCHAIN_FILE=${CC_TOOLCHAIN_FILE}
FROM vendor_packages_src as ceres_vendor
RUN cd workspace \
&& colcon build \
--install-base ${TARGET_SYSROOT} \
--merge-install \
--packages-up-to ceres_vendor \
--cmake-force-configure \
--cmake-args \
--no-warn-unused-cli \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=${CC_TOOLCHAIN_FILE}
FROM vendor_packages_src as opencv_vendor
RUN cd workspace \
&& colcon build \
--install-base ${TARGET_SYSROOT} \
--merge-install \
--packages-up-to opencv_vendor \
--cmake-force-configure \
--cmake-args \
--no-warn-unused-cli \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=${CC_TOOLCHAIN_FILE}
FROM ${BASE_IMAGE} AS boost
WORKDIR /tmp
RUN wget https://archives.boost.io/release/1.83.0/source/boost_1_83_0.tar.gz
RUN tar -zxf boost_1_83_0.tar.gz \
&& cd boost_1_83_0 \
&& ./bootstrap.sh --prefix=${TARGET_SYSROOT} --without-libraries=python \
&& sed -i "/using gcc/c using gcc : arm64 : aarch64-none-linux-gnu-gcc ;" project-config.jam \
&& ./b2 cxxflags="-fPIC" cflags="-fPIC" link=static install
FROM vendor_packages_src as pcl_vendor
COPY --from=boost ${TARGET_SYSROOT} ${TARGET_SYSROOT}
RUN cd workspace \
&& colcon build \
--install-base ${TARGET_SYSROOT} \
--merge-install \
--packages-up-to pcl_vendor \
--cmake-force-configure \
--cmake-args \
--no-warn-unused-cli \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=${CC_TOOLCHAIN_FILE}
# OpenSSL
FROM ${BASE_IMAGE} AS ssl_builder
WORKDIR /tmp
RUN git clone --depth=1 https://github.com/janbar/openssl-cmake.git \
&& cd openssl-cmake \
&& mkdir build \
&& cd build \
&& cmake .. \
-DCMAKE_TOOLCHAIN_FILE=${CC_TOOLCHAIN_FILE} \
-DCMAKE_INSTALL_PREFIX=${TARGET_SYSROOT} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
&& make -j$(($(nproc) / 2)) && make install \
&& rm -rf /tmp
# Python 3.12
FROM ${BASE_IMAGE} AS python_builder
WORKDIR /tmp
COPY --from=ssl_builder ${TARGET_SYSROOT} ${TARGET_SYSROOT}
# COPY vendor_packages/Python-3.10.12.tar.xz .
RUN wget https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tar.xz && \
RUN tar -xf Python-3.10.12.tar.xz && \
rm Python-3.10.12.tar.xz
# 配置和编译 Python
WORKDIR /tmp/Python-3.10.12
ENV CC=aarch64-none-linux-gnu-gcc \
CXX=aarch64-none-linux-gnu-g++ \
AR=aarch64-none-linux-gnu-ar \
RANLIB=aarch64-none-linux-gnu-ranlib \
HOSTARCH=aarch64-none-linux-gnu \
BUILDARCH=x86_64-linux-gnu
RUN CFLAGS="-fPIC" LDFLAGS="-fPIC" ./configure \
--host=aarch64-none-linux-gnu \
--build=x86_64-linux-gnu \
--prefix=${TARGET_SYSROOT} \
--with-build-python=python3.12 \
--disable-ipv6 \
--enable-optimizations \
--with-openssl=${TARGET_SYSROOT} \
ac_cv_file__dev_ptmx=yes \
ac_cv_file__dev_ptc=yes \
&& make -j$(($(nproc) / 2)) && make install
# https://github.com/benfogle/crossenv
# cross compile python packages
WORKDIR /tmp
RUN python3 -m pip install crossenv \
&& python3 -m crossenv ${TARGET_SYSROOT}/bin/python3 venv \
&& . venv/bin/activate \
&& pip -v install numpy==1.21.5 lark==1.1.1 packaging --prefix=${TARGET_SYSROOT}
FROM ${BASE_IMAGE} as final
COPY --from=system_packages ${TARGET_SYSROOT} ${TARGET_SYSROOT}
COPY --from=ceres_vendor ${TARGET_SYSROOT} ${TARGET_SYSROOT}
COPY --from=opencv_vendor ${TARGET_SYSROOT} ${TARGET_SYSROOT}
COPY --from=pcl_vendor ${TARGET_SYSROOT} ${TARGET_SYSROOT}
COPY --from=python_builder ${TARGET_SYSROOT} ${TARGET_SYSROOT}
+67
View File
@@ -0,0 +1,67 @@
## Build Image
ROS Noetic + Gazebo Classic
```
docker buildx build -f gazebo_classic_sim_dev.dockerfile -t sim_dev:gazebo_classic .
```
## NOTICE
When you build code in container with error:
```
fatal: detected dubious ownership in repository at '/code/PX4-Autopilot'
To add an exception for this directory, call:
git config --global --add safe.directory
```
you should run this command in container:
```
git config --global --add safe.directory '*'
```
## WSL2 With GUI&GPU Support
> NOTICE: replace `~/code` on your host
```
docker run -it \
-v ~/code:/code \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /mnt/wslg:/mnt/wslg \
-v /usr/lib/wsl:/usr/lib/wsl \
-e DISPLAY=$DISPLAY \
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
-e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-e PULSE_SERVER=$PULSE_SERVER \
--device=/dev/dxg \
--device /dev/dri/card0 \
--device /dev/dri/renderD128 \
--gpus all sim_dev:gazebo_classic
```
## Ubuntu With GUI&GPU Support
> NOTICE: replace `~/code` on your host
```
docker run -it \
-v ~/code:/code \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY \
--device=/dev/dxg \
--device /dev/dri/card0 \
--device /dev/dri/renderD128 \
--gpus all sim_dev:gazebo_classic
```
## How to enter container again with bash
```
docker container ls -a
# start container if not
docker container start [container id]
docker exec -it [container id] bash
```
@@ -0,0 +1,28 @@
FROM osrf/ros:noetic-desktop-full AS builder
ARG DEBIAN_FRONTEND=noninteractive
# catkin-tools
RUN apt-get update && apt-get install -y \
ca-certificates \
gnupg \
lsb-core \
sudo \
curl \
wget \
python3-catkin-tools \
&& rm -rf /var/lib/apt/lists/*
# PX4 dependencies
COPY requirements.txt /requirements.txt
COPY ubuntu.sh /ubuntu.sh
RUN /ubuntu.sh && rm -rf /var/lib/apt/lists/* && rm /requirements.txt /ubuntu.sh
# for WSL2 GPU Support
ENV LD_LIBRARY_PATH=/usr/lib/wsl/lib
RUN apt update && apt install -y \
mesa-utils \
vainfo \
mesa-va-drivers \
&& rm -rf /var/lib/apt/lists/*
+29
View File
@@ -0,0 +1,29 @@
argcomplete
argparse>=1.2
cerberus
coverage
empy>=3.3
future
jinja2>=2.8
jsonschema
kconfiglib
lxml
matplotlib>=3.0.*
numpy>=1.13
nunavut>=1.1.0
packaging
pandas>=0.21
pkgconfig
psutil
pygments
wheel>=0.31.1
pymavlink
pyros-genmsg
pyserial
pyulog>=0.5.0
pyyaml
requests
setuptools>=39.2.0
six>=1.12.0
toml>=0.9
sympy>=1.10.1
+277
View File
@@ -0,0 +1,277 @@
#! /usr/bin/env bash
set -e
## Bash script to setup PX4 development environment on Ubuntu LTS (22.04, 20.04, 18.04).
## Can also be used in docker.
##
## Installs:
## - Common dependencies and tools for nuttx, jMAVSim, Gazebo
## - NuttX toolchain (omit with arg: --no-nuttx)
## - jMAVSim and Gazebo9 simulator (omit with arg: --no-sim-tools)
##
INSTALL_NUTTX="true"
INSTALL_SIM="true"
INSTALL_ARCH=`uname -m`
# Parse arguments
for arg in "$@"
do
if [[ $arg == "--no-nuttx" ]]; then
INSTALL_NUTTX="false"
fi
if [[ $arg == "--no-sim-tools" ]]; then
INSTALL_SIM="false"
fi
done
# detect if running in docker
if [ -f /.dockerenv ]; then
echo "Running within docker, installing initial dependencies";
apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \
ca-certificates \
gnupg \
lsb-core \
sudo \
wget \
;
fi
# script directory
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# check requirements.txt exists (script not run in source tree)
REQUIREMENTS_FILE="requirements.txt"
if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then
echo "FAILED: ${REQUIREMENTS_FILE} needed in same directory as ubuntu.sh (${DIR})."
return 1
fi
# check ubuntu version
# otherwise warn and point to docker?
UBUNTU_RELEASE="`lsb_release -rs`"
if [[ "${UBUNTU_RELEASE}" == "14.04" ]]; then
echo "Ubuntu 14.04 is no longer supported"
exit 1
elif [[ "${UBUNTU_RELEASE}" == "16.04" ]]; then
echo "Ubuntu 16.04 is no longer supported"
exit 1
elif [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
echo "Ubuntu 18.04"
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
echo "Ubuntu 20.04"
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
echo "Ubuntu 22.04"
fi
echo
echo "Installing PX4 general dependencies"
sudo apt-get update -y --quiet
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
astyle \
build-essential \
cmake \
cppcheck \
file \
g++ \
gcc \
gdb \
git \
lcov \
libfuse2 \
libxml2-dev \
libxml2-utils \
make \
ninja-build \
python3 \
python3-dev \
python3-pip \
python3-setuptools \
python3-wheel \
rsync \
shellcheck \
unzip \
zip \
;
# Python3 dependencies
echo
echo "Installing PX4 Python3 dependencies"
if [ -n "$VIRTUAL_ENV" ]; then
# virtual environments don't allow --user option
python -m pip install -r ${DIR}/requirements.txt
else
# older versions of Ubuntu require --user option
python3 -m pip install --user -r /requirements.txt
fi
# NuttX toolchain (arm-none-eabi-gcc)
if [[ $INSTALL_NUTTX == "true" ]]; then
echo
echo "Installing NuttX dependencies"
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
automake \
binutils-dev \
bison \
build-essential \
flex \
g++-multilib \
gcc-multilib \
gdb-multiarch \
genromfs \
gettext \
gperf \
libelf-dev \
libexpat-dev \
libgmp-dev \
libisl-dev \
libmpc-dev \
libmpfr-dev \
libncurses5 \
libncurses5-dev \
libncursesw5-dev \
libtool \
pkg-config \
screen \
texinfo \
u-boot-tools \
util-linux \
vim-common \
;
if [[ "${UBUNTU_RELEASE}" == "20.04" || "${UBUNTU_RELEASE}" == "22.04" ]]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
kconfig-frontends \
;
fi
if [ -n "$USER" ]; then
# add user to dialout group (serial port access)
sudo usermod -a -G dialout $USER
fi
# arm-none-eabi-gcc
NUTTX_GCC_VERSION="9-2020-q2-update"
NUTTX_GCC_VERSION_SHORT="9-2020q2"
source $HOME/.profile # load changed path for the case the script is reran before relogin
if [ $(which arm-none-eabi-gcc) ]; then
GCC_VER_STR=$(arm-none-eabi-gcc --version)
GCC_FOUND_VER=$(echo $GCC_VER_STR | grep -c "${NUTTX_GCC_VERSION}")
fi
if [[ "$GCC_FOUND_VER" == "1" ]]; then
echo "arm-none-eabi-gcc-${NUTTX_GCC_VERSION} found, skipping installation"
else
echo "Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}";
wget -O /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/${NUTTX_GCC_VERSION_SHORT}/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-${INSTALL_ARCH}-linux.tar.bz2 && \
sudo tar -jxf /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 -C /opt/;
# add arm-none-eabi-gcc to user's PATH
exportline="export PATH=/opt/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}/bin:\$PATH"
if grep -Fxq "$exportline" $HOME/.profile; then
echo "${NUTTX_GCC_VERSION} path already set.";
else
echo $exportline >> $HOME/.profile;
source $HOME/.profile; # Allows to directly build NuttX targets in the same terminal
fi
fi
fi
# Simulation tools
if [[ $INSTALL_SIM == "true" ]]; then
echo
echo "Installing PX4 simulation dependencies"
# General simulation dependencies
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
bc \
;
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
java_version=11
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
java_version=13
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
java_version=11
else
java_version=14
fi
# Java (jmavsim)
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
ant \
openjdk-$java_version-jre \
openjdk-$java_version-jdk \
libvecmath-java \
;
# Set Java 11 as default
sudo update-alternatives --set java $(update-alternatives --list java | grep "java-$java_version")
# Gazebo / Gazebo classic installation
if [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
echo "Gazebo (Garden) will be installed"
echo "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-garden"
else
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
# 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
fi
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
dmidecode \
$gazebo_packages \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
libeigen3-dev \
libgstreamer-plugins-base1.0-dev \
libimage-exiftool-perl \
libopencv-dev \
libxml2-utils \
pkg-config \
protobuf-compiler \
;
if sudo dmidecode -t system | grep -q "Manufacturer: VMware, Inc." ; then
# fix VMWare 3D graphics acceleration for gazebo
echo "export SVGA_VGPU10=0" >> ~/.profile
fi
fi
if [[ $INSTALL_NUTTX == "true" ]]; then
echo
echo "Relogin or reboot computer before attempting to build NuttX targets"
fi
+107
View File
@@ -0,0 +1,107 @@
## Build Image
ROS Jazzy + GZ Harmonic
```
docker buildx build -f gz_harmonic_sim_dev.dockerfile -t sim_dev:gz_harmonic .
```
## NOTICE
When you build code in container with error:
> fatal: detected dubious ownership in repository at '/code/PX4-Autopilot'
> To add an exception for this directory, call:
> git config --global --add safe.directory
you should run this command in container:
```
git config --global --add safe.directory '*'
```
## Ubuntu With GUI&GPU Support
1. Install nvidia-container-toolkit
```
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt install -y nvidia-container-toolkit
sudo systemctl restart docker
```
2. Run container with docker compose
```
# in host bash
# x11 permission
xhost +local:root
# 修改 docker-compose-ubuntu.yml 中${HOST_WS} 为你主机上的工作空间的目录
docker compose -f docker-compose-ubuntu.yml up -d
docker exec -it sim_dev_container bash
# in container bash
git config --global --add safe.directory '*'
cd /simulation_ws
sudo apt update
rosdep install --from-paths src/autonomy --ignore-src -r -y
/simulation_ws/src/autonomy/drivers/mavros/mavros/scripts/install_geographiclib_datasets.sh
colcon build --symlink-install --packages-up-to mavlink mavros px4_bringup
```
## How to enter container again with bash
```
# get container id
docker container ls -a
# start container if not
docker container start [container id]
docker exec -it [container id] bash
```
## WSL2 With GUI&GPU Support
> NOTICE: replace `~/code` on your host
```
docker run -it \
-v ~/code:/code \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /mnt/wslg:/mnt/wslg \
-v /usr/lib/wsl:/usr/lib/wsl \
-e DISPLAY=$DISPLAY \
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
-e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-e PULSE_SERVER=$PULSE_SERVER \
--device=/dev/dxg \
--device /dev/dri/card0 \
--device /dev/dri/renderD128 \
--gpus all sim_dev:gz_harmonic
```
docker-compose
```
docker compose -f docker-compose-wsl.yml up -d
docker exec -it sim_dev_container bash
cd /simulation_ws
sudo apt update
rosdep install --from-paths src/autonomy --ignore-src -r -y
/simulation_ws/src/autonomy/drivers/mavros/mavros/scripts/install_geographiclib_datasets.sh
colcon build --symlink-install --packages-up-to mavlink mavros px4_bringup
```
## Simulation
### build simulation worksapce
```bash
MAKEFLAGS="-j4" colcon build --symlink-install \
--packages-up-to \
mavlink mavros mavros_extras px4_bringup vins_estimator usb_cam \
--cmake-args \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
```
+23
View File
@@ -0,0 +1,23 @@
services:
sim_dev:
image: sim_dev:gz_harmonic
container_name: sim_dev_container
runtime: nvidia # 启用 NVIDIA GPU 支持
stdin_open: true # 保持标准输入打开
tty: true # 分配一个伪终端
privileged: true # 特权模式,允许访问所有 /dev 设备
ports:
- 2222:22 # ssh server
environment:
- DISPLAY=${DISPLAY}
- NVIDIA_DRIVER_CAPABILITIES=all
volumes:
- /dev/dri:/dev/dri
- ${HOST_WS}:/workspace
- ${DATASET}:/dataset
- /tmp/.X11-unix:/tmp/.X11-unix
deploy:
resources:
reservations:
devices:
- capabilities: [gpu]
+18
View File
@@ -0,0 +1,18 @@
services:
sim_dev:
image: sim_dev:gz_harmonic
container_name: sim_dev_container
volumes:
- ~/simulation_ws:/simulation_ws
- /tmp/.X11-unix:/tmp/.X11-unix
- /mnt/wslg:/mnt/wslg
- /usr/lib/wsl:/usr/lib/wsl
environment:
- DISPLAY=${DISPLAY}
- WAYLAND_DISPLAY=${WAYLAND_DISPLAY}
- XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}
- PULSE_SERVER=${PULSE_SERVER}
devices:
- /dev/dxg
- /dev/dri/card0
- /dev/dri/renderD128
@@ -0,0 +1,69 @@
FROM osrf/ros:jazzy-desktop-full AS builder
ARG DEBIAN_FRONTEND=noninteractive
# catkin-tools
RUN apt-get update && apt-get install -y \
ca-certificates \
gnupg \
sudo \
curl \
wget \
&& rm -rf /var/lib/apt/lists/*
# PX4 dependencies
WORKDIR /root
RUN wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/ubuntu.sh \
&& wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/requirements.txt \
&& chmod +x /root/ubuntu.sh \
&& ./ubuntu.sh \
&& rm -rf /var/lib/apt/lists/* \
&& rm /root/requirements.txt /root/ubuntu.sh
# COPY requirements.txt /requirements.txt
# COPY ubuntu.sh /ubuntu.sh
# RUN /ubuntu.sh && rm -rf /var/lib/apt/lists/* && rm /requirements.txt /ubuntu.sh
# for WSL2 GPU Support
ENV LD_LIBRARY_PATH=/usr/lib/wsl/lib
RUN apt update && apt install -y \
mesa-utils \
vainfo \
mesa-va-drivers \
vim \
net-tools \
openssh-server \
libasio-dev \
python3-future \
libgeographiclib-dev \
ros-jazzy-eigen-stl-containers \
ros-jazzy-diagnostic-updater \
ros-jazzy-rmw-zenoh-cpp \
ros-jazzy-ros-gz \
&& rm -rf /var/lib/apt/lists/*
# ceres
WORKDIR /root
RUN apt update && apt install -y \
libgoogle-glog-dev \
libgflags-dev \
libatlas-base-dev \
libeigen3-dev \
libsuitesparse-dev \
&& rm -rf /var/lib/apt/lists/*
RUN wget https://github.com/ceres-solver/ceres-solver/archive/refs/tags/2.1.0.tar.gz \
&& tar -zxf 2.1.0.tar.gz \
&& cd ceres-solver-2.1.0 \
&& mkdir build && cd build \
&& cmake .. -DCXSPARSE=OFF \
&& make install -j4 \
&& rm -rf /root/ceres-solver-2.1.0 /root/2.1.0.tar.gz
# spdlog
RUN wget https://github.com/gabime/spdlog/archive/refs/tags/v1.12.0.tar.gz \
&& tar -zxf v1.12.0.tar.gz \
&& cd spdlog-1.12.0 \
&& mkdir build && cd build \
&& cmake .. -DSPDLOG_BUILD_SHARED=ON \
&& make install -j \
&& rm -rf /root/v1.12.0.tar.gz /root/spdlog-1.12.0
+28
View File
@@ -0,0 +1,28 @@
argcomplete
cerberus
coverage
empy>=3.3,<4
future
jinja2>=2.8
jsonschema
kconfiglib
lxml
matplotlib>=3.0
numpy>=1.13
nunavut>=1.1.0
packaging
pandas>=0.21
pkgconfig
psutil
pygments
wheel>=0.31.1
pymavlink
pyros-genmsg
pyserial
pyulog>=0.5.0
pyyaml
requests
setuptools>=39.2.0
six>=1.12.0
toml>=0.9
sympy>=1.10.1
+231
View File
@@ -0,0 +1,231 @@
#! /usr/bin/env bash
set -e
## Bash script to setup PX4 development environment on Ubuntu LTS (24.04, 22.04).
## Can also be used in docker.
##
## Installs:
## - Common dependencies and tools for nuttx, jMAVSim, Gazebo
## - NuttX toolchain (omit with arg: --no-nuttx)
## - jMAVSim and Gazebo9 simulator (omit with arg: --no-sim-tools)
##
INSTALL_NUTTX="true"
INSTALL_SIM="true"
INSTALL_ARCH=`uname -m`
# Parse arguments
for arg in "$@"
do
if [[ $arg == "--no-nuttx" ]]; then
INSTALL_NUTTX="false"
fi
if [[ $arg == "--no-sim-tools" ]]; then
INSTALL_SIM="false"
fi
done
# detect if running in docker
if [ -f /.dockerenv ]; then
echo "Running within docker, installing initial dependencies";
apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \
ca-certificates \
gnupg \
gosu \
lsb-release \
software-properties-common \
sudo \
wget \
;
fi
# script directory
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# check requirements.txt exists (script not run in source tree)
REQUIREMENTS_FILE="requirements.txt"
if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then
echo "FAILED: ${REQUIREMENTS_FILE} needed in same directory as ubuntu.sh (${DIR})."
return 1
fi
# check ubuntu version
# otherwise warn and point to docker?
UBUNTU_RELEASE="`lsb_release -rs`"
echo "Ubuntu ${UBUNTU_RELEASE}"
echo
echo "Installing PX4 general dependencies"
sudo apt-get update -y --quiet
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
astyle \
build-essential \
cmake \
cppcheck \
file \
g++ \
gcc \
gdb \
git \
lcov \
libssl-dev \
libxml2-dev \
libxml2-utils \
make \
ninja-build \
python3 \
python3-dev \
python3-pip \
python3-setuptools \
python3-wheel \
rsync \
shellcheck \
unzip \
zip \
;
# Python3 dependencies
echo
echo "Installing PX4 Python3 dependencies"
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
REQUIRED_VERSION="3.11"
if [[ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" == "$REQUIRED_VERSION" ]]; then
python3 -m pip install --break-system-packages -r ${DIR}/requirements.txt
else
if [ -n "$VIRTUAL_ENV" ]; then
# virtual environments don't allow --user option
python -m pip install -r ${DIR}/requirements.txt
else
python3 -m pip install --user -r ${DIR}/requirements.txt
fi
fi
# NuttX toolchain (arm-none-eabi-gcc)
if [[ $INSTALL_NUTTX == "true" ]]; then
echo
echo "Installing NuttX dependencies"
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
automake \
binutils-dev \
bison \
build-essential \
flex \
g++-multilib \
gcc-arm-none-eabi \
gcc-multilib \
gdb-multiarch \
genromfs \
gettext \
gperf \
kconfig-frontends \
libelf-dev \
libexpat-dev \
libgmp-dev \
libisl-dev \
libmpc-dev \
libmpfr-dev \
libncurses-dev \
libncurses6 \
libncursesw6 \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib \
libtool \
libunwind-dev \
pkg-config \
screen \
texinfo \
u-boot-tools \
util-linux \
vim-common \
;
if [ -n "$USER" ]; then
# add user to dialout group (serial port access)
sudo usermod -aG dialout $USER
fi
fi
# Simulation tools
if [[ $INSTALL_SIM == "true" ]]; then
echo
echo "Installing PX4 simulation dependencies"
# General simulation dependencies
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
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
# 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
elif [[ "${UBUNTU_RELEASE}" == "21.3" ]]; then
echo "Gazebo (Garden) will be installed"
echo "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 jammy main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
sudo apt-get update -y --quiet
# Install Gazebo
gazebo_packages="gz-garden"
else
# Expects Ubuntu 22.04 > by default
echo "Gazebo (Harmonic) will be installed"
echo "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"
if [[ "${UBUNTU_RELEASE}" == "24.04" ]]; then
gazebo_packages="$gazebo_packages cppzmq-dev"
fi
fi
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
dmidecode \
$gazebo_packages \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
libeigen3-dev \
libgstreamer-plugins-base1.0-dev \
libimage-exiftool-perl \
libopencv-dev \
libxml2-utils \
pkg-config \
protobuf-compiler \
;
if sudo dmidecode -t system | grep -q "Manufacturer: VMware, Inc." ; then
# fix VMWare 3D graphics acceleration for gazebo
echo "export SVGA_VGPU10=0" >> ~/.profile
fi
fi