jeudi 15 août 2019

How to assign vals to a Eigen Block of dynamic matrix

I'd like to save vals of point cloud of sensor_msgs::PointCloud2 in a Eigen::Block of dynamic matrix which I rename its name as View

typedef typename Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::Block<Matrix> View;

Then, in the source code, I declare a View object with known size:

View view(
(it->name == "normal_x") ? cloud.getDescriptorRowViewByName("normals", 0) : 
((it->name == "normal_y") ? cloud.getDescriptorRowViewByName("normals", 1): 
((it->name == "normal_z") ? cloud.getDescriptorRowViewByName("normals", 2): 
((isFeature[fieldId]) ? cloud.getFeatureViewByName(it->name) :
cloud.getDescriptorViewByName(it->name))))
         );

But when I try assigning vals to it, the segment fault occurred: view(0, ptId) = T(*reinterpret_cast<const uint16_t*>(fPtr)); where ptId is a int number and iterate from 0.

But as far as I know, if the declaration of a dynamic matrix with known size, the assignment of the matrix should be legal. Is this the problem of the version of Eigen?

Aucun commentaire:

Enregistrer un commentaire