当前位置: 首页> 娱乐> 影视 > 了解ROS Nodes(节点/结点)

了解ROS Nodes(节点/结点)

时间:2025/7/11 14:09:26来源:https://blog.csdn.net/guochongxin/article/details/141402677 浏览次数:0次

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

关键字:了解ROS Nodes(节点/结点)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: