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: Actuator array controller for a Pr2 robot. 00023 * Author: Nathan Koenig 00024 * Date: 19 Sept 2007 00025 * SVN: $Id$ 00026 */ 00027 #ifndef GAZEBO_ROS_PUB_WORLD_STATE_HH 00028 #define GAZEBO_ROS_PUB_WORLD_STATE_HH 00029 00030 // Custom Callback Queue 00031 #include <ros/callback_queue.h> 00032 #include <ros/advertise_options.h> 00033 00034 #include <gazebo/Controller.hh> 00035 #include <gazebo/Body.hh> 00036 #include <gazebo/Model.hh> 00037 #include <gazebo/World.hh> 00038 #include <gazebo/Simulator.hh> 00039 #include <gazebo_plugins/WorldState.h> 00040 00041 #include <ros/ros.h> 00042 00043 #include <map> 00044 #include <vector> 00045 #include <string> 00046 00047 #include <boost/thread.hpp> 00048 00049 namespace gazebo 00050 { 00053 00106 class GazeboRosPubWorldState : public Controller 00107 { 00110 public: GazeboRosPubWorldState(Entity *parent); 00111 00113 public: virtual ~GazeboRosPubWorldState(); 00114 00117 protected: virtual void LoadChild(XMLConfigNode *node); 00118 00120 protected: virtual void InitChild(); 00121 00123 protected: virtual void UpdateChild(); 00124 00126 protected: virtual void FiniChild(); 00127 00129 private: int worldStateConnectCount; 00130 private: void WorldStateConnect(); 00131 private: void WorldStateDisconnect(); 00132 00134 private: gazebo_plugins::WorldState worldStateMsg; 00135 00137 private: gazebo::Model* parent_model_; 00138 00140 private: ros::NodeHandle* rosnode_; 00141 private: ros::Publisher pub_; 00142 00144 private: boost::mutex lock; 00145 00147 private: ParamT<std::string> *robotNamespaceP; 00148 private: std::string robotNamespace; 00149 00151 private: ParamT<std::string> *topicNameP; 00152 private: std::string topicName; 00153 00155 private: ParamT<std::string> *frameNameP; 00156 private: std::string frameName; 00157 00158 // Custom Callback Queue 00159 private: ros::CallbackQueue queue_; 00160 private: void QueueThread(); 00161 private: boost::thread callback_queue_thread_; 00162 00163 }; 00164 00166 00167 00168 } 00169 #endif 00170