perception_open3d icon indicating copy to clipboard operation
perception_open3d copied to clipboard

rosToOpen3d for tensor pointclouds does not handle custom fields correctly

Open willat343 opened this issue 3 years ago • 1 comments

There are a few problems with this function in terms of custom fields:

  • the output field type in the open3d structure is float32, regardless of the ros field type
  • custom fields are entered as triplets into the open3d structure, where the triplet contains 3 copies of the same data entry
  • only uint8/int8/float32 ros field types are handled in the iterator

This is a code snippet from the rosToOpen3d function:

        sensor_msgs::PointCloud2ConstIterator<float> ros_pc2_fx(*ros_pc2, ros_pc2->fields[num_fields].name);
        sensor_msgs::PointCloud2ConstIterator<float> ros_pc2_fy(*ros_pc2, ros_pc2->fields[num_fields].name);
        sensor_msgs::PointCloud2ConstIterator<float> ros_pc2_fz(*ros_pc2, ros_pc2->fields[num_fields].name);
        std::vector<Eigen::Vector3d> o3d_TensorList_fields;

        for (size_t i = 0; i < ros_pc2->height * ros_pc2->width; ++i, ++ros_pc2_fx, ++ros_pc2_fy, ++ros_pc2_fz)
        {
          o3d_TensorList_fields.push_back(Eigen::Vector3d(*ros_pc2_fx, *ros_pc2_fy, *ros_pc2_fz));
        }
        open3d::core::Tensor o3d_tpc_fields =
          open3d::core::eigen_converter::EigenVector3dVectorToTensor(o3d_TensorList_fields, dtype_f, device_type);
        o3d_tpc.SetPointAttr(ros_pc2->fields[num_fields].name, o3d_tpc_fields);

willat343 avatar May 12 '22 05:05 willat343

Yes, this should be corrected, there is no reason for the fields to be repeated. Please feel free to submit a PR but we will try to fix this asap.

nkhedekar avatar May 27 '22 15:05 nkhedekar