Add build script and devcontainer configurations for VIO development

This commit is contained in:
EricX-Zhao
2026-04-25 12:16:54 +00:00
parent 10ffc327b2
commit ae3946e650
4 changed files with 189 additions and 0 deletions
Executable
+114
View File
@@ -0,0 +1,114 @@
#!/bin/bash
set -x
# ./build.sh -t DESKTOP -p "vins_estimator" -b RelWithDebInfo
# ./build.sh -t RK3588 -p "depthai_examples" -b RelWithDebInfo
# ./build.sh -t DESKTOP -p "device_manager" -b RelWithDebInfo
# ./build.sh -t RK3588 -p "depthai_examples vins_estimator" -b Release
# ./build.sh -t RK3588 -p "svo_ros" -b Release
# ./build.sh -t DESKTOP -p "ov_core ov_init ov_msckf" -b RelWithDebInfo -l 1
# export WORKSPACE="$(dirname "$(realpath "$BASH_SOURCE")")"
# export WORKSPACE="$(realpath "$BASH_SOURCE")"
export WORKSPACE="$(dirname "$0")"
TARGET_PLATFORM=""
BUILD_TYPE=Release
PACKAGE_UP_TO=""
TOOLCHAIN_FILE=""
INSTALL_METHOD="--merge-install"
CMAKE_FORCE_CONFIG=""
CMAKE_ARGS='-DBUILD_TESTING=OFF
-DDEPTHAI_ENABLE_CURL=OFF
-DBUILD_SHARED_LIBS=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON'
# if number of arguments is less than 2, add -h to list of args
if [ $# -lt 2 ]; then
set -- "$@" -h
fi
usage() {
echo "Usage: build.bash [-h] [-b <build_type>] -t <target_platform> -p <package> [-c] "
echo "Options:"
echo " -h : show this help text"
echo " -b <build_type> : build type to use (default is RelWithDebInfo for platform=PC and Release for others)"
echo " -t <target> : platform to build for (DESKTOP/RK3588)"
echo " -p : Build select package"
echo " -c : Do a clean build"
echo " -f : Force cmake configure"
exit 0
}
# Parse the build options.
while getopts ":hb:t:p:m:f:d:l:c" opt; do
case $opt in
h) usage;;
b) BUILD_TYPE="$OPTARG";;
t) TARGET_PLATFORM="$OPTARG";;
p) PACKAGE_UP_TO="--packages-up-to $OPTARG";;
d) PRODUCT="$OPTARG";;
c) CLEAN_BUILD="true";;
f) CMAKE_FORCE_CONFIG="--cmake-force-configure";;
l) INSTALL_METHOD='--symlink-install';;
?) usage;;
esac
done
if [[ "${TARGET_PLATFORM}" = "" ]]; then
echo "Please specify the platform to build for"
exit 1
fi
CMAKE_ARGS+=" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON "
if [[ "${BUILD_TYPE}" = "" ]];then
if [[ "${TARGET_PLATFORM}" = "PC" ]]; then
BUILD_TYPE=RelWithDebInfo
else
BUILD_TYPE=Release
fi
fi
CMAKE_ARGS+=" -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
if [[ ${CLEAN_BUILD} = "true" ]]; then
rm -rf ${WORKSPACE}/output/${TARGET_PLATFORM}
fi
if [[ "${TARGET_PLATFORM}" = "RK3588" ]]; then
# in rk3588_dev container
TOOLCHAIN_FILE=/opt/cmake/rk3588.toolchain.cmake
CMAKE_ARGS+=" -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}"
export ARM_ARCHITECTURE=arm64
fi
export TARGET=${TARGET_PLATFORM}
INSTALL_DIR=${WORKSPACE}/output/${TARGET_PLATFORM}/install
BUILD_DIR=${WORKSPACE}/output/${TARGET_PLATFORM}/build
LOG_DIR=${WORKSPACE}/output/${TARGET_PLATFORM}/log
# CMAKE_ARGS+=" -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF"
CMAKE_ARGS+=" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath-link,/workspace/output/RK3588/install/lib""
echo "TARGET: ${TARGET_PLATFORM}"
echo "TOOLCHAIN_FILE: ${TOOLCHAIN_FILE}"
echo "PACKAGE_UP_TO: ${PACKAGE_UP_TO}"
MAKEFLAGS="-j8" colcon --log-base ${LOG_DIR} build \
--build-base ${BUILD_DIR} \
--install-base ${INSTALL_DIR} \
--parallel-workers 8 \
${INSTALL_METHOD} \
${PACKAGE_UP_TO} \
${CMAKE_FORCE_CONFIG} \
--cmake-args \
--no-warn-unused-cli \
${CMAKE_ARGS}
if [ $? -eq 0 ]; then
mkdir -p "${INSTALL_DIR}"
echo "Build: $(date "+%Y-%m-%d %H:%M:%S")" > "${INSTALL_DIR}/version"
fi
+33
View File
@@ -0,0 +1,33 @@
services:
pc-dev-base:
# image: sim_dev:gz_harmonic
# container_name: ${PROJECT}-pc-dev
runtime: nvidia # 启用 NVIDIA GPU 支持
stdin_open: true # 保持标准输入打开
tty: true # 分配一个伪终端
privileged: true # 特权模式,允许访问所有 /dev 设备
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- DISPLAY=${DISPLAY}
- NVIDIA_DRIVER_CAPABILITIES=all
volumes:
- /dev/dri:/dev/dri
# - ${WORKSPACE}:/workspace
# - ${DATASET}:/dataset
- /tmp/.X11-unix:/tmp/.X11-unix
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
rk3588-dev-base:
image: rk3588_dev:jazzy
# container_name: ${PROJECT}-rk3588-dev
stdin_open: true # 保持标准输入打开
tty: true # 分配一个伪终端
# volumes:
# - ${WORKSPACE}:/workspace
+34
View File
@@ -0,0 +1,34 @@
{
"name": "VIO Dev Container",
"dockerComposeFile": [
"vio.yaml"
],
"service": "vio-dev",
"runServices": [
"vio-dev"
],
"workspaceFolder": "/workspace",
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind",
"source=/mnt/d/dataset,target=/dataset,type=bind"
],
"shutdownAction": "none",
"containerEnv": {
"http_proxy": "http://host.docker.internal:7897",
"https_proxy": "http://host.docker.internal:7897",
"no_proxy": "localhost,127.0.0.1"
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"llvm-vs-code-extensions.vscode-clangd",
"twxs.cmake"
]
}
},
"remoteUser": "root"
}
+8
View File
@@ -0,0 +1,8 @@
name: vio-dev
services:
vio-dev:
extends:
file: ../common.yaml
service: pc-dev-base
image: sim_dev:gz_harmonic
container_name: vio-dev-pc