1. start.sh#!/bin/bash # JzBot 启动脚本 - 使用后台进程不依赖桌面 # 检查ROS2环境 if [ -f /opt/ros/humble/setup.bash ]; then source /opt/ros/humble/setup.bash fi # 检查工作空间 if [ -f /home/bsbot/bsbot_clean/install/setup.bash ]; then source /home/bsbot/bsbot_clean/install/setup.bash fi # 激活CAN接口 source /home/jzbot/jzbot_clean/src/differential_drive_can/scripts/can_activate.sh # 启动节点到后台 echo 启动 SocketCAN Bridge... ros2 launch ros2_socketcan socket_can_bridge.launch.xml sleep 2 echo 启动 Differential Drive CAN Node... source install/setup.bash ros2 run differential_drive_can differential_drive_can_node sleep 3 echo 启动 JZBot Joy Control... source install/setup.bash ros2 launch jzbot_joy joy.launch.py echo 所有节点已启动 wait2. start.servicesudo gedit /etc/systemd/system/jzbot.service[Unit] DescriptionJZBot ROS2 System [Service] Typesimple Userjzbot WorkingDirectory/home/jzbot/jzbot_clean ExecStart/home/jzbot/jzbot_clean/start_jzbot.sh Restarton-failure RestartSec5 [Install] WantedBymulti-user.target# 给脚本加执行权限 chmod x /home/jzbot/jzbot_clean/start_jzbot.sh # 重载服务 sudo systemctl daemon-reload sudo systemctl enable jzbot.service sudo systemctl start jzbot.service # 查看日志 sudo journalctl -u bsbot.service -f