7 #include <boost/filesystem.hpp> 12 const std::vector<geometry_msgs::Vector3>& orients_msg,
13 std::vector<Eigen::Matrix3d>& m_orients)
17 for(
auto v : orients_msg)
20 Eigen::Vector3d eigen_vec;
25 eigen_vec.normalize();
28 Eigen::Vector3d candidate_dir = Eigen::Vector3d::UnitX();
29 if ( std::abs(eigen_vec.dot(Eigen::Vector3d::UnitX())) > 0.8 )
32 candidate_dir = Eigen::Vector3d::UnitY();
35 Eigen::Vector3d y_vec = eigen_vec.cross(candidate_dir).normalized();
37 Eigen::Vector3d x_vec = y_vec.cross(eigen_vec).normalized();
40 Eigen::Matrix3d m = Eigen::Matrix3d::Identity();
45 m_orients.push_back(m);
49 void planeAxesToEigenMatrixImpl(
const Eigen::Vector3d& x_axis,
const Eigen::Vector3d& y_axis,
const Eigen::Vector3d& z_axis,
52 m = Eigen::Matrix3d::Identity();
58 void planeToEigenAffine3dImpl(
const Eigen::Vector3d& o,
const Eigen::Matrix3d& m, Eigen::Affine3d& e)
60 e = Eigen::Affine3d::Identity();
61 e.matrix().block<3,3>(0,0) = m;
62 e.matrix().col(3).head<3>() = o;
71 void planeAxesToEigenMatrix(
const Eigen::Vector3d& x_axis,
const Eigen::Vector3d& y_axis,
const Eigen::Vector3d& z_axis,
74 planeAxesToEigenMatrixImpl(x_axis, y_axis, z_axis, m);
78 geometry_msgs::Quaternion& q_msg)
81 planeAxesToEigenMatrixImpl(x_axis, y_axis, z_axis, m);
83 Eigen::Quaterniond e_q(m);
88 const Eigen::Vector3d& x_axis,
const Eigen::Vector3d& y_axis,
const Eigen::Vector3d& z_axis,
92 planeAxesToEigenMatrixImpl(x_axis, y_axis, z_axis, m);
94 planeToEigenAffine3dImpl(origin, m, e);
97 void planeToEigenAffine3d(
const Eigen::Vector3d& origin,
const Eigen::Matrix3d& orientation, Eigen::Affine3d& e)
99 planeToEigenAffine3dImpl(origin, orientation, e);
103 const Eigen::Vector3d& x_axis,
const Eigen::Vector3d& y_axis,
const Eigen::Vector3d& z_axis,
104 geometry_msgs::Pose& p)
109 planeAxesToEigenMatrixImpl(x_axis, y_axis, z_axis, m);
111 planeToEigenAffine3dImpl(origin, m, e);
115 void planeToPoseMsg(
const Eigen::Vector3d& origin,
const Eigen::Matrix3d& orientation,
116 geometry_msgs::Pose& p)
119 planeToEigenAffine3dImpl(origin, orientation, e);
125 assert(boost::filesystem::exists(file_path));
132 mesh = boost::get<shape_msgs::Mesh>(mesh_msg);
136 const Eigen::Vector3d& scale_vector,
137 const std::string& frame_id,
138 const geometry_msgs::Pose& p,
139 int object_operation)
141 moveit_msgs::CollisionObject co;
149 const Eigen::Vector3d& scale_vector,
150 const std::string& frame_id,
151 const geometry_msgs::Pose& p,
152 moveit_msgs::CollisionObject& co,
153 int object_operation)
155 assert(boost::filesystem::exists(file_path));
157 boost::filesystem::path boost_path(file_path);
160 boost_path.filename().string(),
161 p, co, object_operation);
165 const Eigen::Vector3d& scale_vector,
166 const std::string& frame_id,
167 const std::string& obj_id,
168 const geometry_msgs::Pose& p,
169 moveit_msgs::CollisionObject& co,
172 assert(boost::filesystem::exists(file_path));
174 co.header.frame_id = frame_id;
178 co.mesh_poses.resize(1);
181 co.mesh_poses[0] = p;
183 assert(co.ADD == op || co.REMOVE == op || co.APPEND == op || co.MOVE == op);
188 const std::string& file_path,
189 const Eigen::Vector3d& scale_vector,
190 const std::string& frame_id,
191 const std::string& link_id,
192 const geometry_msgs::Pose& p,
193 int object_operation)
195 moveit_msgs::AttachedCollisionObject ato;
203 const Eigen::Vector3d& scale_vector,
204 const std::string& frame_id,
205 const std::string& link_id,
206 const geometry_msgs::Pose& p,
207 moveit_msgs::AttachedCollisionObject& aco,
208 int object_operation)
210 assert(boost::filesystem::exists(file_path));
212 boost::filesystem::path boost_path(file_path);
215 boost_path.filename().string(),
216 p, aco, object_operation);
220 const Eigen::Vector3d& scale_vector,
221 const std::string& frame_id,
222 const std::string& link_id,
223 const std::string& obj_id,
224 const geometry_msgs::Pose& p,
225 moveit_msgs::AttachedCollisionObject& aco,
226 int object_operation)
228 aco.link_name = link_id;
moveit_msgs::AttachedCollisionObject savedSTLToAttachedCollisionObjectMsg(const std::string &file_path, const Eigen::Vector3d &scale_vector, const std::string &frame_id, const std::string &link_id, const geometry_msgs::Pose &p, int object_operation=moveit_msgs::CollisionObject::ADD)
void poseEigenToMsg(const Eigen::Affine3d &e, geometry_msgs::Pose &m)
void quaternionEigenToMsg(const Eigen::Quaterniond &e, geometry_msgs::Quaternion &m)
void convertOrientationVectors(const std::vector< geometry_msgs::Vector3 > &orients_msg, std::vector< Eigen::Matrix3d > &m_orients)
void savedSTLToCollisionObjectMsg(const std::string &file_path, const Eigen::Vector3d &scale_vector, const std::string &frame_id, const geometry_msgs::Pose &p, moveit_msgs::CollisionObject &co, int object_operation=moveit_msgs::CollisionObject::ADD)
void vectorMsgToEigen(const geometry_msgs::Vector3 &m, Eigen::Vector3d &e)
void savedSTLToMeshShapeMsg(const std::string &file_path, const Eigen::Vector3d &scale_vector, shape_msgs::Mesh &mesh)
void planeToEigenAffine3d(const Eigen::Vector3d &origin, const Eigen::Vector3d &x_axis, const Eigen::Vector3d &y_axis, const Eigen::Vector3d &z_axis, Eigen::Affine3d &e)
void planeAxesToEigenMatrix(const Eigen::Vector3d &x_axis, const Eigen::Vector3d &y_axis, const Eigen::Vector3d &z_axis, Eigen::Matrix3d &m)
void planeAxesToQuaternionMsg(const Eigen::Vector3d &x_axis, const Eigen::Vector3d &y_axis, const Eigen::Vector3d &z_axis, geometry_msgs::Quaternion &q_msg)
bool constructMsgFromShape(const Shape *shape, ShapeMsg &shape_msg)
Mesh * createMeshFromResource(const std::string &resource)
static const std::string FILE_URL_PREFIX
void planeToPoseMsg(const Eigen::Vector3d &origin, const Eigen::Vector3d &x_axis, const Eigen::Vector3d &y_axis, const Eigen::Vector3d &z_axis, geometry_msgs::Pose &p)
boost::variant< shape_msgs::SolidPrimitive, shape_msgs::Mesh, shape_msgs::Plane > ShapeMsg