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

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

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

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){
    j=distance(i,msg->points.begin());
    msg->points.push_back (pcl::PointXYZ(field[j].x,field[j].y,field[j].z));
}
sensor_msgs::PointCloud2 output;
pcl::toROSMsg(*msg,output);
pub.publish(output);
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

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

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

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

Question Tools

Stats

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

Seen: 2,523 times

Last updated: Oct 04 '12