Go to the documentation of this file.00001 #ifndef OBJECT_MOVEIT_GRASPEDOBJECTHANDLER_H
00002 #define OBJECT_MOVEIT_GRASPEDOBJECTHANDLER_H
00003
00004
00005
00006 #include <ros/ros.h>
00007 #include <string>
00008 #include <moveit_msgs/AttachedCollisionObject.h>
00009
00010 namespace moveit_object_handling
00011 {
00012
00023 class GraspedObjectHandler
00024 {
00025 public:
00026 GraspedObjectHandler()
00027 {
00028 }
00029 virtual ~GraspedObjectHandler()
00030 {
00031 }
00032
00033 virtual bool attachObjectToRobot(const std::string& object_name, const std::string& attach_link_name) = 0;
00036 virtual bool detachObjectFromRobot(const std::string& object_name) = 0;
00037
00038 };
00039
00040
00046 class GraspedObjectHandlerMoveIt: public GraspedObjectHandler
00047 {
00048 public:
00053 GraspedObjectHandlerMoveIt(
00054 ros::NodeHandle& n, const std::vector<std::string>& _gripperLinkNames,
00055 const std::string& get_planning_scene_service = "/get_planning_scene",
00056 const std::string& set_planning_scene_topic = "/planning_scene");
00057
00058 virtual bool attachObjectToRobot(const std::string& object_name, const std::string& attach_link_name);
00059
00060 virtual bool detachObjectFromRobot(const std::string& object_name);
00061
00062 void waitForSubscribers();
00063
00064 private:
00065 bool attachObjectToRobot(const std::string& name, const std::string& link_name, const std::vector<std::string>& allowedTouchLinks);
00066
00067 static bool hasObject(const std::string& name, const std::vector<moveit_msgs::AttachedCollisionObject>& objs, moveit_msgs::AttachedCollisionObject& o);
00068
00069 static bool hasObject(const std::string& name, const std::vector<moveit_msgs::CollisionObject>& objs, moveit_msgs::CollisionObject& o);
00070
00071 static bool removeObject(const std::string& name, std::vector<moveit_msgs::CollisionObject>& objs);
00072
00073 static bool removeObject(const std::string& name, std::vector<moveit_msgs::AttachedCollisionObject>& objs);
00074
00075 void subscribeAndAdvertise(const std::string& get_planning_scene_service = "/get_planning_scene",
00076 const std::string& set_planning_scene_topic = "/planning_scene");
00077
00078 bool transformPose(const geometry_msgs::Pose& pose, const std::string& from_frame, const std::string& to_frame, geometry_msgs::Pose& p);
00079
00083 bool transformCollisionObject(const std::string& to_frame, moveit_msgs::CollisionObject& collision_object);
00084
00085 ros::ServiceClient moveit_planning_scene_client;
00086 ros::Publisher moveit_planning_scene_publisher;
00087
00088 ros::NodeHandle& node;
00089
00090 std::vector<std::string> gripperLinkNames;
00091 };
00092
00093 }
00094
00095 #endif // OBJECT_MOVEIT_GRASPEDOBJECTHANDLER_H