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

How to subscribe to Nao tactile sensor? [closed]

asked 2014-02-20 19:28:30 -0600

dnth gravatar image

Below are the codes for my listener node. What am I missing? The output doesn't show anything.

#!/usr/bin/env python
import rospy
from std_msgs.msg import String
    def callback(data):
    rospy.loginfo(rospy.get_name()+ ": I heard %s" % data.data)


def tactilelistener():
    rospy.init_node('tactilelistener', anonymous=True)
    rospy.Subscriber("tactile_touch", String, callback)
    rospy.spin()

if __name__== '__main__':
    tactilelistener()
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Vincent Rabaud
close date 2014-08-01 06:19:56.984948

1 Answer

Sort by » oldest newest most voted
2

answered 2014-02-23 21:49:28 -0600

dnth gravatar image

updated 2014-02-23 21:50:03 -0600

I got it working with this code. Please also refer to nao_driver and nao_msgs

#!/usr/bin/env python
import rospy
from nao_msgs.msg import TactileTouch

def callback(data):
    rospy.loginfo( "I heard %u %u" % (data.button, data.state))

def tactilelistener():

    # in ROS, nodes are unique named. If two nodes with the same
    # node are launched, the previous one is kicked off. The 
    # anonymous=True flag means that rospy will choose a unique
    # name for our 'talker' node so that multiple talkers can
    # run simultaenously.
    rospy.init_node('tactilelistener', anonymous=True)

    rospy.Subscriber("tactile_touch", TactileTouch, callback)

    # spin() simply keeps python from exiting until this node is stopped
    rospy.spin()

if __name__ == '__main__':
    tactilelistener()
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-02-20 19:28:30 -0600

Seen: 318 times

Last updated: Feb 23 '14