Exercise 2.3 : shutdown request: new node registered with same name

Hi,
When i launch the Age launch file the rate.sleep() throws the shutdown request saying that the new node is registered with the same name. I don’t understand this issue and don’t know how to resolve it. Kindly help.

Reference:
process[publishAge_node-1]: started with pid [10325]
shutdown request: new node registered with same name
Traceback (most recent call last):
File “/home/user/catkin_ws/src/robot_odo/src/Age.py”, line 16, in
rate.sleep()
File “/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/timer.py”, line 103, in sleep
sleep(self._remaining(curr_time))
File “/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/timer.py”, line 166, in sleep
raise rospy.exceptions.ROSInterruptException(“ROS shutdown request”)
rospy.exceptions.ROSInterruptException: ROS shutdown request

Hi @sanjayatj,

This means you have used the same node name more than once in your Python or launch files, or you’re trying to launch the same program when it’s already running. Please check the following for this repetition:

  • Your rospy.init_node() statements.
  • Your launch file node declaration
<node name="whatever" ... />

Hi @bayodesegun
I checked my code and launch file as well. The ‘sleep’ function was not repeated. Please find my code and launch file below for reference. My package name is robot_odo.

Age code:
#! /usr/bin/env python

import rospy

from robot_odo.msg import Age

rospy.init_node(‘publishAge_node’)

pub = rospy.Publisher(’/age_info’, Age, queue_size=1)

rate = rospy.Rate(2)

age = Age()

age.years = 25

age.months = 8

age.days = 18

while not rospy.is_shutdown():

pub.publish(age)

rate.sleep()

Age Launch File

Hi @sanjayatj,

This has nothing to do with the sleep() function. It’s about the name you used for your node in your python code and launch file.

I see that you used “publishAge_node” as the name of your node in the Python file:

rospy.init_node(‘publishAge_node’)

Is this the same name you used in your launch file (please refer to my previous post)? If so, you can change it. It could also be that you are using this exact name somewhere else in another launch file.

If unsure, please paste your launch file code here.

Hi @bayodesegun

This is my launch file
launch
node pkg=“robot_odo” type=“Age.py” name=“publishAge_node” output=“screen”
/launch

Questions:

  1. I was under the understanding that, while writing the python script i have to initialize the node by giving the same node name as in the launch file (In this case publishAge_node). Is my understanding wrong?

  2. The error that threw up (as mentioned in my initial post) indicated the rate.sleep() in line 16 of my package path and sleep(self._remaining(curr_time)) in line 103 of a different path. That is why i thought it had something to do with sleep function. So if it had nothing to do with sleep, please help me understand why it was mentioned in the error statement.

Actually, when i run roslaunch, the launch does not display anything and it just waits. When i hit the ctrl+C after about 5 mins the error mentioned in the initial questions shows up.

Thank you in advance!

1 Like

Hi @sanjayatj,

Answers:

  1. You are partly right, you can use the same name in the python and launch file, but you don’t have to.
  2. the sleep() was mentioned because that’s where the error showed up. But as for what is causing the error, it’s hinted in this statement: shutdown request: new node registered with same name.

The key thing is that you’re asking ROS to start two programs (nodes) with the same name, and it could be that:

  • You’re running another program where you are specifying the same node name.
  • You’re trying to run the same program when it’s already running (maybe in another terminal).

To reset all programs running, try changing to a unit with a different simulation and then come back to the current unit.

@bayodesegun
Thank you! I’ll try your suggestions and get back to you with the results. :slightly_smiling_face:

1 Like