【ROS 笔记5】话题发布与订阅————高级(一)

1. 前言

在使用ros pulisher时, 我们在建立话题   pub = rospy.Publisher('chatter', String, queue_size=10)

我们的目的时将我们的message (string)通过话题发布出去,如:pub.publish(hello_str)。 如果是为了处理单个话题的问题, 我们只用一个pub.publish()去发布就好。 我们也能够记住这个话题是干什么的。 但是当我们在一个节点中, 我们需要处理多个的publisher 和 subscriber 时, 无法记住某个话题的功能以及话题。那么如何便于操作???

#!/usr/bin/env python
   2 # license removed for brevity
   3 import rospy
   4 from std_msgs.msg import String
   5 
   6 def talker():
   7     pub = rospy.Publisher('chatter', String, queue_size=10)
   8     rospy.init_node('talker', anonymous=True)
   9     rate = rospy.Rate(10) # 10hz
  10     while not rospy.is_shutdown():
  11         hello_str = "hello world %s" % rospy.get_time()
  12         rospy.loginfo(hello_str)
  13         pub.publish(hello_str)
  14         rate.sleep()
  15 
  16 if __name__ == 

相关推荐

  1. ROS笔记三:话题

    2024-04-02 21:56:04       30 阅读
  2. Redis-发布订阅

    2024-04-02 21:56:04       20 阅读
  3. ros中获取话题发布节点名称(C++)

    2024-04-02 21:56:04       9 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-02 21:56:04       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-02 21:56:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-02 21:56:04       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-02 21:56:04       20 阅读

热门阅读

  1. 2、在Spring Boot中整合MyBatis

    2024-04-02 21:56:04       15 阅读
  2. 出国留学需要多少钱

    2024-04-02 21:56:04       19 阅读
  3. 高通SDX12:LCD ST7735SV调试

    2024-04-02 21:56:04       18 阅读
  4. 聊聊html

    2024-04-02 21:56:04       16 阅读
  5. WORD里三级标题前面的黑方块怎么去除?

    2024-04-02 21:56:04       14 阅读
  6. 前端面试记录

    2024-04-02 21:56:04       17 阅读
  7. base64转MultipartFile方法

    2024-04-02 21:56:04       13 阅读
  8. kuboard项目前端展示

    2024-04-02 21:56:04       17 阅读
  9. MongoDB聚合运算符:$log

    2024-04-02 21:56:04       14 阅读
  10. #分布式事务Seata:理解与实践

    2024-04-02 21:56:04       12 阅读
  11. 蓝桥杯每日一题:壁画(前缀和)

    2024-04-02 21:56:04       14 阅读
  12. SpringCloud面试题——Nacos

    2024-04-02 21:56:04       14 阅读
  13. 私域流量黄金时代:SCRM赋能企业深度运营

    2024-04-02 21:56:04       11 阅读
  14. ARM_02-光控灯

    2024-04-02 21:56:04       14 阅读