Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions docker/scripts/build_opencv.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env bash
set -eo pipefail

OPENCV_VERSION=$1
# Build directory defaults to /OpenCV (Dockerfile) but can be overridden when
# running locally via setup_local.sh.
OPENCV_BUILD_DIR="${OPENCV_BUILD_DIR:-/OpenCV}"

CMAKE_FLAGS=" \
-DCPACK_BINARY_DEB=ON \
-DBUILD_EXAMPLES=OFF \
Expand All @@ -9,7 +14,7 @@ CMAKE_FLAGS=" \
-DBUILD_opencv_java=OFF \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DOPENCV_EXTRA_MODULES_PATH=/OpenCV/opencv_contrib/modules \
-DOPENCV_EXTRA_MODULES_PATH=${OPENCV_BUILD_DIR}/opencv_contrib/modules \
-DCUDA_FAST_MATH=ON \
-DEIGEN_INCLUDE_PATH=/usr/include/eigen3 \
-DWITH_EIGEN=ON \
Expand All @@ -18,13 +23,14 @@ CMAKE_FLAGS=" \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_TESTS=OFF"

OPENCV_VERSION=$1
# Use nproc on Linux, sysctl on macOS
JOBS=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)

mkdir /OpenCV && cd /OpenCV &&
mkdir -p "${OPENCV_BUILD_DIR}" && cd "${OPENCV_BUILD_DIR}" &&

git clone --depth 1 --branch ${OPENCV_VERSION} https://github.com/opencv/opencv.git
git clone --depth 1 --branch ${OPENCV_VERSION} https://github.com/opencv/opencv_contrib.git
[ -d opencv ] || git clone --depth 1 --branch ${OPENCV_VERSION} https://github.com/opencv/opencv.git
[ -d opencv_contrib ] || git clone --depth 1 --branch ${OPENCV_VERSION} https://github.com/opencv/opencv_contrib.git

cmake -S opencv -B build ${CMAKE_FLAGS} && \
cmake --build build --config Release -- -j$(nproc) && \
cmake --build build --config Release -- -j${JOBS} && \
cmake --install build --config Release --prefix ./install
73 changes: 67 additions & 6 deletions docker/scripts/build_px4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,58 @@
set -eo pipefail

PX4_VERSION=$1
# Where PX4 will be cloned/built. Dockerfile leaves this as /home/${USER};
# setup_local.sh overrides to $HOME so it works for any local username.
PX4_BUILD_DIR="${PX4_BUILD_DIR:-/home/${USER}}"

git clone --recurse-submodules -b ${PX4_VERSION} https://github.com/PX4/PX4-Autopilot.git /home/${USER}/PX4-Autopilot
[ -d "${PX4_BUILD_DIR}/PX4-Autopilot" ] || \
git clone --recurse-submodules -b ${PX4_VERSION} https://github.com/PX4/PX4-Autopilot.git "${PX4_BUILD_DIR}/PX4-Autopilot"

cd /home/${USER}/PX4-Autopilot
cd "${PX4_BUILD_DIR}/PX4-Autopilot"

# Patch to allow setting parameters via env variables
# Patch to allow setting parameters via env variables. Applied via `git apply
# --reverse --check` first to make this idempotent on re-runs.
if git apply --reverse --check - <<'EOF' >/dev/null 2>&1
diff --git a/ROMFS/px4fmu_common/init.d-posix/rcS b/ROMFS/px4fmu_common/init.d-posix/rcS
index fed292b9d1..1d34854077 100644
--- a/ROMFS/px4fmu_common/init.d-posix/rcS
+++ b/ROMFS/px4fmu_common/init.d-posix/rcS
@@ -126,15 +126,6 @@ then
set AUTOCNF yes
fi

-# Allow overriding parameters via env variables: export PX4_PARAM_{name}={value}
-env | while IFS='=' read -r line; do
- value=${line#*=}
- name=${line%%=*}
- case $name in
- "PX4_PARAM_"*) param set "${name#PX4_PARAM_}" "$value" ;;
- esac
-done
-
# multi-instance setup
# shellcheck disable=SC2154
param set MAV_SYS_ID $((px4_instance+1))
@@ -239,6 +230,15 @@ then
exit 1
fi

