aed5d326a0
症状一(最隐蔽):同一 shell 里先 source 过真机环境(scripts/env.sh)再
source 仿真环境,install/ 与 ros_flexiv 的路径不会被 conda deactivate 撤掉,
长在 install_sim/ 前面:
- PYTHONPATH 里真机那份 arm_msgs 压住仿真那份 → 消息类型混用
- LD_LIBRARY_PATH 里没有 $CONDA_PREFIX/lib → sim_tactile_adapter 订阅
ros_gz_interfaces/Contacts 时抛
Type support not from this implementation ...
cannot open shared object file
而库其实就在 conda 里、ldd 全齐。整条触觉链静默死掉(话题不发)。
症状二:setuptools 写 console_scripts 用的是**构建那一刻**的 python。
若在真机环境里跑过 build_sim.sh,install_sim/ 里 7 个入口脚本的 shebang
会指向 ros_flexiv —— 而 ros2 run 是照 shebang 执行的,于是**仿真节点一直
跑在真机 conda 环境里**。两个环境都是 Humble+py3.11,所以"居然能跑",
只有偶发 dlopen / 反序列化怪错。
修法:
- conda_switch.sh 新增 path_drop_patterns:按 glob 从冒号列表里删条目
- sim_env.sh 清掉真机残留 + 末尾补 $CONDA_PREFIX/lib(优先级最低)
- 新增 lib/fix_shebangs.sh,build.sh / build_sim.sh 收尾各扫一遍(幂等)
Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.2 KiB
Bash
Executable File
37 lines
1.2 KiB
Bash
Executable File
#!/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"
|
|
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_control arm_moveit_config arm_bringup arm_application)
|
|
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"
|