Ask Your Question

Getting an <unexpected keyword argument 'queue_size> error with python3

asked 2021-06-08 11:02:39 -0600

angad gravatar image


I am currently running ROS Noetic on ubuntu20.04 on a raspberry pi 4. I made a simple publisher node and subscriber node with C++ and ran them together flawlessly.

I would like to replicate the results with Python(3).

However, when running my publisher's script, I get this error:

> Traceback (most recent call last):
>         File "", line 7, in <module>
>             rospy.init_node('publisher_1', String, queue_size=10)
> TypeError: init_node() got an unexpected keyword argument 'queue_size'

I have found a few previous discussions regarding this topic, but they all involve software from over 5 years ago.

Any ideas what could be causing this error?

Here is the script in question:

 #!/usr/bin/env python3

    import rospy
    from std_msgs.msg import String

    if __name__=='__main__':
        rospy.init_node('robot_news_radio_transmitter', String, queue_size=10)
            #publisher w name, type (string), queue-size

        rate = rospy.Rate(2)

        while not rospy.is_shutdown():
            msg = String()                     #create message string
   = "transmition test"      #data inside string
        pub.publish(msg)                   #publish
    #doing something every 0.5 seconds

    rospy.loginfo("Node was STOPPED")
edit retag flag offensive close merge delete


This appears to be a duplicate of #q379874.

@angad: please decide which one you want to keep open, and close -- and delete -- the other one.

gvdhoorn gravatar image gvdhoorn  ( 2021-06-09 02:48:09 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-06-08 13:38:18 -0600

gvdhoorn gravatar image

updated 2021-06-08 13:39:27 -0600

if __name__=='__main__':
     rospy.init_node('robot_news_radio_transmitter', String, queue_size=10)

queue_size is not an argument of rospy.init_node(..), but of rospy.Publisher(..).

See the documentation:

__init__(self, name, data_class, subscriber_listener=None, tcp_nodelay=False, latch=False, headers=None, queue_size=None)
edit flag offensive delete link more

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-06-08 11:02:39 -0600

Seen: 90 times

Last updated: Jun 08 '21