Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

ros python publisher

#!/usr/bin/env python
# license removed for brevity
import rospy
from std_msgs.msg import String

def talker():
    pub = rospy.Publisher('chatter', String, queue_size=10)
    rospy.init_node('talker', anonymous=True)
    rate = rospy.Rate(10) # 10hz
    while not rospy.is_shutdown():
        hello_str = "hello world %s" % rospy.get_time()
        rospy.loginfo(hello_str)
        pub.publish(hello_str)
        rate.sleep()

if __name__ == '__main__':
    try:
        talker()
    except rospy.ROSInterruptException:
        pass
Comment

PREVIOUS NEXT
Code Example
Python :: pyside 
Python :: how to take input for list in python 
Python :: how to play mp3 files using vlc python library 
Python :: for i 
Python :: Python Django Models Unique Rows 
Python :: python recursively print directory 
Python :: max of three numbers in python 
Python :: python webdriver disable logs 
Python :: find all color in image python 
Python :: python how to draw a square 
Python :: get json from file python 
Python :: change value in excel using python 
Python :: cryptography python 
Python :: non-default argument follows default argument 
Python :: count number of each item in list python 
Python :: program to print duplicates from a list of integers in python 
Python :: flask blueprint static folder 
Python :: keep only one duplicate in pandas 
Python :: python challenges 
Python :: get subscriber count with python 
Python :: maxsize in python 
Python :: 3d array numpy 
Python :: run exe from python 
Python :: panda search strings in column 
Python :: initialise a 2d array python 
Python :: python how to get the last element in a list 
Python :: pyplot new figure 
Python :: How to wait a page is loaded in Python Selenium 
Python :: python array get index 
Python :: zero crossing rate python 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =