1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| function init_ros_noetic() { source /opt/ros/noetic/setup.bash echo "ROS Noetic 已初始化!" }
function init_ros_foxy() { source /opt/ros/foxy/setup.bash echo "ROS Foxy 已初始化!" }
if [[ $- == *i* ]]; then echo "========================" echo "是否初始化 ROS 环境?" echo "1: 初始化 ROS Noetic (ROS1)" echo "2: 初始化 ROS Foxy (ROS2)" echo "其他: 跳过 ROS 初始化" echo "========================" read -p "请输入你的选择 (1/2/其他): " ros_choice case $ros_choice in 1) init_ros_noetic ;; 2) init_ros_foxy ;; *) echo "未初始化 ROS 环境" ;; esac fi
|