부팅하는 동안 시작 파일을 실행하기 위해 systemd를 사용하려고 합니다. 시작 파일이 rplidar를 시작합니다. 파일을 직접 실행하면 .sh
LiDAR가 실행됩니다.
$ systemctl status rosCore.service
● rosCore.service - start roscore
Loaded: loaded (/etc/systemd/system/rosCore.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2018-04-15 09:31:13 CEST; 1min 5s ago
Main PID: 710 (rosCoreService.)
CGroup: /system.slice/rosCore.service
├─ 710 /bin/bash /usr/local/bin/rosCoreService.sh
├─ 940 /usr/bin/python /opt/ros/kinetic/bin/roslaunch rplidar_ros rplidar.launch
├─1029 /usr/bin/python /opt/ros/kinetic/bin/rosmaster --core -p 11311 -w 3 __log:=/root/.ros/log/fa4e9410-407e-11e8-acf8-f5f547bf4eb3/master.log
└─1069 /opt/ros/kinetic/lib/rosout/rosout __name:=rosout __log:=/root/.ros/log/fa4e9410-407e-11e8-acf8-f5f547bf4eb3/rosout-1.log
Apr 15 09:31:13 PLRV1WB1 systemd[1]: Started start roscore.
Apr 15 09:31:14 PLRV1WB1 rosCoreService.sh[710]: Error, cannot bind to the specified serial port /dev/ttyUSB0.
Apr 15 09:31:15 PLRV1WB1 rosCoreService.sh[710]: RPLIDAR running on ROS package rplidar_ros
Apr 15 09:31:15 PLRV1WB1 rosCoreService.sh[710]: SDK Version: 1.5.7
Apr 15 09:31:15 PLRV1WB1 rosCoreService.sh[710]: [rplidarNode-2] process has died [pid 1072, exit code 255, cmd /home/plrv1wb1/catkin_ws/devel/lib/rplidar_ros/rpli
Apr 15 09:31:15 PLRV1WB1 rosCoreService.sh[710]: log file: /root/.ros/log/fa4e9410-407e-11e8-acf8-f5f547bf4eb3/rplidarNode-2*.log
오류는 다음과 같습니다
Apr 15 09:31:14 PLRV1WB1 rosCoreService.sh[710]: Error, cannot bind to the specified serial port /dev/ttyUSB0.
내 서비스와 .sh 파일은 아래와 같습니다.
/etc/systemd/system/
******* rosCore.service *************
Unit]
Description=start roscore
Restart=on-abort
[Service]
ExecStart=/usr/local/bin/rosCoreService.sh
[Install]
WantedBy=default.target
**********************************************
/usr/local/bin/
*******************rosCoreService.sh **********
#!/bin/bash
source /home/bc/.bashrc
source /opt/ros/kinetic/setup.bash
source /home/bc/catkin_ws/devel/setup.bash
roslaunch rplidar_ros rplidar.launch
***************************************************
답변1
다음에 추가
After=dev-ttyUSB0.device
[Unit]
블록 으로 .
충분하지 않은 경우 장치에 태그를 지정해야 합니다 udev
. 바라보다 man systemd.device
:
udev 장치에 태그를 지정하려면 udev 규칙에서 "TAG+="systemd""를 사용하세요.