#!/usr/bin/env bash set -eo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT" if [[ -f "${HOME}/anaconda3/etc/profile.d/conda.sh" ]]; then # shellcheck disable=SC1091 source "${HOME}/anaconda3/etc/profile.d/conda.sh" elif [[ -f "${HOME}/miniconda3/etc/profile.d/conda.sh" ]]; then # shellcheck disable=SC1091 source "${HOME}/miniconda3/etc/profile.d/conda.sh" set +u conda activate ros_flexiv 2>/dev/null || true set -u 2>/dev/null || true fi if [[ -z "${ROS_DISTRO:-}" ]]; then if [[ -f /opt/ros/jazzy/setup.bash ]]; then # shellcheck disable=SC1091 source /opt/ros/jazzy/setup.bash elif [[ -f /opt/ros/humble/setup.bash ]]; then # shellcheck disable=SC1091 source /opt/ros/humble/setup.bash elif [[ -f /opt/ros/iron/setup.bash ]]; then # shellcheck disable=SC1091 source /opt/ros/iron/setup.bash else echo "未检测到系统 ROS 2;使用 conda ros_flexiv 环境" fi fi PACKAGES=(flexiv_description arm_msgs arm_description arm_kinematics arm_interfaces arm_control arm_driver_flexiv arm_bringup arm_application) # conda GCC 15 把 Humble 消息头里缺的 cstdint 当成错误。补上这个头,仍用 conda 编译器, # 才能和 ros_flexiv 里的 librclcpp 链在一起。 export CXXFLAGS="${CXXFLAGS:-} -include cstdint -Wno-template-body" colcon build --symlink-install --packages-select "${PACKAGES[@]}" "$@" # shellcheck source=lib/fix_shebangs.sh source "${ROOT}/scripts/lib/fix_shebangs.sh" fix_shebangs "${ROOT}/install" "${CONDA_PREFIX:-/usr}/bin/python3" echo "构建完成。请执行: source ${ROOT}/install/setup.bash"