+# Allow overriding parameters via env variables: export PX4_PARAM_{name}={value}
+env | while IFS='=' read -r line; do
+ value=${line#*=}
+ name=${line%%=*}
+ case $name in
+ "PX4_PARAM_"*) param set "${name#PX4_PARAM_}" "$value" ;;
+ esac
+done
+
dataman start

# only start the simulator if not in replay mode, as both control the lockstep time
EOF
then
echo "Patch already applied, skipping."
else
git apply - <<'EOF'
diff --git a/ROMFS/px4fmu_common/init.d-posix/rcS b/ROMFS/px4fmu_common/init.d-posix/rcS
index fed292b9d1..1d34854077 100644
Expand Down Expand Up @@ -43,13 +89,28 @@ index fed292b9d1..1d34854077 100644
+done
+
dataman start

# only start the simulator if not in replay mode, as both control the lockstep time
EOF
fi

# Platform-specific PX4 setup. Docker / Ubuntu host uses ubuntu.sh; macOS host
# (when invoked from setup_local.sh) uses macos.sh from PX4-Autopilot itself.
case "$(uname -s)" in
Linux*)
./Tools/setup/ubuntu.sh --no-nuttx --no-sim-tools
;;
Darwin*)
./Tools/setup/macos.sh
;;
*)
echo "Unsupported PX4 host platform: $(uname -s)" >&2
exit 1
;;
esac

./Tools/setup/ubuntu.sh --no-nuttx --no-sim-tools
make px4_sitl_default
cd ..
cd "${PX4_BUILD_DIR}"
mkdir -p px4_sitl/bin
mkdir -p px4_sitl/romfs/etc
cp -a PX4-Autopilot/build/px4_sitl_default/bin px4_sitl/
Expand Down
21 changes: 12 additions & 9 deletions docker/scripts/build_ros_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ MICRO_XRCE_DDS_AGENT_VERSION=$1
PX4_MSGS_VERSION=$2
PX4_ROS2_INTERFACE_LIB_VERSION=$3
PX4_ROS_COM_VERSION=$4
# Workspace path defaults to /root/px4_ros_ws (Dockerfile) but can be overridden
# when running locally via setup_local.sh.
PX4_ROS_WS="${PX4_ROS_WS:-/root/px4_ros_ws}"

mkdir -p /root/px4_ros_ws/src && cd /root/px4_ros_ws/src && \
git clone --depth 1 -b ${MICRO_XRCE_DDS_AGENT_VERSION} https://github.com/eProsima/Micro-XRCE-DDS-Agent.git && \
git clone --depth 1 -b ${PX4_MSGS_VERSION} https://github.com/PX4/px4_msgs.git && \
git clone --depth 1 -b ${PX4_ROS2_INTERFACE_LIB_VERSION} https://github.com/Auterion/px4-ros2-interface-lib.git && \
git clone --depth 1 -b ${PX4_ROS_COM_VERSION} https://github.com/PX4/px4_ros_com.git && \
git clone --depth 1 -b humble https://github.com/ros-perception/vision_opencv.git && \
git clone --depth 1 -b humble https://github.com/ros-perception/image_common.git && \
git clone --depth 1 -b humble https://github.com/ros-perception/image_transport_plugins.git && \
git clone --depth 1 -b humble https://github.com/gazebosim/ros_gz.git && \
mkdir -p "${PX4_ROS_WS}/src" && cd "${PX4_ROS_WS}/src" && \
[ -d Micro-XRCE-DDS-Agent ] || git clone --depth 1 -b ${MICRO_XRCE_DDS_AGENT_VERSION} https://github.com/eProsima/Micro-XRCE-DDS-Agent.git
[ -d px4_msgs ] || git clone --depth 1 -b ${PX4_MSGS_VERSION} https://github.com/PX4/px4_msgs.git
[ -d px4-ros2-interface-lib ] || git clone --depth 1 -b ${PX4_ROS2_INTERFACE_LIB_VERSION} https://github.com/Auterion/px4-ros2-interface-lib.git
[ -d px4_ros_com ] || git clone --depth 1 -b ${PX4_ROS_COM_VERSION} https://github.com/PX4/px4_ros_com.git
[ -d vision_opencv ] || git clone --depth 1 -b humble https://github.com/ros-perception/vision_opencv.git
[ -d image_common ] || git clone --depth 1 -b humble https://github.com/ros-perception/image_common.git
[ -d image_transport_plugins ] || git clone --depth 1 -b humble https://github.com/ros-perception/image_transport_plugins.git
[ -d ros_gz ] || git clone --depth 1 -b humble https://github.com/gazebosim/ros_gz.git
rm -rf ros_gz/ros_ign* \
ros_gz/ros_gz_sim_demos \
image_transport_plugins/compressed_depth_image_transport \
Expand Down
22 changes: 13 additions & 9 deletions docker/scripts/install_deps.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
# SUDO is empty inside the Dockerfile (running as root); setup_local.sh sets
# it to "sudo" so the same script works for a non-root local install.
SUDO="${SUDO:-}"

