Skip to content

PointCloud2Modifier::setPointCloud2FieldsByString does not support intensity #263

@john-maidbot

Description

@john-maidbot

Bug report

Required Info:

  • Operating System:
    • Ubuntu 22.04
  • Installation type:
    • apt
  • Version or commit hash:
  • DDS implementation:
    • CycloneDDS
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

    sensor_msgs::msg::PointCloud2::SharedPtr pcl(new sensor_msgs::msg::PointCloud2);
    sensor_msgs::PointCloud2Modifier modifier(*pcl);
    modifier.setPointCloud2FieldsByString(2, "xyz", "intensity");

Expected behavior

Intensity field is created with correct datatype as expected.

Actual behavior

The code crashes with a runtime error.

[deskew_node-1] terminate called after throwing an instance of 'std::runtime_error'
[deskew_node-1]   what():  Field intensity does not exist

Additional information

The intensity field is claimed to be supported here:

# Common PointField names are x, y, z, intensity, rgb, rgba

Yet it is not implemented here:

inline void PointCloud2Modifier::setPointCloud2FieldsByString(int n_fields, ...)

Was there a reason for not including the intensity field?

In the meantime, I think I can work around this as follows:

modifier.setPointCloud2Fields(
    4,  // Number of fields
    "x", 1, sensor_msgs::msg::PointField::FLOAT32,  // x field
    "y", 1, sensor_msgs::msg::PointField::FLOAT32,  // y field
    "z", 1, sensor_msgs::msg::PointField::FLOAT32,  // z field
    "intensity", 1, sensor_msgs::msg::PointField::FLOAT32 // intensity field
);

Thank you for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions