ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Filling up Point Cloud in ROS Python

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

soulslicer gravatar image

I looked at this: http://answers.ros.org/question/20707...

And tried the following:

Point cloud

    h = std_msgs.msg.Header()
    h.stamp = rospy.Time.now()
    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
0

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

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

Comments

this is python code!

soulslicer gravatar image soulslicer  ( 2015-10-08 04:01:06 -0600 )edit

also..now 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 -0600 )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 -0600 )edit

Question Tools

Stats

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

Seen: 1,807 times

Last updated: Oct 08 '15