ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

What does "Assertion `cloud.points.size () == cloud.width * cloud.height' failed" mean?

asked 2012-10-04 22:21:41 -0500

tordalk gravatar image

Hello, after storing each points' coordinates of a point cloud in an array, then converting them to a ROSmessage and publishing them I get the following error message while running:

array: /opt/ros/fuerte/include/pcl-1.5/pcl/ros/conversions.h:248: void pcl::toROSMsg(const pcl::PointCloud<pointt>&, sensor_msgs::PointCloud2&) [with PointT = pcl::PointXYZ, sensor_msgs::PointCloud2 = sensor_msgs::PointCloud2_<std::allocator<void> >]: Assertion `cloud.points.size () == cloud.width * cloud.height' failed. Aborted (core dumped)

What does the last part about size, width and height mean?

Here's the part that might be the source of the error. The array's declared as 'field' with x,y,z as its elements.

msg->header.frame_id = "some_tf_frame";
msg->height = 1;
msg->width = pc.points.size();

//Storing the vector values in msg->points

for(i = msg->points.begin();i != msg->points.end();++i){
    msg->points.push_back (pcl::PointXYZ(field[j].x,field[j].y,field[j].z));
sensor_msgs::PointCloud2 output;
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-10-04 22:31:40 -0500

updated 2012-10-04 22:33:53 -0500

Keep in mind that setting msg->width and msg->height has no effect over msg->points. The problem is that you are trying to iterate over msg->points when it is still empty.

You can verify that actually, the inside of the for loop is never being executed and msg->points.size() will be 0. msg->width * msg->height will be equal to pc.points.size() and hence the assertion failure.

You should iterate over the correct variable. Probably pc.points

I might be wrong, but I hope this helps.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-10-04 22:21:41 -0500

Seen: 2,278 times

Last updated: Oct 04 '12