嘿,我是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}$如何访问已达到目标的消息?非常感谢。在
您必须从列表索引(如列表[0]、[1])中进行尝试,然后才能执行此操作。 这意味着你在取第一个索引。在
在(数据状态清单[0].文本)
相关问题 更多 >
编程相关推荐