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

rospy.init_node in multiprocessing.Process

asked 2018-07-19 04:56:59 -0500

machinekoder gravatar image

updated 2018-07-19 04:57:37 -0500

Hello everyone,

I have the following setup:

  • The main thread which starts a ROS node with services, pubs, and subs
  • A multiprocessing.Process which also should start an (anonymous) ROS node that has pubs and subs

So far so good. When I start (fork) the new process before calling rospy.init_node, everything works fine when I start from the command line.

However, when I start the application via roslaunch, I get the following error:

shutdown request: new node registered with same name

It looks like roslaunch/node enforces a new name in every node started as a subprocess. Any ideas how to circumvent the problem?

edit retag flag offensive close merge delete


I found the culprit: Looks like the name mappings override even anonymous nodes.

machinekoder gravatar image machinekoder  ( 2018-07-19 05:25:50 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-19 05:27:01 -0500

machinekoder gravatar image

I found a workaround:

    del rospy.names.get_mappings()['__name']
except KeyError:

However, I would prefer if rospy would have an option to force anonymity.

edit flag offensive delete link more

Question Tools



Asked: 2018-07-19 04:56:59 -0500

Seen: 1,054 times

Last updated: Jul 19 '18