23 lines
480 B
Bash
23 lines
480 B
Bash
|
|
#!/bin/bash
|
|||
|
|
set -e
|
|||
|
|
|
|||
|
|
# ===== 环境 =====
|
|||
|
|
source /opt/ros/humble/setup.bash
|
|||
|
|
source /home/nvidia/Downloads/sweeper_200/install/setup.bash
|
|||
|
|
|
|||
|
|
# ===== 信号处理(这是核心)=====
|
|||
|
|
terminate() {
|
|||
|
|
echo "[start_ros2] Caught SIGTERM/SIGINT, shutting down ROS2..."
|
|||
|
|
kill -TERM "$ROS2_PID"
|
|||
|
|
wait "$ROS2_PID"
|
|||
|
|
exit 0
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
trap terminate SIGINT SIGTERM
|
|||
|
|
|
|||
|
|
# ===== 启动 launch(前台语义)=====
|
|||
|
|
ros2 launch launch_system start_all.launch.py &
|
|||
|
|
ROS2_PID=$!
|
|||
|
|
|
|||
|
|
wait "$ROS2_PID"
|