Ask Your Question
0

How to start ROS2 node automatically after starting the system?

asked 2019-09-26 00:16:21 -0500

D0l0RES gravatar image

How to make autostart of nodes in ROS2 at system startup? I tried through rc.local and nothing good came of it.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-10-02 03:00:50 -0500

Dmitriy gravatar image

updated 2019-10-02 03:12:17 -0500

We use systemd service with properly defined environment variables, works fine. Example:

[Unit]
Description="Project daemon"

[Service]
Environment="ROS_DOMAIN_ID=42"
Environment="LD_LIBRARY_PATH=/opt/project/install/lib:/opt/ros/dashing/lib"
Environment="PYTHONPATH=/opt/project/install/lib/python3.6/site-packages:/opt/ros/dashing/lib/python3.6/site-packages/"
Environment="AMENT_PREFIX_PATH=/opt/project/install:/opt/ros/dashing"

ExecStart=/opt/ros/dashing/bin/ros2 launch --debug project_bringup project.launch.py
Restart=on-failure

[Install]
WantedBy=multi-user.target
edit flag offensive delete link more
0

answered 2019-09-26 03:07:50 -0500

aPonza gravatar image

updated 2019-09-26 03:15:14 -0500

Not really a ROS-related question, but you likely want to look into cron (assuming *nix since you speak of rc.local) with @reboot, for example as seen in this article.

There are plenty of questions about the details of what else you need to do though: try googling "ros node at startup site:answers.ros.org" and see what's applicable to ROS2 as well.

EDIT: best answer for ROS1 even though I couldn't find a ROS2 equivalent of the robot_upstart package.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-09-26 00:16:21 -0500

Seen: 55 times

Last updated: Oct 02