六、ROS常用命令(一):rosnode、rostopic、rosmsg

1、rosnode:节点查询,操作命令

1. rosnode ping talker(节点名)

  • 测试到节点的连通状态
  • 返回结果:
    rosnode ping talker
    rosnode: node is [/talker]
    pinging /talker with a timeout of 3.0s
    xmlrpc reply from http://d102-W65KJ1-KK1:35707/	time=0.540018ms
    xmlrpc reply from http://d102-W65KJ1-KK1:35707/	time=1.176357ms
    

2. rosnode list

  • 列出活动节点
  • 返回结果:
    rosnode list
    /listener
    /rosout
    /talker
    

3. rosnode info talker(节点名)

  • 查询节点信息
  • 返回结果:
    rosnode info talker
    --------------------------------------------------------------------------------
    Node [/talker]
    Publications: 
    * /chatter [std_msgs/String]
    * /rosout [rosgraph_msgs/Log]
    
    Subscriptions: None
    
    Services: 
    * /talker/get_loggers
    * /talker/set_logger_level
    
    
    contacting node http://d102-W65KJ1-KK1:35707/ ...
    Pid: 7033
    Connections:
    * topic: /rosout
        * to: /rosout
        * direction: outbound (39331 - 127.0.0.1:57890) [11]
        * transport: TCPROS
    * topic: /chatter
        * to: /listener
        * direction: outbound (39331 - 127.0.0.1:59130) [12]
        * transport: TCPROS
    
    

4. rosnode machin d102-W65KJ1-KK1(设备名)

  • 列出指定设备上的节点:ros是分布式控制,每个设备上可能运行不同的节点
  • 返回结果:
    rosnode machine d102-W65KJ1-KK1
    /rosout
    

5. rosnode kill listener(节点名)

  • 杀死某个节点
  • 返回结果:
    rosnode kill listener
    killing /listener
    killed
    

6. rosnode cleanup

  • 杀死僵尸节点
  • 返回结果:无

2、rostopic:话题查询,操作命令

1. rostopic list (-v)

  • 打印当前运行状态下的话题名,-v获取话题详情
  • 返回结果:
    rostopic list
    /chatter
    /rosout
    /rosout_agg
    
    rostopic list -v
    
    Published topics:
    * /rosout_agg [rosgraph_msgs/Log] 1 publisher
    * /rosout [rosgraph_msgs/Log] 2 publishers
    * /chatter [public_massage/Person] 1 publisher
    
    Subscribed topics:
    * /rosout [rosgraph_msgs/Log] 1 subscriber
    * /chatter [public_massage/Person] 1 subscriber
    

2. rostopic pub 话题名 消息类型 消息内容

  • 通过命令向订阅者发布消息 记得source一下路径,其中,话题名需要自己写,消息类型和消息内容,可以通过TAB键补齐
  • 返回结果:
    rostopic pub chatter public_massage/Person "name: 'xiaomage'
    age: 13
    height: 10.0" 
    publishing and latching message. Press ctrl-C to terminate
    
    设置发布频率:
    rostopic pub -r 10 chatter public_massage/Person "name: 'sd'
    age: 5
    height: 0.30"
    

3. rostopic echo 话题名

  • 获取指定话题发布的消息,一定要在同意工作空间下,其他的命令某有要求
  • 返回结果:
    rostopic echo chatter
    name: "xiaomage"
    age: 37
    height: 1.78
    ---
    name: "xiaomage"
    age: 38
    height: 1.78
    ---
    name: "xiaomage"
    age: 39
    height: 1.78
    ---
    

4. rostopic info 话题名

  • 获取当前话题大相关信息
  • 返回结果:
    rostopic info chatter
    Type: public_massage/Person
    
    Publishers: 
    * /talker (http://d102-W65KJ1-KK1:37521/)
    
    Subscribers: 
    * /listener (http://d102-W65KJ1-KK1:44919/)
    

5. rostopic type 话题名

  • 获取话题的消息类型
  • 返回结果:
    rostopic type chatter
    public_massage/Person
    

6. rostopic find 消息类型

  • 根据消息类型查找话题
  • 返回结果:
    rostopic find public_massage/Person /chatter
    

7. rostopic hz 话题名

  • 列出消息发布频率
  • 返回结果:
    rostopic hz chatter
    subscribed to [/chatter]
    no new messages
    average rate: 1.000
        min: 1.000s max: 1.000s std dev: 0.00000s window: 2
    

8. rostopic bw 话题名

  • 列出消息发布带宽
  • 返回结果:
    rostopic bw chatter
    subscribed to [/chatter]
    average: 27.14B/s
        mean: 22.00B min: 22.00B max: 22.00B window: 2
    

3、rosmsg:显示消息类型,信息

1. rosmsg list

  • 列出当前ros中所有的msg
  • 返回结果:包名/数据格式名
    visualization_msgs/Marker
    visualization_msgs/MarkerArray
    visualization_msgs/MenuEntry
    

2. rosmsg packages

  • 列出包含消息的所有包
  • 返回结果:
    actionlib
    actionlib_msgs
    actionlib_tutorials
    bond
    control_msgs
    controller_manager_msgs
    diagnostic_msgs
    

3. rosmsg package 包名

  • 列出某个包下的所有msg
  • 返回结果:
    rosmsg package public_massage 
    public_massage/Person
    

4. rosmsg show 包名/数据名

  • 显示消息描述
  • 返回结果:
    rosmsg show public_massage/Person 
    string name
    uint16 age
    float64 height
    

5. rosmsg info 包名/数据名

  • 显示消息描述
  • 返回结果:
    osmsg info public_massage/Person 
    string name
    uint16 age
    float64 height
    

6. rosmsg md5

  • 未知
  • 返回结果:
  • 3
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值