Systemd roslaunch
I've recently migrated my ROS project to Ubuntu 16.04LTS and ROS kinetic since I was having stability issues with Ubuntu 14.04LTS. Unfortunately this means I can't use robot upstart anymore to run my roslaunch file at startup (afaik).
I've made an attempt at using systemd (based on this guide) to run a bash script which runs roslaunch at startup but I'm stuck trying to get everything to work.
my systemd file: (chmod 664)
[Unit]
Description=start runslam
After=mysql.service
[Service]
ExecStart=/usr/local/bin/runslam.sh
KillMode=process
[Install]
WantedBy=default.target
my bash script: (chmod +x)
#!/bin/bash
roslaunch runslam slam.launch
Just running the bash script from the terminal starts up roscore and my project runs fine but when running:
$ sudo systemctl start runslam.service
$ systemctl status runslam.service
I get the following output:
● runslam.service - start runslam
Loaded: loaded (/etc/systemd/system/runslam.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2016-10-06 11:36:29 AEST; 7s ago Process: 3746 ExecStart=/usr/local/bin/runslam.sh (code=exited, status=127) Main PID: 3746 (code=exited, status=127)Oct 06 11:36:29 ausdroid-sbc-flt1 systemd[1]: Started start runslam.
Oct 06 11:36:29 ausdroid-sbc-flt1 runslam.sh[3746]: /usr/local/bin/runslam.sh: line 3: roslaunch: command not found
Oct 06 11:36:29 ausdroid-sbc-flt1 systemd[1]: runslam.service: Main process exited,> code=exited, status=127/n/a
Oct 06 11:36:29 ausdroid-sbc-flt1 systemd[1]: runslam.service: Unit entered failed state.
Oct 06 11:36:29 ausdroid-sbc-flt1 systemd[1]: runslam.service: Failed with result 'exit-code'.
I think "roslaunch: command not found" means that the ROS environment needs to be somehow specified in the systemd file does anyone know how to do this? Thanks.
Note it may be advisable to use
KillSignal=2
asroslaunch
seems to respond toSIGINT
instead of the defaultSIGTERM