I need respawn functionality in ROS2. How do I do this? I searched all over the web and the only thing I found is “respawn” is no longer supported attribute.
But none of the docs explain: What is the ROS2 way to achieve the same thing?
ROS Resources: ROS Homepage | Media and Trademarks | Documentation | ROS Index | How to Get Help | Q&A Help Site | Discussion Forum | Service Status |
I need respawn functionality in ROS2. How do I do this? I searched all over the web and the only thing I found is “respawn” is no longer supported attribute.
But none of the docs explain: What is the ROS2 way to achieve the same thing?
I think you should be able to do this with a Lifecycle node
Just start up the node again on the shutdown event and I think you’d get a “respawn” effect.
I think this is an ideal question for answers.ros.org. But I’ll try to answer it anyway, but please consider posting the question and answer there too.
I think the documentation is out of date, because it says here you cannot use respawn any longer:
http://docs.ros.org/en/rolling/Guides/Launch-files-migration-guide.html?highlight=respawn#node
But looking at the api you can ask it to respawn an executable if it crashes or exits (which what I assume you’re asking about):
The “node” action inherits from the executable action, so when defining a node in launch with either python or xml you should be able to specify this argument.
Post to answers and I’ll make a more concrete answer with examples.
I don’t fully understand how to use the respawn parameter. Can you please give an concrete example using a python launch file? (I’m using foxy).
Thanks a lot
Jeremy
Here is an example. we just need to enable respawn
argument.
please post the further question on http://answers.ros.org/ to aggregate the Q&A for the community thanks!
Thanks for the help! I posted a follow up question on https://answers.ros.org/question/382043/ros2-respawn/.
If somebody is looking for a more generic solution: I did some experiments with dinit
service manager in ROS1 context (GitHub - asherikov/cdinit). The goal is to get systemd-like behavior in userspace – service dependencies, startup ordering, restarts, manual starting/stopping, and complement or replace roslaunch. Overall seems to be a plausible approach, should also be transferrable to ROS2. It is of low priority for me, but if somebody is interested I can try to push it forward.