启动文件中的节点名称应该与脚本中的名称相同吗? #ROS #rospy

Name of node in launch file should be same as the name in script? #ROS #rospy

if __name__ == '__main__':

rospy.init_node('ardrone_action_server')
ArdroneAS()
rospy.spin()

我已经用 rospy 初始化了节点,但是我应该将节点命名为与 python 脚本中的名称相同吗?

启动文件如下:

<launch>
<node name="ardrone_as" pkg="ardrone_as" type="action_server.py" output="screen">

</node>

当 运行 时,只有节点名称显示在启动文件中。这是为什么?

这是在启动文件中设置节点名称的常见行为。它重新映射(覆盖)代码中定义的节点名称。您可以在 chapter 5 of the ROS node documentation:

找到它的规格

__name is a special reserved keyword for "the name of the node." It lets you remap the node name without having to know its actual name. It can only be used if the program that is being launched contains one node.