ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Run ROS2 launch after startup

asked 2021-01-25 09:01:09 -0500

jmedik gravatar image

Hi Guys, last few hours I'm struggling with the problem how to start ROS launch file automatically after boot. I put all nodes into one script robot_marker_launch.py and it is working fine. But I'm not able to figure out how to start it automatically. I need to source the ROS in the terminal and then start the launch file.

I found Ros_launch but it is for the older versions and not for ROS2 and Foxy The next Idea was to start the script using of crontab -e but it went wrong because I was not able source the ros2 files.

Can somebody give me a hint either how to start the script or how to make a workaround and don't use the source command in the crontab.

I'm using Raspberry Pi with Ubuntu 20.04 and Foxy

Thank you

edit retag flag offensive close merge delete

Comments

Not specific to this exact questions but see this question on robot_upstart and maybe look into system services.

JackB gravatar image JackB  ( 2021-01-25 10:32:32 -0500 )edit

For a workaround using crontab you can run your command using an interactive bash like this : bash -ic "ros2 launch [...]". As long as you source your workspace in your .bashrc it should work.

Mackou gravatar image Mackou  ( 2021-01-26 02:27:12 -0500 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2021-01-26 12:55:03 -0500

jmedik gravatar image

Hi all, thanks you for the comments. Meanwhile, I solved the issue: I put all the "ROS" variables printenv | grep -i ROS^C into the /etc/environment. After restart I call the /opt/ros/foxy/bin/ros2 launch script.sh after using the crontab.

edit flag offensive delete link more
0

answered 2021-01-26 09:10:21 -0500

shlokgoel gravatar image

you can source the ros2 environment by adding it to your .bashrc and then use crontab -e to start the ros2 nodes at startup.

The following command will source your ros2 environment everytime you open a new terminal automatically:

echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-01-25 09:01:09 -0500

Seen: 2,306 times

Last updated: Jan 26 '21