Files
RC2027_BR_code/minco_ws/scripts/deploy_to_robot.sh
T
Kevin a2947065b3 feat(minco_ws): MID360 + Point-LIO + SCAN/MINCO 导航工作区(19 个包)
- scan/: SCAN 无图局部规划(6 包)+ step_blocker(台阶封堵)+ body_odom(雷达→车体中心)
- navigation/: MINCO + Nav2 有图方案;perception/: Livox 驱动 + Point-LIO + rog_map
- chassis/: R2 底盘串口桥
- docs/: QUICKSTART(上机流程)/ SCAN_VEHICLE(方案与限制)/ DEPLOY_ROBOT(双机部署)
- scripts/: setup_deps.sh(依赖体检/安装)+ deploy_to_robot.sh(rsync 同步/远程编译)

排除 build/ install/ log/、PCD 地图(155 MB,单独 rsync)。
2026-10-20 10:51:18 +08:00

88 lines
2.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 把工作区同步到机器人小电脑(GMK M6),可选地在那边直接编译。
#
# bash scripts/deploy_to_robot.sh <user>@<host> # 只同步
# bash scripts/deploy_to_robot.sh <user>@<host> --build # 同步并远程编译
# bash scripts/deploy_to_robot.sh <user>@<host> --dry-run # 只看会传什么
#
# 只传 src/ docs/ scripts/,**永远不传** build/ install/ log/。
# 目标机默认路径 ~/RC2027_BR_code/minco_ws(可用环境变量 REMOTE_WS 覆盖)。
#
# 前置:两边都装好 rsync(sudo apt install rsync);已配置 SSH 免密更好。
set -euo pipefail
DEST="${1:-}"
if [ -z "$DEST" ] || [ "$DEST" = "-h" ] || [ "$DEST" = "--help" ]; then
sed -n '2,12p' "$0"
exit 0
fi
shift
DO_BUILD=0
DRY=""
for a in "$@"; do
case "$a" in
--build) DO_BUILD=1 ;;
--dry-run) DRY="--dry-run" ;;
*) echo "未知参数: $a" >&2; exit 2 ;;
esac
done
SRC_WS="$(cd "$(dirname "$0")/.." && pwd)"
REMOTE_WS="${REMOTE_WS:-RC2027_BR_code/minco_ws}" # 相对家目录
echo "== 同步 =="
echo " 源 : $SRC_WS"
echo " 目标: $DEST:~/$REMOTE_WS"
[ -n "$DRY" ] && echo " (dry-run,不会真的写)"
# 排除项:
# build/ install/ log/ —— 构建产物,路径写死且全是符号链接
# __pycache__ *.pyc —— 无意义且会造成“改了没生效”的错觉
# .git —— 不需要,传过去反而大
rsync -az --info=stats2 $DRY \
--exclude 'build/' \
--exclude 'install/' \
--exclude 'log/' \
--exclude '__pycache__/' \
--exclude '*.pyc' \
--exclude '.git/' \
"$SRC_WS/" "$DEST:~/$REMOTE_WS/"
if [ "$DO_BUILD" -eq 0 ] || [ -n "$DRY" ]; then
cat <<EOF
== 下一步(在机器人上)==
cd ~/$REMOTE_WS
bash scripts/setup_deps.sh # 第一次必做
source /opt/ros/humble/setup.bash
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release \\
-DPython3_EXECUTABLE=/usr/bin/python3 --parallel-workers 6
EOF
exit 0
fi
echo
echo "== 远程编译(6 核并行,约 20-30 分钟)=="
ssh "$DEST" "WS=~/$REMOTE_WS bash -s" <<'REMOTE'
set -e
cd "$WS"
source /opt/ros/humble/setup.bash
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release \
-DPython3_EXECUTABLE=/usr/bin/python3 --parallel-workers 6
source install/setup.bash
echo
echo "== 注册检查 =="
for p in scan_planner step_blocker body_odom techx_r2_chassis_control; do
if ros2 pkg prefix "$p" >/dev/null 2>&1; then
echo " OK $p"
else
echo " FAIL $p"
fi
done
REMOTE
echo
echo "编译完成。落地前记得先跑 docs/DEPLOY_ROBOT.md 的检查清单(网口/串口/标定)。"