ros2 / ros2/common_interfaces

PointCloud2Modifier::setPointCloud2FieldsByString does not support intensity

Open
#263 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
393
Forks
157
PR merge metrics
No merged PRs in 30d

Description

Bug report

Required Info:

  • Operating System:
    • Ubuntu 22.04
  • Installation type:
    • apt
  • Version or commit hash:
    • c0c0bc57f958eb54a142446f0c2a475754367eee
  • 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: https://github.com/ros2/common_interfaces/blob/c0c0bc57f958eb54a142446f0c2a475754367eee/sensor_msgs/msg/PointField.msg#L12

Yet it is not implemented here: https://github.com/ros2/common_interfaces/blob/c0c0bc57f958eb54a142446f0c2a475754367eee/sensor_msgs/include/sensor_msgs/impl/point_cloud2_iterator.hpp#L195

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sensor_msgs/include/sensor_msgs/impl/point_cloud2_iterator.hpp at PointCloud2Modifier::setPointCloud2FieldsByString and reproduce the reported call with "xyz" and "intensity". Compare the supported field names with sensor_msgs/msg/PointField.msg; done means the call creates an intensity field with the expected datatype without throwing a runtime error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
robotics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.