初始化 Vector4f 时出现无效尺寸。

huangapple go评论76阅读模式
英文:

Invalid size when Initializing Vector4f

问题

当我尝试在ROS / PCL中运行此行时,我收到以下错误:

Eigen::Vector4f normalized(3,1);

我得到以下错误信息:

/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)

我使用的是Ubuntu 20.04,Eigen 3.3.7

请问我应该如何解决这个问题?提前感谢。

英文:

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&lt;Derived&gt;::resize(Eigen::Index, Eigen::Index) 
[with Derived = Eigen::Matrix&lt;float, 4, 1&gt;; Eigen::Index = long int]: 
Assertion 
`(!(RowsAtCompileTime!=Dynamic) || (rows==RowsAtCompileTime)) &amp;&amp; 
(!(ColsAtCompileTime!=Dynamic) || (cols==ColsAtCompileTime)) &amp;&amp; 
(!(RowsAtCompileTime==Dynamic &amp;&amp; MaxRowsAtCompileTime!=Dynamic) || 
(rows&lt;=MaxRowsAtCompileTime)) &amp;&amp; (!(ColsAtCompileTime==Dynamic &amp;&amp; 
MaxColsAtCompileTime!=Dynamic) || (cols&lt;=MaxColsAtCompileTime)) &amp;&amp; rows&gt;=0 &amp;&amp; cols&gt;=0 &amp;&amp;
 &quot;Invalid sizes when resizing a matrix or array.&quot;&#39; 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.

答案1

得分: 0

@Homer512解释的解决方案是:

normal.normalized();
英文:

The solution as explained by @Homer512 is:

normal.normalized();

huangapple
  • 本文由 发表于 2023年5月25日 03:37:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76326886.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定