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 <tinyxml.h>
00037 #include <boost/thread/mutex.hpp>
00038 
00039 #include <ros/ros.h>
00040 #include <pr2_hardware_interface/hardware_interface.h>
00041 #include <pr2_controller_manager/controller_manager.h>
00042 #include <pr2_gazebo_plugins/SetModelsJointsStates.h>
00043 #include <pr2_mechanism_model/robot.h>
00044 
00045 #include <gazebo/physics/World.hh>
00046 #include <gazebo/physics/Model.hh>
00047 #include <gazebo/physics/physics.hh>
00048 #include <gazebo/common/Time.hh>
00049 #include <gazebo/common/Plugin.hh>
00050 
00051 #undef USE_CBQ
00052 #ifdef USE_CBQ
00053 #include <ros/callback_queue.h>
00054 #endif
00055 
00056 namespace gazebo
00057 {
00058 
00059 class GazeboRosControllerManager : public ModelPlugin
00060 {
00061 public:
00062   GazeboRosControllerManager();
00063   virtual ~GazeboRosControllerManager();
00064   void Load( physics::ModelPtr _parent, sdf::ElementPtr _sdf );
00065 
00066 protected:
00067   // Inherited from gazebo::Controller
00068   virtual void UpdateChild();
00069 
00070 private:
00071 
00072   gazebo::physics::ModelPtr parent_model_;
00073   pr2_hardware_interface::HardwareInterface hw_;
00074   pr2_controller_manager::ControllerManager *cm_;
00075 
00079   pr2_mechanism_model::RobotState *fake_state_;
00080   std::vector<gazebo::physics::JointPtr>  joints_;
00081 
00083   //private: ParamT<std::string> *setModelsJointsStatesServiceNameP;
00084   //private: std::string setModelsJointsStatesServiceName;
00085 
00086   /*
00087    * \brief read pr2.xml for actuators, and pass tinyxml node to mechanism control node's initXml.
00088    */
00089   void ReadPr2Xml();
00090 
00091   /*
00092    *  \brief pointer to ros node
00093    */
00094   ros::NodeHandle* rosnode_;
00095 
00097   private: ros::ServiceServer setModelsJointsStatesService;
00098 
00100   private: bool setModelsJointsStates(pr2_gazebo_plugins::SetModelsJointsStates::Request &req,
00101                                       pr2_gazebo_plugins::SetModelsJointsStates::Response &res);
00102 
00104   /*
00105    *  \brief tmp vars for performance checking
00106    */
00107   double wall_start_, sim_start_;
00108 
00110   //ParamT<std::string> *robotParamP;
00111   //ParamT<std::string> *robotNamespaceP;
00112   std::string robotParam;
00113   std::string robotNamespace;
00114 
00115   bool fake_calibration_;
00116 
00117 #ifdef USE_CBQ
00118   private: ros::CallbackQueue controller_manager_queue_;
00119   private: void ControllerManagerQueueThread();
00120   private: boost::thread controller_manager_callback_queue_thread_;
00121 #endif
00122   private: void ControllerManagerROSThread();
00123   private: boost::thread ros_spinner_thread_;
00124 
00125   // Pointer to the model
00126   private: physics::WorldPtr world;
00127 
00128   // Pointer to the update event connection
00129   private: event::ConnectionPtr updateConnection;
00130 
00131   // subscribe to world stats
00132   private: transport::NodePtr node;
00133   private: transport::SubscriberPtr statsSub;
00134   private: common::Time simTime;
00135 
00136 };
00137 
00138 }
00139 
00140 #endif
00141 


pr2_gazebo_plugins
Author(s): John Hsu
autogenerated on Thu Jun 6 2019 17:49:09