c++eigenrospoint-cloud-library

Invalid size when Initializing Eigen::Vector4f


When I try to run this line in ROS / PCL

Eigen::Vector4f normalized(3,1);

I get the following Error:

/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:281: 
void Eigen::PlainObjectBase<Derived>::resize(Eigen::Index, Eigen::Index) 
[with Derived = Eigen::Matrix<float, 4, 1>; Eigen::Index = long int]: 
Assertion 
`(!(RowsAtCompileTime!=Dynamic) || (rows==RowsAtCompileTime)) && 
(!(ColsAtCompileTime!=Dynamic) || (cols==ColsAtCompileTime)) && 
(!(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic) || 
(rows<=MaxRowsAtCompileTime)) && (!(ColsAtCompileTime==Dynamic && 
MaxColsAtCompileTime!=Dynamic) || (cols<=MaxColsAtCompileTime)) && rows>=0 && cols>=0 &&
 "Invalid sizes when resizing a matrix or array."' failed.
Aborted (core dumped)

I'm using Ubuntu 20.04, Eigen 3.3.7.

Can you please tell me how can I solve that? thanks in advance.


Solution

  • The solution as explained by @Homer512 is:

    normal.normalized();