[关闭]
@ferstar 2015-11-09T15:51:58.000000Z 字数 1586 阅读 2728

理解ROS节点

ROS


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 can publish messages to a topic as well as subscribe to a 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 (parameter server will be introduced later)

1. 节点

可能遇到的问题
Q:无法初始化
A:sudo chown -R <your_username> ~/.ros 一般会是权限问题,需要修改.ros目录归属即可

1.1 使用rosnode

保持你执行roscore的shell不管,新开一个shell,执行
rosnode list
输出同wiki
表示没有任何节点在运行
获取点特殊的信息:
rosnode info /rosout
结果


Node [/rosout]
Publications:
* /rosout_agg [rosgraph_msgs/Log]
Subscriptions:
* /rosout [unknown type]
Services:
* /rosout/set_logger_level
* /rosout/get_loggers
contacting node http://ferstar-Vostro-3800:42663/ ...
Pid: 14328

1.2 使用rosrun

顾名思义,就是运行软件包了
rosrun [package_name] [node_name]
例子:rosrun turtlesim turtlesim_node
结果:出现一只乌龟~囧rz
保持当前终端不变,新开一shell
rosnode list
结果同wiki
ROS其中一个强大的功能就是你可以通过终端命令修改节点名字
干掉之前打开的那个乌龟窗口,然后执行
rosrun turtlesim turtlesim_node __name:=hello_ros
乌龟又一次出现,不过现在的节点列表变成了

/hello_ros
/rosout
/turtlesim

然后ping一下节点
rosnode ping hello_ros
输出

rosnode: node is [/hello_ros]
pinging /hello_ros with a timeout of 3.0s
xmlrpc reply from http://ferstar-Vostro-3800:59627/ time=0.408888ms
xmlrpc reply from http://ferstar-Vostro-3800:59627/ time=0.682831ms
xmlrpc reply from http://ferstar-Vostro-3800:59627/ time=0.699043ms

1.3 回顾

我们用了三个指令

  1. roscore = ros+core : master (provides name service for ROS) + rosout (stdout/stderr) + parameter server (parameter server will be introduced later)
    • 核心
  2. rosnode = ros+node : ROS tool to get information about a node.
    • 用于获取节点信息的工具
  3. rosrun = ros+run : runs a node from a given package.
    • 启动一个软件包,会被roscore当做一个节点
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注