1 #ifndef __ROSEE_UTILS_EIGEN__ 2 #define __ROSEE_UTILS_EIGEN__ 5 #include <std_msgs/Float32MultiArray.h> 21 std_msgs::Float32MultiArray rosMatrix;
23 unsigned int nRow = eigenMatrix.rows();
24 unsigned int nCol = eigenMatrix.cols();
25 unsigned int size = nRow*nCol;
28 std::cerr <<
"[Utils::eigenMatrixToFloat32MultiArray] eigenMatrix passed has size 0" << std::endl;
32 rosMatrix.layout.dim.push_back(std_msgs::MultiArrayDimension());
33 rosMatrix.layout.dim.push_back(std_msgs::MultiArrayDimension());
34 rosMatrix.layout.dim[0].label =
"column";
35 rosMatrix.layout.dim[0].size = nCol;
36 rosMatrix.layout.dim[0].stride = nCol*nRow;
38 rosMatrix.layout.dim[1].label =
"row";
39 rosMatrix.layout.dim[1].size = nRow;
40 rosMatrix.layout.dim[1].stride = nRow;
42 rosMatrix.layout.data_offset = 0;
44 rosMatrix.data.resize(size);
46 for (
int iCol=0; iCol<nCol; iCol++){
47 for (
int iRow=0; iRow<nRow; iRow++){
49 rosMatrix.data.at(posRow + iRow) = eigenMatrix(iRow,iCol);
60 std::vector<float> stdVect(eigenVector.data(), eigenVector.data() + eigenVector.size());
67 #endif // __ROSEE_UTILS_EIGEN__ static std::vector< float > eigenVectorToStdVector(Eigen::VectorXd eigenVector)
static std_msgs::Float32MultiArray eigenMatrixToFloat32MultiArray(Eigen::MatrixXd eigenMatrix)
Utility to fill the Float32MultiArray ROS message from an eigen matrix.