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: Bumper Controller 00023 * Author: Nate Koenig mod by John Hsu 00024 * Date: 24 Sept 2008 00025 */ 00026 #ifndef GAZEBO_ROS_BUMPER_CONTROLLER_HH 00027 #define GAZEBO_ROS_BUMPER_CONTROLLER_HH 00028 00029 #define USE_CBQ 00030 #ifdef USE_CBQ 00031 #include <ros/callback_queue.h> 00032 #include <ros/advertise_options.h> 00033 #endif 00034 00035 #include <sys/time.h> 00036 00037 #include <gazebo/Controller.hh> 00038 #include <gazebo/Entity.hh> 00039 #include <gazebo/Param.hh> 00040 00041 // ros messages 00042 #include <ros/ros.h> 00043 #include "boost/thread/mutex.hpp" 00044 #include <std_msgs/String.h> 00045 00046 #include <gazebo_plugins/ContactState.h> 00047 #include <gazebo_plugins/ContactsState.h> 00048 00049 namespace gazebo 00050 { 00051 class ContactSensor; 00052 00055 00080 00081 class GazeboRosBumper : public Controller 00082 { 00084 public: GazeboRosBumper(Entity *parent ); 00085 00087 public: virtual ~GazeboRosBumper(); 00088 00091 protected: virtual void LoadChild(XMLConfigNode *node); 00092 00094 protected: virtual void InitChild(); 00095 00097 protected: virtual void UpdateChild(); 00098 00100 protected: virtual void FiniChild(); 00101 00103 private: ContactSensor *myParent; 00104 00107 private: Body *myFrame; 00108 00110 private: ros::NodeHandle* rosnode_; 00111 private: ros::Publisher contact_pub_; 00112 00114 private: ParamT<std::string> *bumperTopicNameP; 00115 private: std::string bumperTopicName; 00116 00117 private: ParamT<std::string> *frameNameP; 00118 private: std::string frameName; 00119 00121 private: boost::mutex lock; 00122 00124 private: gazebo_plugins::ContactsState contactsStateMsg; 00125 00127 private: ParamT<std::string> *robotNamespaceP; 00128 private: std::string robotNamespace; 00129 00131 private: int contactConnectCount; 00132 private: void ContactConnect(); 00133 private: void ContactDisconnect(); 00134 00135 #ifdef USE_CBQ 00136 private: ros::CallbackQueue contact_queue_; 00137 private: void ContactQueueThread(); 00138 private: boost::thread callback_queue_thread_; 00139 #endif 00140 00141 }; 00142 00144 00145 00146 } 00147 00148 #endif 00149