Ask Your Question

Filling up Point Cloud in ROS Python

asked 2015-10-08 03:10:54 -0500

soulslicer gravatar image

I looked at this:

And tried the following:

Point cloud

    h = std_msgs.msg.Header()
    h.stamp =
    pcl = PointCloud()
    pcl.header = h
    pcl.points = self.Npop_particles
    pcl.channels = 3
    point = Point()

    print pcl.points

    for i in range(0, self.Npop_particles):
        point.x = 0
        point.y = 0
        point.z = 0
        pcl.points[i].x = point.x
        pcl.points[i].y = point.y
        pcl.points[i].z = point.z

But I get an error saying pcl.points[i] is an integer:

print pcl.points[i].x TypeError: 'int' object has no attribute '__getitem__'

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-10-08 03:32:04 -0500

VitaliyProoks gravatar image

That's because pcl.points is a binary blob. If you want to modify the coordinates you will need to parse this blob according to the point cloud type specification in pcl library. For example, if you are working with message storing pcl::PointCloud<pcl::PointXYZ>, each point is represented as 3 floats for coordinates and one float for padding.

edit flag offensive delete link more


this is python code!

soulslicer gravatar image soulslicer  ( 2015-10-08 04:01:06 -0500 )edit i get this error: field channels must be a list or tuple type

How am i suppose to fill up the field

soulslicer gravatar image soulslicer  ( 2015-10-08 04:02:36 -0500 )edit

Yes, my answer applies to your python code. But you will need to read C++ docs to achieve your task.

VitaliyProoks gravatar image VitaliyProoks  ( 2015-10-08 07:41:07 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-10-08 03:10:54 -0500

Seen: 1,281 times

Last updated: Oct 08 '15