ROSEndEffector
ROS End-Effector package: provides a ROS-based set of standard interfaces to command robotics end-effectors in an agnostic fashion.
UtilsYAML.h
Go to the documentation of this file.
1 #ifndef __ROSEE_UTILS_YAML__
2 #define __ROSEE_UTILS_YAML__
3 
4 #include <yaml-cpp/yaml.h>
5 #include <Eigen/Dense>
6 
7 
8 namespace ROSEE { namespace Utils {
9 
18 static Eigen::MatrixXd yamlMatrixToEigen(const YAML::Node &matrixNode) {
19 
20  //note: they say adding row by row to eigen is tremendously slow,
21  // so we use vector
22  std::vector<std::vector<float>> stdMat;
23  stdMat = matrixNode.as<std::vector<std::vector<float>>>();
24 
25  Eigen::MatrixXd eigenMat(stdMat.size(), stdMat.at(0).size());
26 
27  for (int iRow = 0; iRow<stdMat.size(); iRow++) {
28  for (int iCol = 0; iCol<stdMat.at(0).size(); iCol++) {
29  eigenMat(iRow, iCol) = stdMat.at(iRow).at(iCol);
30  }
31  }
32 
33  return eigenMat;
34 
35 }
36 
37 static Eigen::VectorXd yamlVectorToEigen(const YAML::Node &vectorNode) {
38 
39  //note: they say adding row by row to eigen is tremendously slow,
40  // so we use vector
41  std::vector<float> stdVect;
42  stdVect = vectorNode.as<std::vector<float>>();
43 
44  Eigen::VectorXd eigenVec(stdVect.size());
45 
46  for (int i = 0; i<stdVect.size(); i++) {
47  eigenVec(i) = stdVect.at(i);
48  }
49 
50  return eigenVec;
51 
52 }
53 
54 }
55 
56 }
57 
58 #endif // __ROSEE_UTILS_YAML__
static Eigen::MatrixXd yamlMatrixToEigen(const YAML::Node &matrixNode)
given a yaml node with a structure like
Definition: UtilsYAML.h:18
static Eigen::VectorXd yamlVectorToEigen(const YAML::Node &vectorNode)
Definition: UtilsYAML.h:37