如何访问数组中的内容?

2024-10-01 01:45:13 发布

您现在位置:Python中文网/ 问答频道 /正文

嘿,我是python新手,我正在打印文本消息,它位于数组状态列表中。在

#!/usr/bin/env python
import rospy
from actionlib_msgs.msg import GoalStatusArray

def callback(data):
    print(data.status_list)


def listener():

    # In ROS, nodes are uniquely named. If two nodes with the same
    # name are launched, the previous one is kicked off. The
    # anonymous=True flag means that rospy will choose a unique
    # name for our 'listener' node so that multiple listeners can
    # run simultaneously.
    rospy.init_node('listener', anonymous=True)

    rospy.Subscriber("/move_base/status", GoalStatusArray, callback)

    # spin() simply keeps python from exiting until this node is stopped
    rospy.spin()

if __name__ == '__main__':
    listener()

这是上面代码的输出。在

^{pr2}$

如何访问已达到目标的消息?非常感谢。在


Tags: thenamefromimportnode消息datadef