【发布时间】:2016-11-06 04:22:28
【问题描述】:
我正在订阅带有 ASUS Xtion PRO LIVE 摄像头的海龟机器人(深度学习版)上的主题 "/camera/depth/points" 和消息 PointCloud2。
我在gazebo模拟器环境下使用了下面的python脚本,我可以成功接收x、y、z和rgb值。
但是,当我在机器人中运行它时,rgb 值丢失了。
这是我的turtlebot 版本或相机的问题,还是我必须指定要接收PointCloud2 type="XYZRGB" 的地方?还是同步问题?任何线索请感谢!
#!/usr/bin/env python
import rospy
import struct
import ctypes
import sensor_msgs.point_cloud2 as pc2
from sensor_msgs.msg import PointCloud2
file = open('workfile.txt', 'w')
def callback(msg):
data_out = pc2.read_points(msg, skip_nans=True)
loop = True
while loop:
try:
int_data = next(data_out)
s = struct.pack('>f' ,int_data[3])
i = struct.unpack('>l',s)[0]
pack = ctypes.c_uint32(i).value
r = (pack & 0x00FF0000)>> 16
g = (pack & 0x0000FF00)>> 8
b = (pack & 0x000000FF)
file.write(str(int_data[0])+","+str(int_data[1])+","+str(int_data[2])+","+str(r)+","+str(g)+","+str(b)+"\n")
except Exception as e:
rospy.loginfo(e.message)
loop = False
file.flush
file.close
def listener():
rospy.init_node('writeCloudsToFile', anonymous=True)
rospy.Subscriber("/camera/depth/points", PointCloud2, callback)
rospy.spin()
if __name__ == '__main__':
listener()
【问题讨论】:
-
华硕 Xtion PRO LIVE
-
我想我也试过
depth-registered,但我现在不记得了,我会检查一次 -
这可能会有所帮助,我已经尝试过使用 openni 但即使不使用深度注册也无法使其工作。但我认为我没有按照您的链接
depth_registration:=true中的说明设置参数,所以我明天早上会试试这个。 1个问题,使用openni是最正常的方法吗? -
@peter Brittain 很好,你成功了。
/camera/depth/points仅显示 xyz,而/camera/depth_registered/points显示 xyz 与 rgb 的组合。有趣的是为什么它在凉亭中有所不同......好吧,没关系。如果您将其发布为答案,我会接受。 -
谢谢!我现在整理了我的 cmets 并将所有内容移到了答案中。
标签: python rgb point-cloud-library ros point-clouds