$search
00001 /* 00002 * Gazebo - Outdoor Multi-Robot Simulator 00003 * Copyright (C) 2003 00004 * Nate Koenig & Andrew Howard 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 /* 00022 * Desc: 3D position interface. 00023 * Author: Sachin Chitta and John Hsu 00024 * Date: 10 June 2008 00025 * SVN: $Id$ 00026 */ 00027 #ifndef GAZEBO_ROS_GRASP_HACK_HH 00028 #define GAZEBO_ROS_GRASP_HACK_HH 00029 00030 #include <ros/callback_queue.h> 00031 #include <ros/advertise_options.h> 00032 00033 #include <gazebo/Controller.hh> 00034 #include <gazebo/Entity.hh> 00035 #include <gazebo/Model.hh> 00036 #include <gazebo/Body.hh> 00037 #include <gazebo/Joint.hh> 00038 #include <gazebo/Param.hh> 00039 #include <gazebo/Time.hh> 00040 #include <gazebo/Pose3d.hh> 00041 00042 #include <ros/ros.h> 00043 #include "boost/thread/mutex.hpp" 00044 #include <std_msgs/String.h> 00045 00046 #include <map> 00047 00048 namespace gazebo 00049 { 00050 class GazeboRosGraspHack : public Controller 00051 { 00052 00053 class GripperPose 00054 { 00055 public: 00056 GripperPose(){this->body = NULL;}; 00057 Body* body; 00058 Pose3d relative_pose; 00059 }; 00060 00062 public: GazeboRosGraspHack(Entity *parent ); 00063 00065 public: virtual ~GazeboRosGraspHack(); 00066 00069 protected: virtual void LoadChild(XMLConfigNode *node); 00070 00072 protected: virtual void InitChild(); 00073 00075 protected: virtual void UpdateChild(); 00076 00078 protected: virtual void FiniChild(); 00079 00081 private: Body *myParentBody; 00082 00084 private: Model *myParentModel; 00085 00087 private: Body* l_wrist_roll_body; 00088 private: Body* r_wrist_roll_body; 00089 00091 private: std::map<std::string, GripperPose > gripper_bodies; 00092 private: std::vector<Pose3d> gripper_relative_poses; 00093 00094 private: bool l_grasp; 00095 private: bool r_grasp; 00096 00098 private: Pose3d l_grasp_relative_pose; 00099 private: Pose3d r_grasp_relative_pose; 00100 00102 private: ros::NodeHandle* rosnode_; 00103 private: ros::Publisher pub_; 00104 00106 private: ParamT<std::string> *topicNameP; 00107 private: std::string topicName; 00108 00109 private: ParamT<double> *graspCheckRateP; 00110 private: double graspCheckRate; 00111 private: Time last_grasp_check_time; 00112 00114 private: boost::mutex lock; 00115 private: bool found_gripper_links; 00116 private: void GetGripperLinks(); 00117 private: void CheckForGrasps(); 00118 00120 private: Time last_time; 00121 00123 private: ParamT<std::string> *robotNamespaceP; 00124 private: std::string robotNamespace; 00125 00127 private: int graspHackConnectCount; 00128 private: void GraspHackConnect(); 00129 private: void GraspHackDisconnect(); 00130 00131 private: ros::CallbackQueue grasp_hack_queue_; 00132 private: void GraspHackQueueThread(); 00133 private: boost::thread callback_queue_thread_; 00134 private: boost::thread get_gripper_links_thread_; 00135 00136 }; 00137 00139 00140 00141 00142 } 00143 00144 #endif 00145