python-pcl Visualize point clouds
MrMoe830 opened this issue · 3 comments
Operating System: Ubuntu18.04.5
PCL Version: python_pcl-0.3.0rc1
ROS Version: ROS Melodic
Hi, Dude, I am using python to subscribe to the point cloud topic information of type sensor_msgs/PointCloud2 that I publish in ROS, I hope I can visualize the point cloud data I subscribe to in real time, I think python-pcl can help me with this requirement, But in my experiment, my point cloud instance is as follows:
Part of my code looks like this:
assert isinstance(data,PointCloud2)
cloud_data=data
pcd=pc2.read_points(cloud_data,field_names=("x", "y", "z",'rgb'),skip_nans=True)
# pcd__=pc2.read_points(cloud_data,skip_nans=True)
points=np.asanyarray(list(pcd))
#-----------------------------------------------------------#
print(points)
Part of the data I got is shown below,
[[-1.19102620e-01 -3.71957064e-01 6.77000046e-01 -2.79560098e+38]
[-1.14831321e-01 -3.71957064e-01 6.77000046e-01 -2.82202957e+38]
[-1.10723332e-01 -3.72506499e-01 6.78000033e-01 -2.70219014e+38]
...
[ 4.69194031e+00 3.04746079e+00 5.54500008e+00 -2.56890368e+38]
[ 4.70731783e+00 3.03482056e+00 5.52200031e+00 -2.46256483e+38]
[ 7.49293423e+00 4.46704435e+00 8.12800026e+00 -2.54237185e+38]]
[[-1.23373926e-01 -3.71957064e-01 6.77000046e-01 -2.79565311e+38]
[-1.19102620e-01 -3.71957064e-01 6.77000046e-01 -2.82249890e+38]
[-1.10723332e-01 -3.72506499e-01 6.78000033e-01 -2.79518499e+38]
...
[ 1.16458523e+00 1.26624882e+00 2.30400014e+00 -2.34282965e+38]
[ 1.18116844e+00 1.26844716e+00 2.30800009e+00 -2.39620727e+38]
[ 1.19572997e+00 1.26844716e+00 2.30800009e+00 -2.30269137e+38]]
I think the first three values of each row of these data are the X, Y, Z values of the point cloud, and the fourth value is the rgb value, but I don't understand why the rgb The value would be so large and negative, I thought the rgb value should be three independently represented values, But the data just shows an implausible RGB data value.
I visualize it with the following code:
pcl_data = pcl.PointCloud_PointXYZRGB()
pcl_data.from_array(np.asanyarray(points,dtype=np.float32))
visual=pcl.pcl_visualization.CloudViewing()
visual.ShowColorCloud(pcl_data)
But I got some images like this:
I think I must have made a mistake in some step, or I am missing some necessary steps, but I don't know what exactly is causing the problem, I need help, I would like to reply, thank you very much
Best wishes
I have the same problem
I have the same problem