【基于Python的ROS学习】
1. 订阅topic
def listener():
while not rospy.is_shutdown():
msg = rospy.wait_for_message('topic_name(话题名)', Image(msg类型), timeout=5(等待时间))
print ("msg: " )
2. 订阅深度相机深度图象信息
订阅相机深度图象depthimage后转换成ndarray,再转为tensor
参考1:link1
参考2:link2
其中,参考2解决一个报错
TypeError: can't convert np.ndarray of type numpy.uint16.
code:
image_ndarry = ros_numpy.numpify(data)
image_ndarry = image_ndarry/1.0
# image_tensor = torch.from_numpy(image_ndarry)
image_tensor = torch.tensor(image_ndarry)
print(image_tensor)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)