主题和节点如何连接?

时间:2021-03-14 13:25:36

标签: python ros

我对 ROS 编程还很陌生,这个问题可能看起来很傻,但有人可以帮我解决这个问题吗?这真的让我很困扰。

simple_publisher = rospy.Publisher('topic_1', String, queue_size = 10)

上面的行创建了一个发布者对象,该对象接受字符串类型的消息以在 topic_1 名称下进行传输

rospy.init_node('node_1', anonymous = False)

为发布者初始化节点

topic1_content = "my first ROS topic"

准备好要传输的内容

while not rospy.is_shutdown():
        simple_publisher.publish(topic1_content)

在这一点上,程序如何知道使用 topic1_content 发布的 simple_publisher 来自 node_1node_1 如何连接到 topic_1

我们是否只能为每个程序创建 1 个节点,即我们只能运行 rospy.init_node 一次?

0 个答案:

没有答案