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
113  std::string robot_hw_sim_type_str_;
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 }
robot_hw_sim.h
gazebo_ros_control::GazeboRosControlPlugin::controller_manager_
boost::shared_ptr< controller_manager::ControllerManager > controller_manager_
Definition: gazebo_ros_control_plugin.h:185
class_loader.h
boost::shared_ptr
gazebo_ros_control::GazeboRosControlPlugin::~GazeboRosControlPlugin
virtual ~GazeboRosControlPlugin()
Definition: gazebo_ros_control_plugin.cpp:87
ros.h
gazebo_ros_control::GazeboRosControlPlugin::e_stop_active_
bool e_stop_active_
Definition: gazebo_ros_control_plugin.h:193
gazebo_ros_control::GazeboRosControlPlugin::Load
virtual void Load(gazebo::physics::ModelPtr parent, sdf::ElementPtr sdf)
Definition: gazebo_ros_control_plugin.cpp:94
gazebo_ros_control::GazeboRosControlPlugin::model_nh_
ros::NodeHandle model_nh_
Definition: gazebo_ros_control_plugin.h:157
gazebo_ros_control::GazeboRosControlPlugin::last_e_stop_active_
bool last_e_stop_active_
Definition: gazebo_ros_control_plugin.h:193
gazebo_ros_control::GazeboRosControlPlugin::parseTransmissionsFromURDF
bool parseTransmissionsFromURDF(const std::string &urdf_string)
Definition: gazebo_ros_control_plugin.cpp:334
gazebo_ros_control::GazeboRosControlPlugin::control_period_
ros::Duration control_period_
Definition: gazebo_ros_control_plugin.h:188
transmission_parser.h
gazebo_ros_control::GazeboRosControlPlugin::last_write_sim_time_ros_
ros::Time last_write_sim_time_ros_
Definition: gazebo_ros_control_plugin.h:190
controller_manager.h
gazebo_ros_control
Plugin template for hardware interfaces for ros_control and Gazebo.
Definition: default_robot_hw_sim.h:71
gazebo_ros_control::GazeboRosControlPlugin::eStopCB
void eStopCB(const std_msgs::BoolConstPtr &e_stop_active)
Definition: gazebo_ros_control_plugin.cpp:341
gazebo_ros_control::GazeboRosControlPlugin::last_update_sim_time_ros_
ros::Time last_update_sim_time_ros_
Definition: gazebo_ros_control_plugin.h:189
gazebo_ros_control::GazeboRosControlPlugin::robot_hw_sim_type_str_
std::string robot_hw_sim_type_str_
Definition: gazebo_ros_control_plugin.h:181
gazebo_ros_control::GazeboRosControlPlugin::parent_model_
gazebo::physics::ModelPtr parent_model_
Definition: gazebo_ros_control_plugin.h:160
gazebo_ros_control::GazeboRosControlPlugin::load_robot_hw_sim_srv
void load_robot_hw_sim_srv()
gazebo_ros_control::GazeboRosControlPlugin::robot_description_
std::string robot_description_
Definition: gazebo_ros_control_plugin.h:175
gazebo_ros_control::GazeboRosControlPlugin::Reset
virtual void Reset()
Definition: gazebo_ros_control_plugin.cpp:295
gazebo_ros_control::GazeboRosControlPlugin::robot_namespace_
std::string robot_namespace_
Definition: gazebo_ros_control_plugin.h:174
gazebo_ros_control::GazeboRosControlPlugin::transmissions_
std::vector< transmission_interface::TransmissionInfo > transmissions_
Definition: gazebo_ros_control_plugin.h:178
gazebo_ros_control::GazeboRosControlPlugin::robot_hw_sim_
boost::shared_ptr< gazebo_ros_control::RobotHWSim > robot_hw_sim_
Definition: gazebo_ros_control_plugin.h:182
gazebo_ros_control::GazeboRosControlPlugin::sdf_
sdf::ElementPtr sdf_
Definition: gazebo_ros_control_plugin.h:161
ros::Time
gazebo_ros_control::GazeboRosControlPlugin::robot_hw_sim_loader_
boost::shared_ptr< pluginlib::ClassLoader< gazebo_ros_control::RobotHWSim > > robot_hw_sim_loader_
Definition: gazebo_ros_control_plugin.h:170
gazebo_ros_control::GazeboRosControlPlugin::deferred_load_thread_
boost::thread deferred_load_thread_
Definition: gazebo_ros_control_plugin.h:164
gazebo_ros_control::GazeboRosControlPlugin::e_stop_sub_
ros::Subscriber e_stop_sub_
Definition: gazebo_ros_control_plugin.h:194
gazebo_ros_control::GazeboRosControlPlugin::Update
void Update()
Definition: gazebo_ros_control_plugin.cpp:245
gazebo_ros_control::GazeboRosControlPlugin::getURDF
std::string getURDF(std::string param_name) const
Definition: gazebo_ros_control_plugin.cpp:303
ros::Duration
gazebo_ros_control::GazeboRosControlPlugin::update_connection_
gazebo::event::ConnectionPtr update_connection_
Definition: gazebo_ros_control_plugin.h:167
ros::NodeHandle
ros::Subscriber


gazebo_ros_control
Author(s): Jonathan Bohren, Dave Coleman
autogenerated on Sun Mar 2 2025 03:49:21