${SUDO} apt-get update && \
${SUDO} apt-get upgrade -y && \
${SUDO} apt-get install -y --no-install-recommends \
curl \
lsb-release \
gnupg && \
curl https://packages.osrfoundation.org/gazebo.gpg --output /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" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null && \
apt-get update && \
apt-get install -y --no-install-recommends \
${SUDO} sh -c 'curl https://packages.osrfoundation.org/gazebo.gpg --output /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 && \
${SUDO} apt-get install -y --no-install-recommends \
gz-harmonic \
ros-humble-foxglove-bridge \
bc \
Expand All @@ -37,5 +41,5 @@ apt-get install -y --no-install-recommends \
libgflags-dev \
python3-rospkg

rm -rf /var/lib/apt/lists/*
apt-get clean
${SUDO} rm -rf /var/lib/apt/lists/*
${SUDO} apt-get clean
21 changes: 13 additions & 8 deletions docker/scripts/install_qgc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ set -eo pipefail

QGC_VERSION=$1
TARGETARCH=$2
# Install location. Dockerfile leaves this as /home/${USER}; setup_local.sh
# overrides to $HOME for any local username.
QGC_INSTALL_DIR="${QGC_INSTALL_DIR:-/home/${USER}}"

if [ "${TARGETARCH}" = "amd64" ]; then
cd /home/${USER}
wget https://github.com/mavlink/qgroundcontrol/releases/download/${QGC_VERSION}/QGroundControl-x86_64.AppImage
cd "${QGC_INSTALL_DIR}"
[ -f QGroundControl-x86_64.AppImage ] || \
wget https://github.com/mavlink/qgroundcontrol/releases/download/${QGC_VERSION}/QGroundControl-x86_64.AppImage
chmod +x ./QGroundControl-x86_64.AppImage
./QGroundControl-x86_64.AppImage --appimage-extract
mv /home/${USER}/squashfs-root /home/${USER}/QGroundControl
chmod +x /home/${USER}/QGroundControl/AppRun
ln -s /home/${USER}/QGroundControl/AppRun /home/${USER}/QGroundControl/qgroundcontrol
[ -d squashfs-root ] || ./QGroundControl-x86_64.AppImage --appimage-extract
[ -d "${QGC_INSTALL_DIR}/QGroundControl" ] || mv "${QGC_INSTALL_DIR}/squashfs-root" "${QGC_INSTALL_DIR}/QGroundControl"
chmod +x "${QGC_INSTALL_DIR}/QGroundControl/AppRun"
[ -L "${QGC_INSTALL_DIR}/QGroundControl/qgroundcontrol" ] || \
ln -s "${QGC_INSTALL_DIR}/QGroundControl/AppRun" "${QGC_INSTALL_DIR}/QGroundControl/qgroundcontrol"
else
mkdir -p /home/${USER}/QGroundControl
echo "QGroundControl is only available for amd64 architecture." >> /home/${USER}/QGroundControl/install.log
mkdir -p "${QGC_INSTALL_DIR}/QGroundControl"
echo "QGroundControl is only available for amd64 architecture." >> "${QGC_INSTALL_DIR}/QGroundControl/install.log"
fi
Loading
Loading