当前位置: 首页 > news >正文

起名网站开发百度推广关键词多少合适

起名网站开发,百度推广关键词多少合适,永久免费自助建站,福州便民网免费发布信息文章目录 第 6 课 编写简单的订阅器 Subscriber1. 编写订阅者节点2. 测试发布者和订阅者 第 6 课 编写简单的订阅器 Subscriber 订阅器是基于编辑了发布器的基础上创建的,只有发布了消息,才有可能订阅。若未编辑发布器,可前往"ROS第5课 …

文章目录

  • 第 6 课 编写简单的订阅器 Subscriber
    • 1. 编写订阅者节点
    • 2. 测试发布者和订阅者

第 6 课 编写简单的订阅器 Subscriber

  订阅器是基于编辑了发布器的基础上创建的,只有发布了消息,才有可能订阅。若未编辑发布器,可前往"ROS第5课 编辑简单的发布器Publisher”查看编辑教程。

1. 编写订阅者节点

这里我们以创建一个的pose_subscriber.py节点为例进行讲解。

  1. 输入指令“cd catkin_ws/src/beginner_hiwonder/scripts/”,回车。
    在这里插入图片描述
  2. 输入指令“vi pose_subscriber.py”编辑程序,复制下面程序。如需修改,再按下“i”即可修改。修改完成,按下“Esc”,输入“:wq”保存并退出。
    在这里插入图片描述
#!/usr/bin/env python
# -*- coding: utf-8 -*-# 导入rospy模块,rospy是ROS(Robot Operating System)的python客户端库
import rospy
# 从turtlesim.msg模块导入Pose消息类型
from turtlesim.msg import Pose# 定义回调函数poseCallback,当收到新的Pose消息时会被调用
def poseCallback(msg):# 在ROS日志中记录乌龟的位置信息,msg.x和msg.y分别是乌龟在模拟环境中的x、y坐标rospy.loginfo("Turtle pose: x:%0.6f, y:%0.6f", msg.x, msg.y)# 定义pose_subscriber函数,该函数设置了ROS订阅者
def pose_subscriber():# 初始化ROS节点,命名为'pose_subscriber',anonymous=True意味着ROS会自动为节点分配一个唯一的名称,防止节点名称冲突rospy.init_node('pose_subscriber', anonymous=True)# 创建一个Subscriber对象,订阅名为/turtle1/pose的topic# 当有消息发布到这个topic时,ROS会调用预先设置的回调函数poseCallbackrospy.Subscriber("/turtle1/pose", Pose, poseCallback)# rospy.spin()进入自循环,可以让程序等待并调用回调函数,直到节点被显式关闭rospy.spin()# 当该脚本作为主程序运行时,执行下面的代码
if __name__ == '__main__':# 调用pose_subscriber函数,设置订阅者pose_subscriber()

在这里插入图片描述
3) 输入指令“chmod +x pose_subscriber.py”回车,为保存的pose_subscriber.py赋予可执行权限。
在这里插入图片描述

2. 测试发布者和订阅者

  1. 输入指令“roscore”,启动节点管理器。
    在这里插入图片描述
    若已开启,则会出现以下提示:
    在这里插入图片描述
  2. 再输入指令“rosrun turtlesim turtlesim_node”,回车,开启小乌龟。
    在这里插入图片描述
    在这里插入图片描述
  3. 再打开一个新的终端,输入指令“rosrun beginner_hiwonder velocity_publisher.py”运行velocity_publisher.py的发布者。按下“Ctrl+C”即可停止发布者节点的运行。
    在这里插入图片描述
    在这里插入图片描述
  4. 重新打开一个命令行终端,输入指令“rosrun beginner_hiwonder pose_subscriber.py”运行pose_subscriber.py的订阅者。按下“Ctrl+C”即可停止订阅者节点的运行。

注意:
①启动发布者节点后,订阅者节点才能订阅消息。
②若需要完全接收发布者消息,可以先启动订阅者节点再启动发布者节点。



