ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I think I put in Uint16 not UInt16 yesterday when I tried this. I fixed it and it compiled but same result.
I put some print commands in so I can see what commands are being executed.
The results of running this is
Main listener rospy.subscriber() when I Ctrl-C it shows rospy.spin()
Looks like the callback function isn't being called.
#!/usr/bin/env python
import roslib; roslib.load_manifest('sensorcsv')
import rospy
from std_msgs.msg import UInt16
def callback(data):
print "Callback"
rospy.loginfo(rospy.get_name()+"I heard %s",data.data)
print rospy.get_name()+"I heard %s"+data.data
def listener():
print "listener"
rospy.init_node('listener', anonymous=True)
rospy.Subscriber("Adc", UInt16, callback)
rospy.spin()
print "rospy.spin()"
if __name__ == '__main__':
print "Main"
listener()
2 | No.2 Revision |
I think I put in Uint16 not UInt16 yesterday when I tried this. I fixed it and it compiled but same result.
I put some print commands in so I can see what commands are being executed.
The results of running this is
Main
listener
rospy.subscriber()
Main
listener
rospy.subscriber()
when I Ctrl-C it shows
shows
rospy.spin()
Looks like the callback function isn't being called.
#!/usr/bin/env python
import roslib; roslib.load_manifest('sensorcsv')
import rospy
from std_msgs.msg import UInt16
def callback(data):
print "Callback"
rospy.loginfo(rospy.get_name()+"I heard %s",data.data)
print rospy.get_name()+"I heard %s"+data.data
def listener():
print "listener"
rospy.init_node('listener', anonymous=True)
rospy.Subscriber("Adc", UInt16, callback)
rospy.spin()
print "rospy.spin()"
if __name__ == '__main__':
print "Main"
listener()