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_HH 00027 #define GAZEBO_ROS_BUMPER_HH 00028 00029 #include <ros/ros.h> 00030 #include <ros/callback_queue.h> 00031 #include <ros/advertise_options.h> 00032 00033 #include <sys/time.h> 00034 00035 #include "sdf/interface/Param.hh" 00036 #include "physics/physics.h" 00037 #include "transport/TransportTypes.hh" 00038 #include "msgs/MessageTypes.hh" 00039 #include "common/Time.hh" 00040 #include "sensors/SensorTypes.hh" 00041 #include "sensors/ContactSensor.hh" 00042 #include "plugins/ContactPlugin.hh" 00043 00044 #include <boost/thread.hpp> 00045 #include <boost/thread/mutex.hpp> 00046 00047 #include <std_msgs/String.h> 00048 00049 #include <gazebo_msgs/ContactState.h> 00050 #include <gazebo_msgs/ContactsState.h> 00051 00052 namespace gazebo 00053 { 00055 class GazeboRosBumper : public ContactPlugin 00056 { 00058 public: GazeboRosBumper(); 00059 00061 public: ~GazeboRosBumper(); 00062 00065 public: void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf); 00066 00068 protected: virtual void UpdateChild(); 00069 00070 00072 private: ros::NodeHandle* rosnode_; 00073 private: ros::Publisher contact_pub_; 00074 00076 private: std::string bumper_topic_name_; 00077 00078 private: std::string frame_name_; 00079 00081 private: gazebo_msgs::ContactsState contact_state_msg_; 00082 00084 private: std::string robot_namespace_; 00085 00087 private: int contact_connect_count_; 00088 private: void ContactConnect(); 00089 private: void ContactDisconnect(); 00090 00091 private: ros::CallbackQueue contact_queue_; 00092 private: void ContactQueueThread(); 00093 private: boost::thread callback_queue_thread_; 00094 00095 // Pointer to the update event connection 00096 private: event::ConnectionPtr update_connection_; 00097 }; 00098 00099 } 00100 00101 #endif 00102