也就是说,pub = None
下面的值是多少?何时以及为什么这是一个好习惯?
counter = 0
pub = None
def callback_receive_number_data(msg):
global counter
counter += msg.data
new_msg = Int64()
new_msg.data = counter
pub.publish(new_msg)
sub = rospy.Subscriber('/number', Int64, callback_receive_number_data)
pub = rospy.Publisher('/number_count', Int64, queue_size=10)