Skip to content

Using services to launch packages

Michael Hoyer edited this page Feb 24, 2021 · 9 revisions

Add the following in a file called filename.service and move this file into /lib/systemd/system/

With the file her run the command sudo systemctl enable filename.service to enable the startup.sh to run at boot. Other usefull commands are sudo systemctl start/stop/restart/status/etc.

[Unit]
Description=vortex startup

[Service]
User=username
Environment=DISPLAY=:0.0
ExecStart=/home/username/path_to/startup.sh

[Install]
WantedBy=multi-user.target

Create a startup.sh file and place somewhere. It should look something like:

#!/bin/bash
source /opt/ros/melodic/setup.bash
cd ~/catkin_ws
catkin build
source devel/setup.bash

## Workaround for headless gazebo (probably not needed for regular system run, usefull with ssh to run simulations in the background)
export DISPLAY=:0.0

roslaunch package_name some_launch_file.launch