Last active
August 29, 2015 14:12
-
-
Save detik19/70f46602666cf8174956 to your computer and use it in GitHub Desktop.
Simple Publisher Using Rospy
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 | |
import roslib; roslib.load_manifest('beginner_tutorials') | |
import rospy | |
from std_msgs.msg import String | |
def talker(): | |
pub = rospy.Publisher('chatter', String) | |
rospy.init_node('talker') | |
while not rospy.is_shutdown(): | |
#subtitute the time to message | |
str="Hello ROS World %s" % rospy.get_time() | |
#loginfo() | |
#gets the message printed to screen | |
#gets it written to the Node's log file | |
#gets it written to rosout | |
rospy.loginfo(str) | |
pub.publish(String(str)) | |
rospy.sleep(1.0) | |
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