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

TypeError: 'Publisher' object is not callable

asked 2016-02-14 12:31:23 -0500

Metalzero2 gravatar image

Hello all.

I am trying to publish to a topic, using python with a custom message file.

My message file name is "joints.msg" and is:

float32 q1
float32 q2
float32 q3

In my python code I have the following (as far a the publisher is concerned):

#!/usr/bin/env python
import rospy
from input_suport import *
from archoff.msg import joints
.
.
.
pub_torques = rospy.Publisher('torque_topic', joints, queue_size=10)
#sub_angles = rospy.Subscriber("angles_topic", joints, get_angles)
rospy.init_node('humerus_m', anonymous=True)
rospy.sleep(1.)
.
.
.
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
        .
        .
        .
    j_speed = joints(dq[0][0], dq[1][0], dq[2][0])
    pub_torques(j_speed)      # first attempt 
    #pub_torques(1.0, 4.2, 3.2)      # second attempt
    rate.sleep()

As you can see above, I tried with two different ways but nothing works. I always get the message:

TypeError: 'Publisher' object is not callable

Any idea what I am doing wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-02-14 12:39:38 -0500

updated 2016-02-14 12:44:00 -0500

you need to put pub_torques.publish(j_speed) to call the objects publish method

See http://wiki.ros.org/ROS/Tutorials/Wri...

edit flag offensive delete link more

Comments

OMG I must be blind! How did I not see that -_-. Thanks very much :)

Metalzero2 gravatar image Metalzero2  ( 2016-02-14 15:18:24 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-02-14 12:31:23 -0500

Seen: 4,372 times

Last updated: Feb 14 '16