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


pr2_gazebo_plugins
Author(s): Sachin Chitta, Stu Glaser, John Hsu
autogenerated on Thu Apr 24 2014 15:47:43