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 <gazebo/physics/World.hh>
00037 #include <gazebo/physics/Model.hh>
00038 #include <gazebo/physics/physics.hh>
00039 #include <gazebo/common/Time.hh>
00040 #include <gazebo/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 #include <sr_self_test/sr_self_test.hpp>
00056 
00057 namespace gazebo
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   boost::shared_ptr<shadow_robot::SrSelfTest> self_test_;
00071 private:
00072 
00073   gazebo::physics::ModelPtr parent_model_;
00074   pr2_hardware_interface::HardwareInterface hw_;
00075   pr2_controller_manager::ControllerManager *cm_;
00076 
00080   pr2_mechanism_model::RobotState *fake_state_;
00081   std::vector<gazebo::physics::JointPtr>  joints_;
00082 
00084   //private: ParamT<std::string> *setModelsJointsStatesServiceNameP;
00085   //private: std::string setModelsJointsStatesServiceName;
00086 
00087   /*
00088    * \brief read pr2.xml for actuators, and pass tinyxml node to mechanism control node's initXml.
00089    */
00090   void ReadPr2Xml();
00091 
00092   /*
00093    *  \brief pointer to ros node
00094    */
00095   ros::NodeHandle* rosnode_;
00096 
00098   private: ros::ServiceServer setModelsJointsStatesService;
00099 
00101   //private: bool setModelsJointsStates(pr2_gazebo_plugins::SetModelsJointsStates::Request &req,
00102   //                                    pr2_gazebo_plugins::SetModelsJointsStates::Response &res);
00103 
00105   /*
00106    *  \brief tmp vars for performance checking
00107    */
00108   double wall_start_, sim_start_;
00109 
00111   //ParamT<std::string> *robotParamP;
00112   //ParamT<std::string> *robotNamespaceP;
00113   std::string robotParam;
00114   std::string robotNamespace;
00115 
00116   bool fake_calibration_;
00117 
00118 #ifdef USE_CBQ
00119   private: ros::CallbackQueue controller_manager_queue_;
00120   private: void ControllerManagerQueueThread();
00121   private: boost::thread controller_manager_callback_queue_thread_;
00122 #endif
00123   private: void ControllerManagerROSThread();
00124   private: boost::thread ros_spinner_thread_;
00125 
00126   // Pointer to the model
00127   private: physics::WorldPtr world;
00128 
00129   // Pointer to the update event connection
00130   private: event::ConnectionPtr updateConnection;
00131 
00132   // subscribe to world stats
00133   private: transport::NodePtr node;
00134   private: transport::SubscriberPtr statsSub;
00135   private: common::Time simTime;
00136 };
00137 
00139 
00140 
00141 }
00142 
00143 #endif
00144 


sr_gazebo_plugins
Author(s): adapted by Ugo(software@shadowrobot.com), Sachin Chitta, Stu Glaser, John Hsu
autogenerated on Fri Aug 28 2015 13:10:13