gazebo_ros_control_plugin.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2013, Open Source Robotics Foundation
00005  *  Copyright (c) 2013, The Johns Hopkins University
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/or other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of the Open Source Robotics Foundation
00019  *     nor the names of its contributors may be
00020  *     used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *********************************************************************/
00036 
00037 /* Author: Dave Coleman, Jonathan Bohren
00038    Desc:   Gazebo plugin for ros_control that allows 'hardware_interfaces' to be plugged in
00039            using pluginlib
00040 */
00041 
00042 // Boost
00043 #include <boost/shared_ptr.hpp>
00044 #include <boost/thread.hpp>
00045 
00046 // ROS
00047 #include <ros/ros.h>
00048 #include <pluginlib/class_loader.h>
00049 
00050 // Gazebo
00051 #include <gazebo/gazebo.hh>
00052 #include <gazebo/physics/physics.hh>
00053 #include <gazebo/common/common.hh>
00054 
00055 // ros_control
00056 #include <gazebo_ros_control/robot_hw_sim.h>
00057 #include <controller_manager/controller_manager.h>
00058 #include <transmission_interface/transmission_parser.h>
00059 
00060 namespace gazebo_ros_control
00061 {
00062 
00063 class GazeboRosControlPlugin : public gazebo::ModelPlugin
00064 {
00065 public:
00066 
00067   virtual ~GazeboRosControlPlugin();
00068 
00069   // Overloaded Gazebo entry point
00070   virtual void Load(gazebo::physics::ModelPtr parent, sdf::ElementPtr sdf);
00071 
00072   // Called by the world update start event
00073   void Update();
00074 
00075   // Called on world reset
00076   virtual void Reset();
00077 
00078   // Get the URDF XML from the parameter server
00079   std::string getURDF(std::string param_name) const;
00080 
00081   // Get Transmissions from the URDF
00082   bool parseTransmissionsFromURDF(const std::string& urdf_string);
00083 
00084 protected:
00085 
00086   // Node Handles
00087   ros::NodeHandle model_nh_; // namespaces to robot name
00088 
00089   // Pointer to the model
00090   gazebo::physics::ModelPtr parent_model_;
00091   sdf::ElementPtr sdf_;
00092 
00093   // deferred load in case ros is blocking
00094   boost::thread deferred_load_thread_;
00095 
00096   // Pointer to the update event connection
00097   gazebo::event::ConnectionPtr update_connection_;
00098 
00099   // Interface loader
00100   boost::shared_ptr<pluginlib::ClassLoader<gazebo_ros_control::RobotHWSim> > robot_hw_sim_loader_;
00101   void load_robot_hw_sim_srv();
00102 
00103   // Strings
00104   std::string robot_namespace_;
00105   std::string robot_description_;
00106 
00107   // Transmissions in this plugin's scope
00108   std::vector<transmission_interface::TransmissionInfo> transmissions_;
00109 
00110   // Robot simulator interface
00111   std::string robot_hw_sim_type_str_;
00112   boost::shared_ptr<gazebo_ros_control::RobotHWSim> robot_hw_sim_;
00113 
00114   // Controller manager
00115   boost::shared_ptr<controller_manager::ControllerManager> controller_manager_;
00116 
00117   // Timing
00118   ros::Duration control_period_;
00119   ros::Time last_update_sim_time_ros_;
00120   ros::Time last_write_sim_time_ros_;
00121 
00122 };
00123 
00124 
00125 }


gazebo_ros_control
Author(s): Jonathan Bohren, Dave Coleman
autogenerated on Fri Aug 28 2015 10:47:54