Improve camera status and production startup

This commit is contained in:
2026-06-22 13:54:07 +08:00
parent 55f646053d
commit 7dadcb8bcc
5 changed files with 72 additions and 30 deletions
+33 -3
View File
@@ -16,6 +16,7 @@ readonly SCAN_FIXER_DIR="${SCAN_FIXER_DIR:-$AGV_PROJECT_DIR/scan_fixer}"
readonly LOG_DIR="${LOG_DIR:-/tmp}"
readonly FASTRTPS_SHM_DIR="${FASTRTPS_SHM_DIR:-/dev/shm}"
readonly AGV_CONTROLLER_DEVICE="${AGV_CONTROLLER_DEVICE:-/dev/agvpro_controller}"
readonly UV_BIN="${UV_BIN:-}"
export ROS_DOMAIN_ID="${ROS_DOMAIN_ID:-1}"
# 日志文件
@@ -131,6 +132,32 @@ ros2_exec() {
' _ "$ROS_SETUP" "$ROS_WORKSPACE_SETUP" "$ROS_DOMAIN_ID" "$@"
}
resolve_uv_bin() {
if [ -n "$UV_BIN" ]; then
if [ -x "$UV_BIN" ]; then
echo "$UV_BIN"
return 0
fi
return 1
fi
local candidate
candidate=$(command -v uv 2>/dev/null || true)
if [ -n "$candidate" ]; then
echo "$candidate"
return 0
fi
for candidate in "$HOME/.local/bin/uv" "$HOME/.cargo/bin/uv"; do
if [ -x "$candidate" ]; then
echo "$candidate"
return 0
fi
done
return 1
}
# ============================================================================
# ROS2 环境操作
# ============================================================================
@@ -184,8 +211,11 @@ stop_ros2_daemon() {
pkill -9 -f "ros2-daemon" 2>/dev/null || true
sleep 2
source "$ROS_SETUP" 2>/dev/null || true
ros2 daemon stop 2>/dev/null || true
bash -c '
source "$1" || exit 0
export ROS_DOMAIN_ID="$2"
ros2 daemon stop
' _ "$ROS_SETUP" "$ROS_DOMAIN_ID" 2>/dev/null || true
echo " [OK] ros2 daemon 已重置"
}
@@ -223,7 +253,7 @@ wait_for_nodes() {
while [ "$elapsed" -lt "$max_wait" ]; do
local nodes
nodes=$(ros2_exec ros2 node list 2>/dev/null || true)
nodes=$(ros2_exec timeout 8 ros2 node list --no-daemon --spin-time 3 2>/dev/null || true)
count=$(printf '%s\n' "$nodes" | grep -cE "$pattern" || true)
if [ "$count" -ge "$expected" ]; then
echo " [OK] 已检测到 $count 个节点"