sweeper_200/start_all.sh

23 lines
480 B
Bash
Raw Normal View History

2025-10-30 11:10:23 +08:00
#!/bin/bash
set -e
2026-02-28 17:00:02 +08:00
# ===== 环境 =====
source /opt/ros/humble/setup.bash
source /home/nvidia/Downloads/sweeper_200/install/setup.bash
2026-01-30 09:30:02 +08:00
2026-02-28 17:00:02 +08:00
# ===== 信号处理(这是核心)=====
terminate() {
echo "[start_ros2] Caught SIGTERM/SIGINT, shutting down ROS2..."
kill -TERM "$ROS2_PID"
wait "$ROS2_PID"
exit 0
}
2025-10-30 11:10:23 +08:00
2026-02-28 17:00:02 +08:00
trap terminate SIGINT SIGTERM
# ===== 启动 launch前台语义=====
2026-01-30 09:30:02 +08:00
ros2 launch launch_system start_all.launch.py &
2026-02-28 17:00:02 +08:00
ROS2_PID=$!
2025-11-03 16:13:55 +08:00
2026-02-28 17:00:02 +08:00
wait "$ROS2_PID"