Ask Your Question

callback not working

asked 2016-10-12 09:51:18 -0500

MiMo gravatar image

updated 2016-10-12 12:23:47 -0500

Hello Everyone, I have problem with my subscriber my code is as bellow, the problem is that, the callback function is not executed, and I cannot see the topic /test in my topic list. Thank you so much in advance.


def callback(msg):

    print("in callback right")
    position_right[0] = msg.pose.position.x
    position_right[1] = msg.pose.position.y
    position_right[2] = msg.pose.position.z
    print "position_x = %s" % position_right[0]
    orientation_right[0] = msg.pose.orientation.x
    orientation_right[1] = msg.pose.orientation.y
    orientation_right[2] = msg.pose.orientation.z
    orientation_right[3] = msg.pose.orientation.w
    pub = rospy.Publisher('/test', Float32 , queue_size=10)
def listener():
    rospy.init_node('listener', anonymous=True)
    print("in sub***************")
    rospy.Subscriber("robot/limb/right/endpoint_state",EndEffectorState, callback)
if __name__ == '__main__':
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-10-12 10:02:00 -0500

mgruhler gravatar image

One mistake you have is that you expect to get data from type geometry_msgs/Pose but the Subscriber is subscribing to a message of type std_msgs/UInt16.

Also, please be more specific about what "is not working"...

edit flag offensive delete link more


thank you for your answer, the callback is not called I can't see the the topic /test in my published topics.


MiMo gravatar image MiMo  ( 2016-10-12 10:20:12 -0500 )edit

hey I updated the code and still not working, is it right pls help

MiMo gravatar image MiMo  ( 2016-10-12 12:21:02 -0500 )edit

please post the output of rostopic list as well as rosnode info <YOUR_NODE>.

You cannot see the topic test because the publisher is not instantiated as long as the callback isn't called.

mgruhler gravatar image mgruhler  ( 2016-10-13 02:30:24 -0500 )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: 2016-10-12 09:51:18 -0500

Seen: 578 times

Last updated: Oct 12 '16