Raspberry Pi: Setting ROS to Start on Boot - LoCO-AUV/loco_config GitHub Wiki

In order to start ROS systems on boot, we use a systemd service to run a script. This script launches several roslaunch files. Setting this all up is pretty straightforward.

systemd Service

The required service file is provided in loco_config under /rpi_config_files, called ros-start.service. Put it into /etc/systemd/system, then run the following command.

sudo systemctl enable ros-start.service

Now the service is enabled.

Bash Script

For the service to have anything to run, we need to have the appropriate script in our RPI's home directory. That file is also provided in loco_config under /rpi_config_files, called ros-start.bash. This file should be put in the /home/user/ directory. For us, that's /home/irvlab, but you might need to change the name (if so, make sure that references to it in ros-start service are also changed. Once the file is in the appropriate place, make it executable.

Preparing the ROS launch files for startup

The ros-start bash script starts a variety of launch file from packages including mavros, robot_localization, loco_pilot, and the camera launch file from loco_launch. You need to simply make sure that you've got all the required launch files and packages installed, and that they work individually, and you should be golden.