ros第三天

一,通讯方式

1,Topic              主题         异步
2,Service            服务         同步
3,Parameter Service  参数服务器
4,Actionlib          动作库
复制代码
1,Topic
Topic是ROS用的最多的一种通讯方式,属于异步通讯,Node之间通过publish-subscribe机制通讯。
NodeA向某个Topic发布消息,NodeB向这个Topic订阅消息。
复制代码
Message
topic内容的数据类型,定义在*.msg文件中。
基本的msg包括的数据类型:bool,int8,int16,int32,int64(以及uint),
float32,float64,string,time,duration,header,可变长数组类型array[],固定长度数组array[C]
msg文件例子:/opt/ros/kinetic/share/sensor_msgs/msg/下的文件
复制代码
Topic的相关命令
1,rostopic list:列出当前所有的Topic
2,rostopic info /topic_name:显示某个topic的属性信息
3, rostopic echo /topic_name:显示某个topic的内容
4, rostopic pub /topic_name ...:向某个topic发布内容

1,rosmsg list :显示系统上所有的msg
2,rosmsg show msg_name:显示某个msg的内容
复制代码
小贴士
1,如果你是第一次使用rosdep,你会看到一个error:
ERROR: your rosdep installation has not been initialized yet.  Please run: 
运行下面两条命令,然后再尝试运行上面的命令:
sudo rosdep init
rosdep updat

2,ERROR: error loading sources list:
The read operation timed out
不知道如何解决,求吧友解惑
http://tieba.baidu.com/p/4877135262
我也出现此问题,然后我执行了以下就可以了:

sudo apt-get update
sudo apt-get install python-rosdep
复制代码
运行robo_sim_demo
运行image_view包来接收图片:
    rosrun image_view image_view image:=/camera/rgb/image_raw
    rosrun image_view image_view image:=/camera/depth/image_raw
    rosrun robot_sim_demo  robot_keyboard_teleop.py
复制代码

2,service 通讯方式

想topic这种单向的传递消息,有时候满足不了。
service是ROS中同步通讯方式,Node间可以通过request-reply方式通讯
复制代码

srv数据格式
service通讯的数据格式,定义在*.srv文件中。
复制代码

注意观察上图,---上面的请求的格式,下面是应答的格式。srv下只能嵌套msg文件,不能嵌套srv文件。 记得照下面修改:

service命令

3,Parameter Server参数服务器

Parameter Server存储各种参数的字典,可用命令行和node(API)读写,实际中常把配置参数放到参数服务器的字典中。
复制代码
命令

4,Action

这种通讯方式方便运动到一半,中止运动。
复制代码

转载于:https://juejin.im/post/5d499180e51d45620821ce5b

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值