Created
March 15, 2014 07:28
-
-
Save hanxue/9563032 to your computer and use it in GitHub Desktop.
ROS Python Publisher Subscriber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# license removed for brevity | |
import rospy | |
from std_msgs.msg import String | |
def talker(): | |
pub = rospy.Publisher('chatter', String) | |
rospy.init_node('talker', anonymous=True) | |
r = rospy.Rate(10) # 10hz | |
while not rospy.is_shutdown(): | |
str = "hello world %s"%rospy.get_time() | |
rospy.loginfo(str) | |
pub.publish(str) | |
r.sleep() | |
if __name__ == '__main__': | |
try: | |
talker() | |
except rospy.ROSInterruptException: pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment