gazebo_ros_controller_manager.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef GAZEBO_CONTROLLER_MANAGER_H
00031 #define GAZEBO_CONTROLLER_MANAGER_H
00032 
00033 #include <vector>
00034 #include <map>
00035 
00036 #include "physics/World.hh"
00037 #include "physics/Model.hh"
00038 #include "physics/physics.h"
00039 #include "common/Time.hh"
00040 #include "common/Plugin.hh"
00041 
00042 #include "pr2_hardware_interface/hardware_interface.h"
00043 #include "pr2_controller_manager/controller_manager.h"
00044 #include "pr2_gazebo_plugins/SetModelsJointsStates.h"
00045 #include "pr2_mechanism_model/robot.h"
00046 #include <tinyxml.h>
00047 #include <ros/ros.h>
00048 #undef USE_CBQ
00049 #ifdef USE_CBQ
00050 #include <ros/callback_queue.h>
00051 #endif
00052 
00053 #include "boost/thread/mutex.hpp"
00054 
00055 namespace gazebo
00056 {
00057 class GazeboRosControllerManager : public ModelPlugin
00058 {
00059 public:
00060   GazeboRosControllerManager();
00061   virtual ~GazeboRosControllerManager();
00062   void Load( physics::ModelPtr _parent, sdf::ElementPtr _sdf );
00063 
00064 protected:
00065   // Inherited from gazebo::Controller
00066   virtual void UpdateChild();
00067 
00068 private:
00069 
00070   gazebo::physics::ModelPtr parent_model_;
00071   pr2_hardware_interface::HardwareInterface hw_;
00072   pr2_controller_manager::ControllerManager *cm_;
00073 
00077   pr2_mechanism_model::RobotState *fake_state_;
00078   std::vector<gazebo::physics::JointPtr>  joints_;
00079 
00081   //private: ParamT<std::string> *setModelsJointsStatesServiceNameP;
00082   //private: std::string setModelsJointsStatesServiceName;
00083 
00084   /*
00085    * \brief read pr2.xml for actuators, and pass tinyxml node to mechanism control node's initXml.
00086    */
00087   void ReadPr2Xml();
00088 
00089   /*
00090    *  \brief pointer to ros node
00091    */
00092   ros::NodeHandle* rosnode_;
00093 
00095   private: ros::ServiceServer setModelsJointsStatesService;
00096 
00098   private: bool setModelsJointsStates(pr2_gazebo_plugins::SetModelsJointsStates::Request &req,
00099                                       pr2_gazebo_plugins::SetModelsJointsStates::Response &res);
00100 
00102   /*
00103    *  \brief tmp vars for performance checking
00104    */
00105   double wall_start_, sim_start_;
00106 
00108   //ParamT<std::string> *robotParamP;
00109   //ParamT<std::string> *robotNamespaceP;
00110   std::string robotParam;
00111   std::string robotNamespace;
00112 
00113   bool fake_calibration_;
00114 
00115 #ifdef USE_CBQ
00116   private: ros::CallbackQueue controller_manager_queue_;
00117   private: void ControllerManagerQueueThread();
00118   private: boost::thread controller_manager_callback_queue_thread_;
00119 #endif
00120   private: void ControllerManagerROSThread();
00121   private: boost::thread ros_spinner_thread_;
00122 
00123   // Pointer to the model
00124   private: physics::WorldPtr world;
00125 
00126   // Pointer to the update event connection
00127   private: event::ConnectionPtr updateConnection;
00128 
00129   // subscribe to world stats
00130   private: transport::NodePtr node;
00131   private: transport::SubscriberPtr statsSub;
00132   private: common::Time simTime;
00133 };
00134 
00136 
00137 
00138 }
00139 
00140 #endif
00141 


sr_gazebo_plugins
Author(s): adapted by Ugo(software@shadowrobot.com), Sachin Chitta, Stu Glaser, John Hsu
autogenerated on Fri Jan 3 2014 12:08:17