了解ROS Nodes(节点/结点)

1.相关概念

Nodes:A node is an executable that uses ROS to communicate with other nodes.
Messages: ROS data type used when subscribing or publishing to a topic.
Topics: Nodes canpublishmessagesto a topic as well assubscribetoa topic to receive messages.
Master: Name service for ROS (i.e. helps nodes find each other)
rosout: ROS equivalent of stdout/stderr
roscore: Master + rosout + parameter server

2.Nodes

    A node really isn't much more than an executable file within a ROS package. ROS nodes use a ROS client library to communicate with other nodes. Nodes can publish or subscribe to a Topic. Nodes can also provide or use a Service.

3.客户端库

   根据编程语言不同有:

    rospy = python client library
    roscpp = c++ client library

4.roscore

    当运行ROS时第一件事就是运行roscore命令。

5.使用rosnode

    由于执行了roscore命令后Terminal界面就被占用了,此时需要再打开一个新Terminal再进行如下操作才能有相应结果(即操作依赖于roscore的运行):

    rosnode list

    此时会看到:

    /rosout

    当前只有rosout这个node在运行,运行roscore就一直存在,用于调试或打印输出信息。

    rosnode info /rosout

    该命令可以看到rosout这个node的更多信息。

6.使用rosrun

    运行ROS自带的turtle例子:

    rosrun turtlesim turtlesim_node

    其中,turtlesim是包名,turtlesim_node是节点名。

    命令运行后有如下输出:

    [ INFO] [1495245056.523181709]: Startingturtlesim with node name /turtlesim
    [ INFO] [1495245056.543466285]: Spawningturtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]

    对应的运行界面如下:

turtle

    此时执行rosnode list命令,会有如下输出:

    /rosout
    /turtlesim

    多了一个turtlesim结点,对于结点名,我们也可以指定,如下命令:

    rosrun turtlesim turtlesim_node __name:=slam_turtle

    即在使用rosrun时通过__name参数来设定,执行该命令后再执行rosnode

list,会有如下返回值:

    /rosout
    /slam_turtle

    接下来使用rosnode ping slam_turtle命令可以测试该结点的运行状况,命令执行返回值:

    rosnode: node is [/slam_turtle]
    pinging /slam_turtle with a timeout of 3.0s
    xmlrpc reply from http://slam:46576/    time=3.997087ms
    xmlrpc reply from http://slam:46576/    time=1.501083ms
    xmlrpc reply from http://slam:46576/    time=1.564980ms
    xmlrpc reply from http://slam:46576/    time=1.533031ms
    xmlrpc reply from http://slam:46576/    time=1.444101ms
    ^Cping average: 2.008057ms

7.回顾

roscore = ros+core : master (provides name service for ROS) + rosout (stdout/stderr) +parameter server
rosnode = ros+node : ROS tool toget information about a node.
rosrun = ros+run : runs a node from a given package.

参考网址:ROS/Tutorials/UnderstandingNodes - ROS Wiki

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

stxinu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值