0

I am trying to run a launch file during boot up using systemd. The launch file launches rplidar. When I run directly the .sh file it's launching the 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

The error is

Apr 15 09:31:14 PLRV1WB1 rosCoreService.sh[710]: Error, cannot bind to the specified serial port /dev/ttyUSB0.

My service and .sh file looks like this.

/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

***************************************************
0

1 Answer 1

1

Add

After=dev-ttyUSB0.device

to the [Unit] block.

If that is not enough then you have to tag the device in udev. See man systemd.device:

To tag a udev device, use "TAG+="systemd"" in the udev rules

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.