gazebo_ros_control_plugin.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, Open Source Robotics Foundation
5  * Copyright (c) 2013, The Johns Hopkins University
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the Open Source Robotics Foundation
19  * nor the names of its contributors may be
20  * used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *********************************************************************/
36 
37 /* Author: Dave Coleman, Jonathan Bohren
38  Desc: Gazebo plugin for ros_control that allows 'hardware_interfaces' to be plugged in
39  using pluginlib
40 */
41 
42 // Boost
43 #include <boost/shared_ptr.hpp>
44 #include <boost/thread.hpp>
45 
46 // ROS
47 #include <ros/ros.h>
48 #include <pluginlib/class_loader.h>
49 #include <std_msgs/Bool.h>
50 
51 // Gazebo
52 #include <gazebo/gazebo.hh>
53 #include <gazebo/physics/physics.hh>
54 #include <gazebo/common/common.hh>
55 
56 // ros_control
60 
61 namespace gazebo_ros_control
62 {
63 
64 class GazeboRosControlPlugin : public gazebo::ModelPlugin
65 {
66 public:
67 
68  virtual ~GazeboRosControlPlugin();
69 
70  // Overloaded Gazebo entry point
71  virtual void Load(gazebo::physics::ModelPtr parent, sdf::ElementPtr sdf);
72 
73  // Called by the world update start event
74  void Update();
75 
76  // Called on world reset
77  virtual void Reset();
78 
79  // Get the URDF XML from the parameter server
80  std::string getURDF(std::string param_name) const;
81 
82  // Get Transmissions from the URDF
83  bool parseTransmissionsFromURDF(const std::string& urdf_string);
84 
85 protected:
86  void eStopCB(const std_msgs::BoolConstPtr& e_stop_active);
87 
88  // Node Handles
89  ros::NodeHandle model_nh_; // namespaces to robot name
90 
91  // Pointer to the model
92  gazebo::physics::ModelPtr parent_model_;
93  sdf::ElementPtr sdf_;
94 
95  // deferred load in case ros is blocking
96  boost::thread deferred_load_thread_;
97 
98  // Pointer to the update event connection
99  gazebo::event::ConnectionPtr update_connection_;
100 
101  // Interface loader
103  void load_robot_hw_sim_srv();
104 
105  // Strings
106  std::string robot_namespace_;
107  std::string robot_description_;
108 
109  // Transmissions in this plugin's scope
110  std::vector<transmission_interface::TransmissionInfo> transmissions_;
111 
112  // Robot simulator interface
115 
116  // Controller manager
118 
119  // Timing
123 
124  // e_stop_active_ is true if the emergency stop is active.
126  ros::Subscriber e_stop_sub_; // Emergency stop subscriber
127 
128 };
129 
130 
131 }
boost::shared_ptr< controller_manager::ControllerManager > controller_manager_
boost::shared_ptr< gazebo_ros_control::RobotHWSim > robot_hw_sim_
bool parseTransmissionsFromURDF(const std::string &urdf_string)
std::vector< transmission_interface::TransmissionInfo > transmissions_
void eStopCB(const std_msgs::BoolConstPtr &e_stop_active)
boost::shared_ptr< pluginlib::ClassLoader< gazebo_ros_control::RobotHWSim > > robot_hw_sim_loader_
Plugin template for hardware interfaces for ros_control and Gazebo.
virtual void Load(gazebo::physics::ModelPtr parent, sdf::ElementPtr sdf)
std::string getURDF(std::string param_name) const


gazebo_ros_control
Author(s): Jonathan Bohren, Dave Coleman
autogenerated on Tue Mar 26 2019 02:31:37