我想给一个动态大小的矩阵赋一个向量。如以下代码所示:
Eigen::Vector3f VectorCam; // Vector in camera frame
Eigen::MatrixXf VectorsCam; // Matrix contains the vectors
for (int i=0; i<=theta1.size(); i++)
{
std::cout << "I'm In theta1.size for loop" << std::endl;
VectorCam << sin(theta1[i]), sin(theta2[i]), cos(theta1[i])*cos(theta2[i]);
std::cout << "theta1.size is:" << theta1.size() << std::endl;
std::cout << VectorCam << std::endl;
VectorsCam.col(i) = VectorCam; // Matrix of Camera Vectors
std::cout << "Vectorscam" << VectorsCam << std::endl;
}
在终点站我收到了这个(下面)!知道for循环仍在第一次运行中,并且它应该在退出之前至少运行2次!我认为问题出在VectorScam.col(I)中
I'm In theta1.size for loop theta1.size为:1 1 1 7.82347E-10 visual_servo_node:/usr/include/eigen3/eigen/src/core/block.h:123:eigen::block<xprtype,BlockRows,BlockCols,InnerPanel::block(XprType&matrix<float,-1,-1>;int BlockRows=-1;int BlockCols=1;bool InnerPanel=true;eigen::index=long int]:(((BlockRows==1)&&(PlockCols==XPRType::COLSATCOMPILETime)&&I<XPR.Rows())((BlockRows==XPRType::RowSATCOMPILETime)&&(PlockCols==1)&&I<XPR.COLS())'失败。中止(核心转储)
在调用
在循环写入之前
Eigen::MatrixXf VectorsCam(3, theta1.size()); // Matrix contains the vectors
(我假设循环的意思是