Ask Your Question

Error : rospy.init_node() has already been called with different arguments:

asked 2021-02-12 06:01:45 -0600

tq1992 gravatar image

updated 2021-12-21 10:34:09 -0600

130s gravatar image

In my project i have one publisher file ( publish rpm for a wheel) and one subscriber file (calculate the speed of the wheel based on rpm value )

the code works fine until i try to publish the speed to another node called "speed" and it gives me this error rospy.init_node() has already been called with different arguments:

the subscriber file code as below:

import rospy
from std_msgs.msg import String , Float64
import math

def calculate_speed(rpm):
    radius = 5.1
    speed =*2.0*(math.pi)*radius

def rpm_subscriber():
    rospy.Subscriber('rpm' , Float64 , calculate_speed)

def speed_publish():
    pub = rospy.Publisher("speed" , Float64 , queue_size=10)

    rate = rospy.Rate(5)

if __name__ == '__main__':


please help i have been stuck here for an hours

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-02-12 10:59:44 -0600

mgruhler gravatar image

Well, the error is pretty clear. You have two calls to rospy.init_node() in your code. One executable equals one ROS node, and should thus only have one call to rospy.init_node(). You'd need to split your code into two executables, if this should be two nodes...

edit flag offensive delete link more


thanks man

tq1992 gravatar image tq1992  ( 2021-12-21 10:42:15 -0600 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2021-02-12 06:01:45 -0600

Seen: 202 times

Last updated: Dec 21 '21