Skip to content

Instantly share code, notes, and snippets.

@chaonan99
Created March 22, 2018 00:16
Show Gist options
  • Save chaonan99/717f96d58aaad169388332cfafe60725 to your computer and use it in GitHub Desktop.
Save chaonan99/717f96d58aaad169388332cfafe60725 to your computer and use it in GitHub Desktop.
A ROS publisher publishing increasing int number
#!/usr/bin/python2
import rospy
from std_msgs.msg import String
pub = rospy.Publisher('addup_number', String, queue_size=10)
rospy.init_node('repub_test_pub', anonymous=True)
r = rospy.Rate(1)
i = 0
while not rospy.is_shutdown():
pub.publish(str(i))
rospy.loginfo("Publish {}".format(i))
i += 1
r.sleep()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment