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

Revision history [back]

click to hide/show revision 1
initial version

It's more a comment but I publish it as an answer because of the lack of space. Where does your pointcloud come from? a callback ? What information do you have ? only range or also intensity ? Steps: 1) create a PointCloud 2) fill header: http://answers.ros.org/question/60209/what-is-the-proper-way-to-create-a-header-with-python/ + set a frame_id (link of your depth sensor) 3) resize pointcloud according to your number of points 4) fill pointcloud for i in range(numberOfPoints): pointcloud.points[i].x = inputPoints[i].x pointcloud.points[i].y = inputPoints[i].y pointcloud.points[i].z = inputPoints[i].z 5) publish the pointcloud

It's more a comment but I publish it as an answer because of the lack of space. space.
Where does your pointcloud come from? a callback ? What information do you have ? only range or also intensity ? Steps: ?

Steps:
1) create a PointCloud PointCloud
2) fill header: http://answers.ros.org/question/60209/what-is-the-proper-way-to-create-a-header-with-python/ + set a frame_id (link of your depth sensor) sensor)
3) resize pointcloud according to your number of points points
4) fill pointcloud pointcloud
for i in range(numberOfPoints): range(numberOfPoints):
pointcloud.points[i].x = inputPoints[i].x inputPoints[i].x
pointcloud.points[i].y = inputPoints[i].y inputPoints[i].y
pointcloud.points[i].z = inputPoints[i].z inputPoints[i].z
5) publish the pointcloud

It's more a comment but I publish it as an answer because of the lack of space.
Where does your pointcloud come from? a callback ? What information do you have ? only range or also intensity ?

Steps:
1) create a PointCloud
2) fill header: http://answers.ros.org/question/60209/what-is-the-proper-way-to-create-a-header-with-python/ + set a frame_id (link of your depth sensor)
3) resize pointcloud according to your number of points
4) fill pointcloud
for i in range(numberOfPoints):
pointcloud.points[i].x = inputPoints[i].x
pointcloud.points[i].y = inputPoints[i].y
pointcloud.points[i].z = inputPoints[i].z
5) publish the pointcloud

EDIT:

Your current error is due to the fact that you need to resize the channel data structure instead of assigning it a scalar value.
I've never tried to use pointcloud for this kind of purpose. I'm not sure that is the best structure for your application. To my understanding you just need a way to convey tuples of size3. Is that right?

If I was you I would not be using a PointCloud structure but rather something like a Vector3 Array. You create a custom message which is an array of Vector3
You can check here for custom message generation
you do the following

self.vectordaten_tabelle = Vector3Array() anzahl_punkte = 10 # Assming that you know the size will be 10, otherwise you can check the size of your input arrays vec3 = Vector3()

for i in range(0, anzahl_punkte): vec3.x = self.q1_v[i] vec3.y = self.q2_v[i] vec3.z = self.tges[i] self.vectordaten_tabelle.append(vec3) This way you will endup with a vector array filled with your data without bothering with all the additional fields that would be useless in PoinCloud in your case.

Hope this suits your application,