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_STEP_WORLD_STATE_HH 00028 #define GAZEBO_ROS_STEP_WORLD_STATE_HH 00029 00030 // Custom Callback Queue 00031 #include <ros/callback_queue.h> 00032 #include <ros/subscribe_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 #include <boost/thread.hpp> 00043 00044 #include <map> 00045 #include <vector> 00046 #include <string> 00047 00048 namespace gazebo 00049 { 00052 00068 class GazeboRosStepWorldState : public Controller 00069 { 00072 public: GazeboRosStepWorldState(Entity *parent); 00073 00075 public: virtual ~GazeboRosStepWorldState(); 00076 00079 protected: virtual void LoadChild(XMLConfigNode *node); 00080 00082 protected: virtual void InitChild(); 00083 00085 protected: virtual void UpdateChild(); 00086 00088 protected: virtual void FiniChild(); 00089 00091 private: gazebo_plugins::WorldState worldStateMsg; 00092 00094 private: const std::map<std::string,gazebo::Body*> *bodies; 00095 00097 private: gazebo::Model* parent_model_; 00098 00100 private: std::vector<gazebo::Model*> models; 00101 00103 private: std::map<std::string,gazebo::Body*> all_bodies; 00104 00106 private: ros::NodeHandle* rosnode_; 00107 private: ros::Subscriber sub_; 00108 private: void WorldStateCallback(const gazebo_plugins::WorldStateConstPtr& worldStateMsg); 00109 00111 private: ParamT<std::string> *robotNamespaceP; 00112 private: std::string robotNamespace; 00113 00115 private: ParamT<std::string> *topicNameP; 00116 private: std::string topicName; 00117 00119 private: ParamT<std::string> *frameNameP; 00120 private: std::string frameName; 00121 00122 // Custom Callback Queue 00123 private: ros::CallbackQueue queue_; 00124 private: void QueueThread(); 00125 private: boost::thread callback_queue_thread_; 00126 00127 }; 00128 00130 00131 00132 } 00133 #endif 00134