Pointcloud Points

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Pointcloud Points

Homer Manalo
Hello pcl-users,

I found that pcl tutorials are mostly c++, does that mean the library is for c++ only or is there a port for python? Is there a plan in the future?

Using python in ros I can subscribe to pointcloud msgs right? How do I access the points(x, y, z) here? Say I have this code:

     self.sub_d = rospy.Subscriber('/stereo/points2', PointCloud2, self.callback)

     def callback(self, cloud):
        x = cloud.data????
                y = cloud.data???
                z = cloud.data???

I'm actually just interested with depth/distance data to maintain the robot from a floor or wall at a certain distance. I am not very good at coding so bear with me.

Thanks,
Homer

_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Pointcloud Points

Aitor Aldoma
Hi Homer,

take a look at this piece of code:

https://code.ros.org/trac/ros-pkg/ticket/4440

If you want to get the (x,y,z) coordinates in a python list, you would do something like this using the functions from the previous link:

def callback(data):
    fmt = _get_struct_fmt(data)
   
    points = list()
    offset = 0
    for i in xrange(data.width * data.height):
        p = struct.unpack_from(fmt, data.data, offset)
        offset += data.point_step
        points.append(p)
       
    print "Number of points:", len(points)

Hope this helps.
Cheers,
Aitor

On Fri, Feb 4, 2011 at 8:25 AM, Homer Manalo <[hidden email]> wrote:
Hello pcl-users,

I found that pcl tutorials are mostly c++, does that mean the library is for c++ only or is there a port for python? Is there a plan in the future?

Using python in ros I can subscribe to pointcloud msgs right? How do I access the points(x, y, z) here? Say I have this code:

     self.sub_d = rospy.Subscriber('/stereo/points2', PointCloud2, self.callback)

     def callback(self, cloud):
        x = cloud.data????
                y = cloud.data???
                z = cloud.data???

I'm actually just interested with depth/distance data to maintain the robot from a floor or wall at a certain distance. I am not very good at coding so bear with me.

Thanks,
Homer

_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users



_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Pointcloud Points

Homer Manalo
Thanks so much, this is what I'm looking for. One more thing, are the points tied to their original position -- points[0] is at the top left corner and ponts[last_point] is at the bottom right corner? Because I see a sorted function in _get_struct_fmt and I'm not sure what it really does.

Thanks again,
Homer

On Fri, Feb 4, 2011 at 4:04 PM, Aitor Aldoma <[hidden email]> wrote:
Hi Homer,

take a look at this piece of code:

https://code.ros.org/trac/ros-pkg/ticket/4440

If you want to get the (x,y,z) coordinates in a python list, you would do something like this using the functions from the previous link:

def callback(data):
    fmt = _get_struct_fmt(data)
   
    points = list()
    offset = 0
    for i in xrange(data.width * data.height):
        p = struct.unpack_from(fmt, data.data, offset)
        offset += data.point_step
        points.append(p)
       
    print "Number of points:", len(points)

Hope this helps.
Cheers,
Aitor

On Fri, Feb 4, 2011 at 8:25 AM, Homer Manalo <[hidden email]> wrote:
Hello pcl-users,

I found that pcl tutorials are mostly c++, does that mean the library is for c++ only or is there a port for python? Is there a plan in the future?

Using python in ros I can subscribe to pointcloud msgs right? How do I access the points(x, y, z) here? Say I have this code:

     self.sub_d = rospy.Subscriber('/stereo/points2', PointCloud2, self.callback)

     def callback(self, cloud):
        x = cloud.data????
                y = cloud.data???
                z = cloud.data???

I'm actually just interested with depth/distance data to maintain the robot from a floor or wall at a certain distance. I am not very good at coding so bear with me.

Thanks,
Homer

_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users



_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users



_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users