Robotics StackExchange | Archived questions

Built in mechanism to prevent multiple instances of same Node

This question was already asked here on ROS answers but no answer was given. Only a suggestion in the comments.

I am building a mobile robot, and using GPIO on the Jetson Nano for the wheel encoder, motor drivers etc. For the wheel encoders, I have a node that maintains the total ticks of both wheel encoders, and publishes those ticks on different topics; leftwheelencoder and rightwheelencoder.

Wheel encoders work by incrementing total ticks, which is kept in two variables (one left and one right) within the WheelEncoderNode class.

It's too easy to launch two WheelEncoderNode nodes that are 1 min apart and will end up publishing different total tick values; obv. the latter one will have a lower count.

Is there a built in mechanism to prevent me from doing that? I mean other than launch files for all packages, which is a requirement.

But I am thinking of maybe a lock file that the WheelEncoderNode creates and checks if it exists, similar to how daemons run. But hoping there's a built-in mechanism in ros for this?

Asked by sameh4 on 2022-12-26 10:49:33 UTC

Comments

Answers

Related issues from ROS2 GitHub I read through:

In general, as per this feature ideas log, uniqueness of node names (see ros2/design#187) is yet to be implemented in the ROS2. So there is no official tool yet for it.

Other place suggests using bondcpp (https://github.com/ros/bond_core/tree/ros2) or other type of software watchdogs. First one is used in the Nav2, so it is a good recommendation.

Asked by ljaniec on 2022-12-26 17:22:18 UTC

Comments