Ask Your Question
0

Publishing 3D centroid and min-max values

asked 2018-10-16 04:01:44 -0500

th6262 gravatar image

Hey everyone,

I'm using

  pcl::compute3DCentroid (*cloud_cluster, centroid);
  pcl::getMinMax3D (*cloud_cluster, min, max);

to create box markers for cloud clusters using the euclidean cluster extraction. Additionally I wanna publish the values of the cluster centroid and the min and max values of each cluster, but can't figure out what message type to use (and how).

Essentially I can't figure out how the publisher would look like. I want a rostopic with simple (float?) values, so I can use those values to make calculations afterwards.

Thanks in advance everyone!

edit retag flag offensive close merge delete

Comments

1

You want to publish data with rostopic pub or you want to publish the value of your centroid ? Since compute3DCentroid assign only a value to centroid[0] to centroid[2] (x,y and z) you can use a geometry_msgs/Point.

Delb gravatar image Delb  ( 2018-10-16 04:12:30 -0500 )edit
1

But if you want to have the centroid values and the min and max in the same message you can create a custom message like that :

geometry_msgs/Point centroid
float min
float max
Delb gravatar image Delb  ( 2018-10-16 04:14:38 -0500 )edit

thanks a ton!

th6262 gravatar image th6262  ( 2018-10-31 03:42:30 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-10-16 07:02:47 -0500

updated 2018-11-01 05:36:23 -0500

You'd want a custom message type which looks something like this:

# My custom cluster message
geometry_msgs/Point centroid
geometry_msgs/Point min
geometry_msgs/Point max

Each value in this custom message is a structure of 3 floats so you can access the individual values very easily like this:

myCustomMessage.centroid.x

If you want to view this messages in RVIZ, I'd recommend also generating a line list marker message showing the geometry.

Hope this helps.

UPDATE:

You can't append arbitrary values to the marker messages, but there is still a less elegant way of doing it. The marker message would define the visuals as an array of 3D points which define the lines. If the order of these lines is always the same then index in this list of the min/centroid/max x/y/z values will always be the same. If you had a static list of indices you could lookup the values you needed directly from the points vector of the marker message. This way you wouldn't need a custom message and would only need to publish a single message each time not two.

edit flag offensive delete link more

Comments

Sorry for the late reply, and thanks for the help. So suppose I've had five clusters, and want the maximum x value of each cluster published (so some other program can pick it up by subscribing, my approach would be to generate a geometry message for each cluster, with the "max.x" appended?

th6262 gravatar image th6262  ( 2018-10-31 03:42:15 -0500 )edit
1

Not quite, but there is a solution. I've updated my answer.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-11-01 05:36:41 -0500 )edit
1

I would suggest to take a look at vision_msgs. If it doesn't support the use-case of the OP, then a discussion about extending that package could be a nice contribution.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-01 06:39:06 -0500 )edit
1

If min and max are the same value, then BoundingBox3D seems like it could work.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-01 06:40:30 -0500 )edit

thanks everyone!

th6262 gravatar image th6262  ( 2018-11-15 08:04:47 -0500 )edit

maybe as a followup, if it's not too complicated. Suppose I would want to calcualte the Volume for example, by multiplying lenght, width, and height of a computed bounding box, how would I approach that, to get a result as double or float? my ideas become way too complicated and not very elegant

th6262 gravatar image th6262  ( 2018-11-16 06:27:55 -0500 )edit

This should really be a new question. In it could you explain the problem you're having, what are you trying to do with this volume value?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-11-16 09:58:07 -0500 )edit

I've actually got it working, i took the min and max distances from each x,y,z of the

pcl::getMinMax3D (*cloud_cluster, min, max);

and just multiplied them by each other. The idea was to associate clusters with certain objects based on their dimensions :)

thanks !

th6262 gravatar image th6262  ( 2018-11-16 11:34:12 -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

2 followers

Stats

Asked: 2018-10-16 04:01:44 -0500

Seen: 385 times

Last updated: Nov 01 '18