chore: 框架科学优化前的完整基线
在开始'设备契约层 + 目录重构 + 通止规装配'改造之前,先钉住当前可运行状态, 使后续任何删除/重构都可回退。 本基线包含: - 现有 ROS 2 工作区全部源码(arm_application / arm_control / arm_bringup 等) - 官方 flexiv_ros2 栈(含 flexiv_hardware / flexiv_controllers 等符号链接) - 设备契约层 src/arm_interfaces(新增,46 项单测通过) - devices/ 设备选型与品牌清单(新增) - scripts/gen_site_example.py 与由它生成的 config/site.example.yaml 按 .gitignore 排除:build/ / install/ / log/ / config/site.yaml / 模型权重二进制。
This commit is contained in:
Executable
+116
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env bash
|
||||
# Clone official Flexiv ROS 2 stack for Rizon (RDK v1.x → humble-v1 branch).
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SRC="${ROOT}/src"
|
||||
BRANCH="${FLEXIV_ROS2_BRANCH:-humble-v1}"
|
||||
|
||||
mkdir -p "${SRC}"
|
||||
cd "${SRC}"
|
||||
|
||||
# Always ensure official URDF package is present (meshes + xacro)
|
||||
if [[ ! -d flexiv_description ]]; then
|
||||
echo "Fetching flexiv_description (${BRANCH})..."
|
||||
if ! git clone --depth 1 -b "${BRANCH}" https://github.com/flexivrobotics/flexiv_description.git; then
|
||||
echo "git clone slow/failed — downloading zip..."
|
||||
python3 - <<PY
|
||||
import urllib.request, socket, zipfile, io, shutil, os
|
||||
url = "https://codeload.github.com/flexivrobotics/flexiv_description/zip/refs/heads/${BRANCH}"
|
||||
old = socket.getaddrinfo
|
||||
socket.getaddrinfo = lambda h, p, f=0, t=0, pr=0, fl=0: [ai for ai in old(h, p, socket.AF_INET, t, pr, fl)]
|
||||
data = urllib.request.urlopen(urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}), timeout=300).read()
|
||||
dest = "${SRC}/flexiv_description"
|
||||
with zipfile.ZipFile(io.BytesIO(data)) as z:
|
||||
z.extractall("/tmp")
|
||||
shutil.rmtree(dest, ignore_errors=True)
|
||||
shutil.move("/tmp/flexiv_description-${BRANCH}", dest)
|
||||
print("flexiv_description ready at", dest)
|
||||
PY
|
||||
fi
|
||||
else
|
||||
echo "flexiv_description already present"
|
||||
fi
|
||||
|
||||
if [[ ! -d flexiv_ros2 ]]; then
|
||||
echo "Cloning flexiv_ros2 (${BRANCH})..."
|
||||
git clone https://github.com/flexivrobotics/flexiv_ros2.git -b "${BRANCH}"
|
||||
else
|
||||
echo "flexiv_ros2 already present — pull if needed: git -C flexiv_ros2 pull"
|
||||
fi
|
||||
|
||||
REPOS_FILE=""
|
||||
for candidate in flexiv_ros2/flexiv.humble.repos flexiv_ros2/flexiv.repos; do
|
||||
if [[ -f "${candidate}" ]]; then
|
||||
REPOS_FILE="${candidate}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "${REPOS_FILE}" ]]; then
|
||||
echo "ERROR: no .repos file found under flexiv_ros2"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Importing dependencies from ${REPOS_FILE}..."
|
||||
if ! command -v vcs >/dev/null 2>&1; then
|
||||
echo "Please install: sudo apt install python3-vcstool"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prefer local Flexiv_Rizon4 RDK (avoids GitHub clone when present)
|
||||
LOCAL_FLEXIV="${LOCAL_FLEXIV:-$HOME/文档/Flexiv_Rizon4}"
|
||||
if [[ -d "${LOCAL_FLEXIV}/flexiv_rdk" ]]; then
|
||||
echo "Using local RDK: ${LOCAL_FLEXIV}/flexiv_rdk"
|
||||
bash "${ROOT}/scripts/use_local_flexiv.sh"
|
||||
elif [[ -d flexiv_rdk ]]; then
|
||||
touch flexiv_rdk/COLCON_IGNORE
|
||||
else
|
||||
echo "Importing flexiv_rdk from ${REPOS_FILE}..."
|
||||
vcs import "${SRC}" < "${REPOS_FILE}" --recursive --skip-existing
|
||||
if [[ -d flexiv_rdk ]]; then
|
||||
touch flexiv_rdk/COLCON_IGNORE
|
||||
fi
|
||||
fi
|
||||
|
||||
# Always import remaining deps from repos (description already handled; skip-existing)
|
||||
vcs import "${SRC}" < "${REPOS_FILE}" --recursive --skip-existing || true
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Done. Next steps (Ubuntu 22.04 / Humble + Rizon):
|
||||
|
||||
Local RDK wired via: scripts/use_local_flexiv.sh
|
||||
src/flexiv_rdk -> ${LOCAL_FLEXIV}/flexiv_rdk (your copy, often RDK 2.x)
|
||||
src/flexiv_rdk_v1 -> RDK 1.9.1 for flexiv_ros2 humble-v1 (if present)
|
||||
|
||||
1) Install ROS deps:
|
||||
sudo apt install -y python3-colcon-common-extensions python3-vcstool \\
|
||||
ros-humble-ros2-control ros-humble-ros2-controllers \\
|
||||
ros-humble-moveit ros-humble-xacro ros-humble-joint-state-publisher-gui
|
||||
|
||||
2) Build & install RDK **v1.9.1** into ~/flexiv_install (for flexiv_hardware):
|
||||
RDK_SRC=${SRC}/flexiv_rdk_v1
|
||||
# fallback if only one tree: RDK_SRC=${SRC}/flexiv_rdk
|
||||
cd \${RDK_SRC}/thirdparty
|
||||
source /opt/ros/humble/setup.bash # or: conda activate ros_flexiv
|
||||
bash build_and_install_dependencies_not_in_ros2.sh ~/flexiv_install
|
||||
cd \${RDK_SRC} && rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_INSTALL_PREFIX=~/flexiv_install -DCMAKE_PREFIX_PATH=~/flexiv_install
|
||||
cmake --build . --target install --config Release
|
||||
|
||||
3) Build this workspace:
|
||||
cd ${ROOT}
|
||||
source /opt/ros/humble/setup.bash
|
||||
colcon build --symlink-install --cmake-args -DCMAKE_PREFIX_PATH=~/flexiv_install
|
||||
source install/setup.bash
|
||||
|
||||
4) Real robot (site SN, no gripper yet):
|
||||
ros2 launch arm_bringup real.launch.py
|
||||
# or explicitly:
|
||||
ros2 launch arm_bringup real.launch.py robot_sn:=Rizon4-063989 load_gripper:=false
|
||||
|
||||
Official fake hardware:
|
||||
ros2 launch flexiv_bringup rizon.launch.py robot_sn:=Rizon4-063989 use_fake_hardware:=true load_gripper:=false
|
||||
|
||||
EOF
|
||||
Reference in New Issue
Block a user