21 #ifndef NORMAL_GENERATOR_H_ 22 #define NORMAL_GENERATOR_H_ 24 #include <Eigen/Dense> 25 #include <geometry_msgs/Point.h> 29 using namespace Eigen;
36 m = AngleAxisd(angle_x, Vector3d::UnitX())
37 * AngleAxisd(angle_y, Vector3d::UnitY())
38 * AngleAxisd(angle_z, Vector3d::UnitZ());
44 geometry_msgs::Point point;
58 normals.push_back(getRotationMatrix(0, 0, 0) * base_vec);
60 normals.push_back(getRotationMatrix(angle_x, 0, 0) * base_vec);
61 normals.push_back(getRotationMatrix(-angle_x, 0, 0) * base_vec);
62 normals.push_back(getRotationMatrix(0, angle_y, 0) * base_vec);
63 normals.push_back(getRotationMatrix(0, -angle_y, 0) * base_vec);
65 normals.push_back(getRotationMatrix(angle_x, angle_y, 0) * base_vec);
66 normals.push_back(getRotationMatrix(-angle_x, angle_y, 0) * base_vec);
67 normals.push_back(getRotationMatrix(angle_x, -angle_y, 0) * base_vec);
68 normals.push_back(getRotationMatrix(-angle_x, -angle_y, 0) * base_vec);
70 std::vector<geometry_msgs::Point> geom_points;
71 for (std::vector<Vector3d>::iterator iter = normals.begin(); iter != normals.end(); ++iter) {
72 geom_points.push_back(convertVectorFromEigen(*iter));
76 if (!savePath.empty()) {
78 for (std::vector<geometry_msgs::Point>::iterator iter = geom_points.begin(); iter != geom_points.end(); ++iter) {
79 geometry_msgs::Point normal = *iter;
80 ss << boost::lexical_cast<std::string>(normal.x) <<
"," << boost::lexical_cast<std::string>(normal.y) <<
"," << boost::lexical_cast<
std::string>(normal.z) <<
";";
84 std::ofstream
f(savePath.c_str());
86 ROS_DEBUG(
"Can't open file to save normals");
88 if ( !contents.empty() )
f << contents;
static geometry_msgs::Point convertVectorFromEigen(Vector3d vec)
static std::vector< geometry_msgs::Point > getNormalVectors(double angle_x, double angle_y, double angle_z, const std::string &savePath=std::string())
::xsd::cxx::tree::string< char, simple_type > string
static Matrix3d getRotationMatrix(double angle_x, double angle_y, double angle_z)