#!/usr/bin/env bash # 把 Flexiv RDK v1.x 构建安装到 ~/flexiv_install(真机 / `flexiv_hardware` 必需)。 set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" RDK="${ROOT}/src/flexiv_rdk" PREFIX="${FLEXIV_INSTALL_PREFIX:-$HOME/flexiv_install}" if [[ ! -d "$RDK" ]]; then echo "Missing $RDK — run scripts/fetch_flexiv.sh first" exit 1 fi echo "Building RDK thirdparty deps into $PREFIX ..." # 有系统 /opt/ros 就优先用它;否则 conda 环境里已经有编译器 if [[ -f /opt/ros/humble/setup.bash ]]; then # shellcheck disable=SC1091 source /opt/ros/humble/setup.bash fi cd "$RDK" if [[ -f thirdparty/build_and_install_dependencies_not_in_ros2.sh ]]; then bash thirdparty/build_and_install_dependencies_not_in_ros2.sh "$PREFIX" elif [[ -f thirdparty/build_and_install_dependencies.sh ]]; then bash thirdparty/build_and_install_dependencies.sh "$PREFIX" else echo "No thirdparty build script found; see RDK README" ls thirdparty || true fi rm -rf build && mkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_BUILD_TYPE=Release cmake --build . --target install -j"$(nproc)" echo "RDK installed to $PREFIX" echo "Then: cd $ROOT && colcon build --symlink-install --cmake-args -DCMAKE_PREFIX_PATH=$PREFIX"