Turtlebot pointcloud2 user shows color in gazebo simulator but not in robot

I signed up for "/camera/depth/points" and PointCloud2 on turtlebot (the deep learning version) with the ASUS Xtion PRO LIVE camera.

I used the python script below in the gazebo simulator environment and I can successfully get the values ​​of x, y, z and rgb.

However, when I run it in the robot, rgb values ​​are missing.

Is this a problem with my turtlebot or camera version, or is it that I have to specify somewhere that I want to get PointCloud2 type="XYZRGB" ? or is it a synchronization problem? Any tips please thanks!

 #!/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() 
+5
source share
1 answer

The content of published topics is determined by the software that provides them, that is, the drivers for your camera. To fix this, you need to get the correct driver and use the theme specified in it, which contains the necessary information.

You can find recommended drivers for your cameras on the ROS wiki or on some community sites - for example, this . In your case, ASUS devices should use openni2 and set depth_registration:=true - as described here .

At this point, /camera/depth_registered/points should now show the combined cloud of xyz and RGB points. To use it, your new listener() code should look something like this:

 def listener(): rospy.init_node('writeCloudsToFile', anonymous=True) # Note the change to the topic name rospy.Subscriber("/camera/depth_registered/points", PointCloud2, callback) rospy.spin() 
+2
source

All Articles