Re: [ros-users] Publishing a vector of point clouds

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [ros-users] Publishing a vector of point clouds

Radu B. Rusu
Administrator
Yohei,

Sorry for the late reply.


On 01/24/2011 07:23 PM, Yohei Kakiuchi wrote:

> I confirmed that a user-defined point type described in
> http://www.ros.org/wiki/pcl_ros worked well for our purpose.
>
> I have a question for using a user-defined point type.
> PointXYZRGB defined in point_types.hpp is using PCL_ADD_POINT4D,
> EIGEN_ALIGNE16.
> I tested simple user-defined class not using EIGEN_ALIGN16 and
> a user-defined class added 'category' to PointXYZRGB.
> Both classes worked well.
> Which is the recommended / correct way for using a user-defined class?

The EIGEN_ALIGN16 macro is needed for alignment, and should be used unless you disabled vectorization in Eigen.

Furthermore, to make sure that the alignment works 100% in Windows, you should define a union over the data type that
you're trying to pad. See examples below.

> * test code
>
> ---
> namespace my_ns
> {
> #if 0
>    struct PointXYZRGBClass
>   {
>     float x;
>     float y;
>     float z;
>     float rgb;
>     uint32_t category;
>    };
> #else
>    struct PointXYZRGBClass
>    {
>      PCL_ADD_POINT4D;  // This adds the members x,y,z which can also be
> accessed using the point (which is float[4])
>      float rgb;
>      uint32_t category;
>      EIGEN_MAKE_ALIGNED_OPERATOR_NEW
>    } EIGEN_ALIGN16;
> #endif
> } // namespace my_ns

This is fine. I would do:

struct PointXYZRGBClass
{
   PCL_ADD_POINT4D;
   union
   {
     struct
     {
       float rgb;
       uint32_t category;
     }
     float data_c[4];
   } EIGEN_MAKE_ALIGNED_OPERATOR_NEW
} EIGEN_ALIGN16;


Cheers,
Radu.

>
> POINT_CLOUD_REGISTER_POINT_STRUCT
> (my_ns::PointXYZRGBClass,
>   (float, x, x)
>   (float, y, y)
>   (float, z, z)
>   (float, rgb, rgb)
>   (uint32_t, category, category)
>   );
>
> 2011/1/24 Kei Okada<[hidden email]>:
>>> Frequently, these problems are better solved by republishing some or
>>> all of the original points as a single PointCloud2 with a
>>> categorization field. The data can be sorted on that field for
>>> efficient access, sometimes that occurs naturally as a result of your
>>> algorithm, anyway.
>>
>> I see, that's seems good solution.
>>
>> Just to be clear, your suggestion is to make PointCloud2 data as followings.
>>     sensor_msgs::PointCloud2 cloud2_;
>>     cloud2_.fields.resize( 5 );
>>     cloud2_.fields[0].name = "x";
>>     cloud2_.fields[1].name = "y";
>>     cloud2_.fields[2].name = "z";
>>     cloud2_.fields[3].name = "rgb";
>>     cloud2_.fields[3].name = "label" or "category";
>> if this is correct, is there a way to convert from/to pcl::Point*** ??
>> Usually, we will write program using pcll:PointCloud<pcl::PointXYZRGB>...
>>
>>
>> On Sun, Jan 23, 2011 at 2:43 AM, Jack O'Quin<[hidden email]>  wrote:
>>> On Fri, Jan 21, 2011 at 7:32 AM, cmuell2s
>>> <[hidden email]>  wrote:
>>>> Hello all,
>>>>
>>>> I stuck at a small problem. I would like to publish a vector/array of
>>>> pcl::PointCloud<pcl::PointXYZ>.
>>>> I couldn't find a sensor_msg or std_msg which would do it, did I
>>>> overlooked sth?
>>>
>>> This comes up frequently. In many cases it seems the obvious solution.
>>>
>>> Often, problems become apparent on further consideration: who will
>>> read this vector of pointclouds? What operations must be performed on
>>> it?
>>>
>>> Frequently, these problems are better solved by republishing some or
>>> all of the original points as a single PointCloud2 with a
>>> categorization field. The data can be sorted on that field for
>>> efficient access, sometimes that occurs naturally as a result of your
>>> algorithm, anyway.
>>> --
>>>   joq
>>> _______________________________________________
>>> ros-users mailing list
>>> [hidden email]
>>> https://code.ros.org/mailman/listinfo/ros-users
>>>
>> _______________________________________________
>> ros-users mailing list
>> [hidden email]
>> https://code.ros.org/mailman/listinfo/ros-users
>>
> _______________________________________________
> ros-users mailing list
> [hidden email]
> https://code.ros.org/mailman/listinfo/ros-users
_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users