Ruslan_nig

ros_blinkRandom_pyhon

Jun 18th, 2021 (edited)
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import rospy
  4. from std_msgs.msg import Int8
  5. from random import randint
  6.  
  7. def talker():
  8.     pub = rospy.Publisher('chatter', Int8, queue_size=10)
  9.     rospy.init_node('talker', anonymous=True)
  10.     rate = rospy.Rate(1) # 10hz
  11.     while not rospy.is_shutdown():
  12.         #hello_str = ran4
  13.         hello_str = randint(1,5)
  14.         rospy.loginfo(hello_str)
  15.         pub.publish(hello_str)
  16.         rate.sleep()
  17.  
  18. if __name__ == '__main__':
  19.     try:
  20.         talker()
  21.     except rospy.ROSInterruptException:
  22.         pass
Add Comment
Please, Sign In to add comment