There are plenty of google and answers.ros hits on this but they all seem a bit complicated and also not necessarily up to the latest date. Here are some, of various vintages and from various sources. We’re trying them but nothing is “smooth”, hence this question
We are running ROS 1 Noetic on Ubuntu 20.04 on Turtlebot3s with Rasberry Pi 3+. We would like to create a ROS .launch file which is automatically run when the OS first starts up. This is not totally trivial because to ROS launch you need to have the environment set up correctly and also be the “correct” user; and there are probably other pre-requisites that I don’t even know about.
What do people think is the “best” way to do this nowadays?
Somewhat related too, you can package your application as a snap and have it run has a daemon. In this blog series we did just that for the TurtleBot3. Upon boot the robot is ready to go (controller, sensors, tf tree, teleop, etc). Check also this short video.
If on Ubuntu, the simplest way is to manually create a startup application. Click on the icon “Startup Application” on the activities, then “Add”. Then customize the name and fill the command field with: terminator -e "bash -i -c 'sleep 3 && ros2 launch myrobot_bringup myrobot_bringup.launch'"
if ROS1 i guess it will be more something like : terminator -e "bash -i -c 'sleep 3 && roslaunch myrobot_bringup myrobot_bringup.launch'"
This assumes you have terminator installed, you can adapt to whatever terminal emulator you prefer using (the flags could then be different). I use sleep 3 to wait 3 seconds after startup before launching ros (I have few things that take a bit of time starting).
And course the creation of the startup application can be automated in a script.