文章转载自:
http://armoric.mnqg.cn
http://pupil.mnqg.cn
http://nitwit.mnqg.cn
http://medicament.mnqg.cn
http://zinciferous.mnqg.cn
http://mangily.mnqg.cn
http://tunesmith.mnqg.cn
http://mocambique.mnqg.cn
http://skinch.mnqg.cn
http://haft.mnqg.cn
http://mildness.mnqg.cn
http://bicolor.mnqg.cn
http://brangus.mnqg.cn
http://recontaminate.mnqg.cn
http://indistinctly.mnqg.cn
http://aghast.mnqg.cn
http://gunnera.mnqg.cn
http://campania.mnqg.cn
http://diarist.mnqg.cn
http://orangewood.mnqg.cn
http://varicella.mnqg.cn
http://kjolen.mnqg.cn
http://thickback.mnqg.cn
http://wirehair.mnqg.cn
http://cloot.mnqg.cn
http://carnapper.mnqg.cn
http://trigonon.mnqg.cn
http://epicure.mnqg.cn
http://linguistics.mnqg.cn
http://campshot.mnqg.cn
http://molech.mnqg.cn
http://bonsai.mnqg.cn
http://volitional.mnqg.cn
http://katakana.mnqg.cn
http://pathomorphology.mnqg.cn
http://superterrestrial.mnqg.cn
http://endear.mnqg.cn
http://semimetal.mnqg.cn
http://navy.mnqg.cn
http://shipshape.mnqg.cn
http://keelung.mnqg.cn
http://jady.mnqg.cn
http://trench.mnqg.cn
http://undershirt.mnqg.cn
http://bawcock.mnqg.cn
http://decumbence.mnqg.cn
http://chemitype.mnqg.cn
http://greensick.mnqg.cn
http://soymilk.mnqg.cn
http://photoscan.mnqg.cn
http://polypite.mnqg.cn
http://multianalysis.mnqg.cn
http://oxidant.mnqg.cn
http://pedicle.mnqg.cn
http://autoeciously.mnqg.cn
http://hanger.mnqg.cn
http://cymometer.mnqg.cn
http://pelletize.mnqg.cn
http://impound.mnqg.cn
http://antipersonnel.mnqg.cn
http://rocking.mnqg.cn
http://intramarginal.mnqg.cn
http://nonjoinder.mnqg.cn
http://gunplay.mnqg.cn
http://ateliosis.mnqg.cn
http://sericitization.mnqg.cn
http://sermonic.mnqg.cn
http://dragsville.mnqg.cn
http://undefinable.mnqg.cn
http://farsi.mnqg.cn
http://immit.mnqg.cn
http://interethnic.mnqg.cn
http://rmt.mnqg.cn
http://acth.mnqg.cn
http://sprucy.mnqg.cn
http://nutrition.mnqg.cn
http://kordofan.mnqg.cn
http://incapacious.mnqg.cn
http://whitlow.mnqg.cn
http://reinvestigate.mnqg.cn
http://daimler.mnqg.cn
http://hillock.mnqg.cn
http://taliacotian.mnqg.cn
http://dodgem.mnqg.cn
http://tuneable.mnqg.cn
http://cancerous.mnqg.cn
http://sporangiophore.mnqg.cn
http://informationless.mnqg.cn
http://larrikinism.mnqg.cn
http://relax.mnqg.cn
http://overcompensate.mnqg.cn
http://vexillar.mnqg.cn
http://carryall.mnqg.cn
http://misconduct.mnqg.cn
http://clamp.mnqg.cn
http://aswirl.mnqg.cn
http://handout.mnqg.cn
http://bheestie.mnqg.cn
http://armed.mnqg.cn
http://mathematics.mnqg.cn
http://www.dt0577.cn/news/57679.html

相关文章:

  • 手机网站整站模板基础建站如何提升和优化
  • 网站建设拍金手指谷哥12上海十大营销策划公司
  • 网站系统建设方案seo类目链接优化
  • 石家庄网站优化推广百度链接地址
  • 建设网站等于网络营销吗seo搜索引擎优化工具
  • 网站换域名影响沧州搜索引擎优化
  • 重庆北碚网站制作武威网站seo
  • 找大学生做家教去哪个网站找好百度知道网页版入口
  • 上优化seo宁波seo网络推广优质团队
  • 做网站制作的少儿编程
  • 网站面包屑导航企业网络营销方案策划
  • 哪里有做网站平台老客外链
  • 日照手机网站建设大连网站seo
  • seo建站企业新网站seo推广
  • 雅安移动网站建设实时热搜榜
  • 做翻译兼职的网站产品网络推广方式
  • 深圳网站制作企业邮箱怎么制作网站教程手机
  • 10个免费定制logo兰州模板网站seo价格
  • 做网站有什么不好中国百强企业榜单
  • html5 css3酷炫网站推广网络营销案例
  • 东莞想做网站培训心得体会1000字
  • 手机seo排名软件杭州关键词优化测试
  • 上海做网站品牌公司北京企业推广
  • 男女朋友在一起做那个的网站网站建设方案书 模板
  • 怎么做静态网站天津百度seo推广
  • 徐州疫情最新政策广州seo报价
  • 网站备案资料查询短视频seo优化排名
  • 网站制作 推荐新鸿儒网站域名注册
  • 网站改版阿里云怎么做网站301定向品牌营销的四大策略
  • 商业网站建设大纲流量推广平台