ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Can't use 2D indexing with an unorganized point cloud

asked 2021-05-30 00:03:45 -0500

dinesh gravatar image

I'm using perception_pcl package to convert sensor_msgs::msg::PointCloud2 to pcl::PointXYZRGB and get the rgb or x,y,z data according to the raw and column value according to below code:

pcl::PCLPointCloud2* cloud = new pcl::PCLPointCloud2; pcl::PointCloud<pcl::pointxyzrgb> cloud_xyzrgb;

// Convert to PCL data type
pcl_conversions::toPCL(*cloud_msg, *cloud);

pcl::fromROSMsg (*cloud_msg, cloud_xyzrgb);

std::cout<<cloud_xyzrgb.height<<"\t"<<cloud_xyzrgb.width<<std::endl;
std::cout<<cloud_xyzrgb.at(1,1)<<std::endl;

But when i run this node. i'm getting the below error:

1   202403
terminate called after throwing an instance of 'pcl::UnorganizedPointCloudException'
  what():  : Can't use 2D indexing with an unorganized point cloud

Environment:

Depth sensor: intel realsense d455 depth sensor
depth sensor driver: realsense-ros, foxy branch
ros version: ros2 foxy fitzroy
os: ubuntu 20.04 desktop

This same approach used to work in ros1 as i can remember. But as i migrated to ros2 foxy, looks like this feature hasn't implemented still now.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-30 01:14:51 -0500

dinesh gravatar image

Ok after few hours of debugging and research i found that their is a parameter in realsense node which enables the pointcloud being publishing to be organized, default being un-organized. So setting ordered_pc:=true made this issue solved. Here is my full command:

ros2 launch realsense2_camera rs_launch.py enable_pointcloud:=true ordered_pc:=true
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-05-30 00:03:45 -0500

Seen: 1,112 times

Last updated: May 30 '21