Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 };