Robotics StackExchange | Archived questions

callback not working

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.

Best,

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)
    pub.publish('orientation_right')
def listener():
    rospy.init_node('listener', anonymous=True)
    print("in sub***************")
    rospy.Subscriber("robot/limb/right/endpoint_state",EndEffectorState, callback)
if __name__ == '__main__':
    listener()
    rospy.spin()

Asked by MiMo on 2016-10-12 09:51:18 UTC

Comments

Answers

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"...

Asked by mgruhler on 2016-10-12 10:02:00 UTC

Comments

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

best,

Asked by MiMo on 2016-10-12 10:20:12 UTC

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

Asked by MiMo on 2016-10-12 12:21:02 UTC

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.

Asked by mgruhler on 2016-10-13 02:30:24 UTC