link_to_collision.hpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 
00018 #include <stdint.h>
00019 #include <unordered_map>
00020 #include <vector>
00021 
00022 #include <Eigen/Dense>
00023 
00024 #include <ros/ros.h>
00025 #include <urdf/model.h>
00026 
00027 #include <boost/shared_ptr.hpp>
00028 #include <boost/scoped_ptr.hpp>
00029 #include <boost/pointer_cast.hpp>
00030 
00031 #include <fcl/collision_object.h>
00032 #include <fcl/collision.h>
00033 #include <fcl/distance.h>
00034 #include <fcl/collision_data.h>
00035 
00036 #include <std_msgs/ColorRGBA.h>
00037 #include <geometry_msgs/Vector3.h>
00038 #include <geometry_msgs/Quaternion.h>
00039 #include <geometry_msgs/Pose.h>
00040 
00041 
00042 #include "cob_obstacle_distance/marker_shapes/marker_shapes_interface.hpp"
00043 #include "cob_obstacle_distance/marker_shapes/marker_shapes.hpp"
00044 #include "cob_obstacle_distance/shapes_manager.hpp"
00045 #include "cob_obstacle_distance/obstacle_distance_data_types.hpp"
00046 
00047 class LinkToCollision
00048 {
00049     private:
00050         typedef boost::shared_ptr<const urdf::Link> PtrConstLink_t;
00051         typedef boost::shared_ptr<urdf::Link> PtrLink_t;
00052         typedef std::vector<boost::shared_ptr<urdf::Link> > VecPtrLink_t;
00053         typedef boost::shared_ptr<urdf::Collision> PtrCollision_t;
00054         typedef boost::shared_ptr<urdf::Geometry> PtrGeometry_t;
00055         typedef boost::shared_ptr<urdf::Mesh> PtrMesh_t;
00056         typedef boost::shared_ptr<urdf::Box> PtrBox_t;
00057         typedef boost::shared_ptr<urdf::Sphere> PtrSphere_t;
00058         typedef boost::shared_ptr<urdf::Cylinder> PtrCylinder_t;
00059         typedef std::unordered_map<std::string, std::vector<std::string> >::iterator MapIter_t;
00060 
00061         urdf::Model model_;
00062         bool success_;
00063         std::string root_frame_id_;
00064         std::unordered_map<std::string, std::vector<std::string> > self_collision_map_; 
00065 
00074         void createSpecificMarkerShape(const std::string& link_of_interest,
00075                                        const geometry_msgs::Pose& pose,
00076                                        const std_msgs::ColorRGBA& col,
00077                                        const PtrGeometry_t& geometry,
00078                                        PtrIMarkerShape_t& segment_of_interest_marker_shape);
00079 
00080 
00086         void poseURDFToMsg(const urdf::Pose& urdf_pose, geometry_msgs::Pose& msg_pose);
00087 
00088     public:
00089         typedef std::unordered_map<std::string, std::vector<std::string> > MapSelfCollisions_t;
00090 
00091         LinkToCollision();
00092         ~LinkToCollision();
00093 
00094         inline MapSelfCollisions_t::iterator getSelfCollisionsIterBegin()
00095         {
00096             return this->self_collision_map_.begin();
00097         }
00098 
00099         inline MapSelfCollisions_t::iterator getSelfCollisionsIterEnd()
00100         {
00101             return this->self_collision_map_.end();
00102         }
00103 
00104         bool ignoreSelfCollisionPart(const std::string& link_of_interest, const std::string& self_collision_obstacle_link);
00105 
00112         bool initFile(const std::string& root_frame_id, const std::string& urdf_file_name);
00113 
00120         bool initParameter(const std::string& root_frame_id, const std::string& urdf_param);
00121 
00130         bool initSelfCollision(XmlRpc::XmlRpcValue& self_collision_params, boost::scoped_ptr<ShapesManager>& sm);
00131 
00132 
00142         bool getMarkerShapeFromUrdf(const Eigen::Vector3d& abs_pos,
00143                                     const Eigen::Quaterniond& quat_pos,
00144                                     const std::string& link_of_interest,
00145                                     PtrIMarkerShape_t& segment_of_interest_marker_shape);
00146 
00157         bool getMarkerShapeFromType(const uint32_t& shape_type,
00158                                     const Eigen::Vector3d& abs_pos,
00159                                     const Eigen::Quaterniond& quat_pos,
00160                                     const std::string& link_of_interest,
00161                                     const Eigen::Vector3d& dimension,
00162                                     PtrIMarkerShape_t& segment_of_interest_marker_shape);
00163 
00172         bool getMarkerShapeFromType(const uint32_t& shape_type,
00173                                     const geometry_msgs::Pose& pose,
00174                                     const std::string& link_of_interest,
00175                                     const Eigen::Vector3d& dimension,
00176                                     PtrIMarkerShape_t& segment_of_interest_marker_shape);
00177 
00178 };


cob_obstacle_distance
Author(s): Marco Bezzon
autogenerated on Thu Jun 6 2019 21:19:14