Go to the documentation of this file.
23 #ifndef __GAZEBO_ROS_API_PLUGIN_HH__
24 #define __GAZEBO_ROS_API_PLUGIN_HH__
34 #include <gazebo/physics/physics.hh>
35 #include <gazebo/common/common.hh>
36 #include <gazebo/transport/transport.hh>
43 #include <rosgraph_msgs/Clock.h>
46 #include "std_srvs/Empty.h"
48 #include "gazebo_msgs/JointRequest.h"
49 #include "gazebo_msgs/BodyRequest.h"
51 #include "gazebo_msgs/SpawnModel.h"
52 #include "gazebo_msgs/DeleteModel.h"
53 #include "gazebo_msgs/DeleteLight.h"
55 #include "gazebo_msgs/ApplyBodyWrench.h"
57 #include "gazebo_msgs/SetPhysicsProperties.h"
58 #include "gazebo_msgs/GetPhysicsProperties.h"
60 #include "gazebo_msgs/SetJointProperties.h"
62 #include "gazebo_msgs/GetWorldProperties.h"
64 #include "gazebo_msgs/GetModelProperties.h"
65 #include "gazebo_msgs/GetModelState.h"
66 #include "gazebo_msgs/SetModelState.h"
68 #include "gazebo_msgs/GetJointProperties.h"
69 #include "gazebo_msgs/ApplyJointEffort.h"
71 #include "gazebo_msgs/GetLinkProperties.h"
72 #include "gazebo_msgs/SetLinkProperties.h"
73 #include "gazebo_msgs/SetLinkState.h"
74 #include "gazebo_msgs/GetLinkState.h"
76 #include "gazebo_msgs/GetLightProperties.h"
77 #include "gazebo_msgs/SetLightProperties.h"
80 #include "gazebo_msgs/ModelState.h"
81 #include "gazebo_msgs/LinkState.h"
82 #include "gazebo_msgs/ModelStates.h"
83 #include "gazebo_msgs/LinkStates.h"
84 #include "gazebo_msgs/PerformanceMetrics.h"
86 #include "geometry_msgs/Vector3.h"
87 #include "geometry_msgs/Wrench.h"
88 #include "geometry_msgs/Pose.h"
89 #include "geometry_msgs/Twist.h"
93 #include <gazebo_msgs/SetModelConfiguration.h>
94 #include <boost/shared_ptr.hpp>
97 #include <dynamic_reconfigure/server.h>
98 #include <gazebo_ros/PhysicsConfig.h>
99 #include "gazebo_msgs/SetPhysicsProperties.h"
100 #include "gazebo_msgs/GetPhysicsProperties.h"
102 #include <boost/algorithm/string.hpp>
104 #ifndef GAZEBO_ROS_HAS_PERFORMANCE_METRICS
105 #if (GAZEBO_MAJOR_VERSION == 11 && GAZEBO_MINOR_VERSION > 1) || \
106 (GAZEBO_MAJOR_VERSION == 9 && GAZEBO_MINOR_VERSION > 14)
107 #define GAZEBO_ROS_HAS_PERFORMANCE_METRICS
109 #endif // ifndef GAZEBO_ROS_HAS_PERFORMANCE_METRICS
133 void Load(
int argc,
char** argv);
153 #ifdef GAZEBO_ROS_HAS_PERFORMANCE_METRICS
154 void onPerformanceMetricsConnect();
158 void onPerformanceMetricsDisconnect();
163 gazebo_msgs::SpawnModel::Response &res);
167 gazebo_msgs::SpawnModel::Response &res);
170 bool deleteModel(gazebo_msgs::DeleteModel::Request &req,gazebo_msgs::DeleteModel::Response &res);
173 bool deleteLight(gazebo_msgs::DeleteLight::Request &req,gazebo_msgs::DeleteLight::Response &res);
176 bool getModelState(gazebo_msgs::GetModelState::Request &req,gazebo_msgs::GetModelState::Response &res);
179 bool getModelProperties(gazebo_msgs::GetModelProperties::Request &req,gazebo_msgs::GetModelProperties::Response &res);
182 bool getWorldProperties(gazebo_msgs::GetWorldProperties::Request &req,gazebo_msgs::GetWorldProperties::Response &res);
185 bool getJointProperties(gazebo_msgs::GetJointProperties::Request &req,gazebo_msgs::GetJointProperties::Response &res);
188 bool getLinkProperties(gazebo_msgs::GetLinkProperties::Request &req,gazebo_msgs::GetLinkProperties::Response &res);
191 bool getLinkState(gazebo_msgs::GetLinkState::Request &req,gazebo_msgs::GetLinkState::Response &res);
194 bool getLightProperties(gazebo_msgs::GetLightProperties::Request &req,gazebo_msgs::GetLightProperties::Response &res);
197 bool setLightProperties(gazebo_msgs::SetLightProperties::Request &req,gazebo_msgs::SetLightProperties::Response &res);
200 bool setLinkProperties(gazebo_msgs::SetLinkProperties::Request &req,gazebo_msgs::SetLinkProperties::Response &res);
203 bool setPhysicsProperties(gazebo_msgs::SetPhysicsProperties::Request &req,gazebo_msgs::SetPhysicsProperties::Response &res);
206 bool getPhysicsProperties(gazebo_msgs::GetPhysicsProperties::Request &req,gazebo_msgs::GetPhysicsProperties::Response &res);
209 bool setJointProperties(gazebo_msgs::SetJointProperties::Request &req,gazebo_msgs::SetJointProperties::Response &res);
212 bool setModelState(gazebo_msgs::SetModelState::Request &req,gazebo_msgs::SetModelState::Response &res);
215 void updateModelState(
const gazebo_msgs::ModelState::ConstPtr& model_state);
218 bool applyJointEffort(gazebo_msgs::ApplyJointEffort::Request &req,gazebo_msgs::ApplyJointEffort::Response &res);
221 bool resetSimulation(std_srvs::Empty::Request &req,std_srvs::Empty::Response &res);
224 bool resetWorld(std_srvs::Empty::Request &req,std_srvs::Empty::Response &res);
227 bool pausePhysics(std_srvs::Empty::Request &req,std_srvs::Empty::Response &res);
230 bool unpausePhysics(std_srvs::Empty::Request &req,std_srvs::Empty::Response &res);
233 bool clearJointForces(gazebo_msgs::JointRequest::Request &req,gazebo_msgs::JointRequest::Response &res);
237 bool clearBodyWrenches(gazebo_msgs::BodyRequest::Request &req,gazebo_msgs::BodyRequest::Response &res);
241 bool setModelConfiguration(gazebo_msgs::SetModelConfiguration::Request &req,gazebo_msgs::SetModelConfiguration::Response &res);
244 bool setLinkState(gazebo_msgs::SetLinkState::Request &req,gazebo_msgs::SetLinkState::Response &res);
247 void updateLinkState(
const gazebo_msgs::LinkState::ConstPtr& link_state);
250 bool applyBodyWrench(gazebo_msgs::ApplyBodyWrench::Request &req,gazebo_msgs::ApplyBodyWrench::Response &res);
276 const std::string &model_name,
277 const ignition::math::Vector3d &initial_xyz,
278 const ignition::math::Quaterniond &initial_q);
282 const ignition::math::Vector3d &initial_xyz,
283 const ignition::math::Quaterniond &initial_q);
286 void updateURDFName(TiXmlDocument &gazebo_model_xml,
const std::string &model_name);
292 bool spawnAndConform(TiXmlDocument &gazebo_model_xml,
const std::string &model_name,
293 gazebo_msgs::SpawnModel::Response &res);
297 void transformWrench(ignition::math::Vector3d &target_force, ignition::math::Vector3d &target_torque,
298 const ignition::math::Vector3d &reference_force,
299 const ignition::math::Vector3d &reference_torque,
300 const ignition::math::Pose3d &target_to_reference );
311 #ifdef GAZEBO_ROS_HAS_PERFORMANCE_METRICS
315 bool isURDF(std::string model_xml);
319 bool isSDF(std::string model_xml);
325 ignition::math::Pose3d
parsePose(
const std::string &str);
328 ignition::math::Vector3d
parseVector3(
const std::string &str);
bool applyJointEffort(gazebo_msgs::ApplyJointEffort::Request &req, gazebo_msgs::ApplyJointEffort::Response &res)
const std::string response
ros::ServiceServer apply_body_wrench_service_
ignition::math::Vector3d force
ros::Subscriber set_link_state_topic_
bool setLinkProperties(gazebo_msgs::SetLinkProperties::Request &req, gazebo_msgs::SetLinkProperties::Response &res)
boost::mutex lock_
A mutex to lock access to fields that are used in ROS message callbacks.
gazebo::common::Time last_pub_clock_time_
bool getLinkProperties(gazebo_msgs::GetLinkProperties::Request &req, gazebo_msgs::GetLinkProperties::Response &res)
void updateLinkState(const gazebo_msgs::LinkState::ConstPtr &link_state)
ros::ServiceServer set_link_properties_service_
ros::ServiceServer clear_body_wrenches_service_
void gazeboQueueThread()
ros queue thread for this node
ros::Publisher pub_model_states_
ros::ServiceServer reset_world_service_
bool unpausePhysics(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
bool isSDF(std::string model_xml)
utility for checking if string is in SDF format
gazebo::transport::SubscriberPtr stat_sub_
bool setJointProperties(gazebo_msgs::SetJointProperties::Request &req, gazebo_msgs::SetJointProperties::Response &res)
bool resetSimulation(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
int pub_performance_metrics_connection_count_
ros::ServiceServer delete_light_service_
ros::Publisher pub_link_states_
std::string robot_namespace_
gazebo::physics::WorldPtr world_
void Load(int argc, char **argv)
Gazebo-inherited load function.
void onModelStatesDisconnect()
Callback for a subscriber disconnecting from ModelStates ros topic.
boost::shared_ptr< boost::thread > physics_reconfigure_thread_
gazebo::transport::PublisherPtr request_pub_
ros::ServiceServer set_model_state_service_
boost::shared_ptr< dynamic_reconfigure::Server< gazebo_ros::PhysicsConfig > > physics_reconfigure_srv_
void updateURDFName(TiXmlDocument &gazebo_model_xml, const std::string &model_name)
Update the model name of the URDF file before sending to Gazebo.
gazebo::transport::PublisherPtr light_modify_pub_
ros::ServiceServer get_light_properties_service_
std::vector< GazeboRosApiPlugin::WrenchBodyJob * > wrench_body_jobs_
ros::ServiceServer get_link_properties_service_
bool applyBodyWrench(gazebo_msgs::ApplyBodyWrench::Request &req, gazebo_msgs::ApplyBodyWrench::Response &res)
gazebo::event::ConnectionPtr pub_model_states_event_
bool getWorldProperties(gazebo_msgs::GetWorldProperties::Request &req, gazebo_msgs::GetWorldProperties::Response &res)
ros::ServiceServer reset_simulation_service_
bool physics_reconfigure_initialized_
gazebo::event::ConnectionPtr time_update_event_
bool getModelState(gazebo_msgs::GetModelState::Request &req, gazebo_msgs::GetModelState::Response &res)
bool clearBodyWrenches(gazebo_msgs::BodyRequest::Request &req, gazebo_msgs::BodyRequest::Response &res)
gazebo::transport::PublisherPtr factory_pub_
ros::ServiceServer get_joint_properties_service_
ros::ServiceServer spawn_urdf_model_service_
ros::ServiceServer get_world_properties_service_
bool setPhysicsProperties(gazebo_msgs::SetPhysicsProperties::Request &req, gazebo_msgs::SetPhysicsProperties::Response &res)
bool setModelConfiguration(gazebo_msgs::SetModelConfiguration::Request &req, gazebo_msgs::SetModelConfiguration::Response &res)
dynamic_reconfigure::Server< gazebo_ros::PhysicsConfig >::CallbackType physics_reconfigure_callback_
void onLinkStatesConnect()
Callback for a subscriber connecting to LinkStates ros topic.
bool deleteLight(gazebo_msgs::DeleteLight::Request &req, gazebo_msgs::DeleteLight::Response &res)
delete a given light by name
void advertiseServices()
advertise services
std::map< std::string, unsigned int > access_count_get_model_state_
index counters to count the accesses on models via GetModelState
ros::ServiceClient physics_reconfigure_set_client_
bool deleteModel(gazebo_msgs::DeleteModel::Request &req, gazebo_msgs::DeleteModel::Response &res)
delete model given name
ignition::math::Vector3d parseVector3(const std::string &str)
convert xml to Pose
ros::ServiceClient physics_reconfigure_get_client_
gazebo::event::ConnectionPtr sigint_event_
void updateSDFAttributes(TiXmlDocument &gazebo_model_xml, const std::string &model_name, const ignition::math::Vector3d &initial_xyz, const ignition::math::Quaterniond &initial_q)
Update the model name and pose of the SDF file before sending to Gazebo.
ros::Publisher pub_clock_
bool resetWorld(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
gazebo::transport::PublisherPtr factory_light_pub_
ros::ServiceServer set_model_configuration_service_
bool getLinkState(gazebo_msgs::GetLinkState::Request &req, gazebo_msgs::GetLinkState::Response &res)
bool spawnURDFModel(gazebo_msgs::SpawnModel::Request &req, gazebo_msgs::SpawnModel::Response &res)
Function for inserting a URDF into Gazebo from ROS Service Call.
ros::ServiceServer set_light_properties_service_
A plugin loaded within the gzserver on startup.
bool spawnSDFModel(gazebo_msgs::SpawnModel::Request &req, gazebo_msgs::SpawnModel::Response &res)
Both SDFs and converted URDFs get sent to this function for further manipulation from a ROS Service c...
void updateModelState(const gazebo_msgs::ModelState::ConstPtr &model_state)
void onModelStatesConnect()
Callback for a subscriber connecting to ModelStates ros topic.
ros::Subscriber set_model_state_topic_
bool getJointProperties(gazebo_msgs::GetJointProperties::Request &req, gazebo_msgs::GetJointProperties::Response &res)
ros::Publisher pub_performance_metrics_
bool enable_ros_network_
enable the communication of gazebo information using ROS service/topics
void loadGazeboRosApiPlugin(std::string world_name)
Connect to Gazebo via its plugin interface, get a pointer to the world, start events.
bool setLinkState(gazebo_msgs::SetLinkState::Request &req, gazebo_msgs::SetLinkState::Response &res)
int pub_model_states_connection_count_
void updateURDFModelPose(TiXmlDocument &gazebo_model_xml, const ignition::math::Vector3d &initial_xyz, const ignition::math::Quaterniond &initial_q)
Update the model pose of the URDF file before sending to Gazebo.
GazeboRosApiPlugin()
Constructor.
void physicsReconfigureCallback(gazebo_ros::PhysicsConfig &config, uint32_t level)
Used for the dynamic reconfigure callback function template.
int pub_link_states_connection_count_
boost::shared_ptr< boost::thread > gazebo_callback_queue_thread_
gazebo::event::ConnectionPtr force_update_event_
ignition::math::Pose3d parsePose(const std::string &str)
convert xml to Pose
void transformWrench(ignition::math::Vector3d &target_force, ignition::math::Vector3d &target_torque, const ignition::math::Vector3d &reference_force, const ignition::math::Vector3d &reference_torque, const ignition::math::Pose3d &target_to_reference)
helper function for applyBodyWrench shift wrench from reference frame to target frame
ros::ServiceServer apply_joint_effort_service_
gazebo::transport::SubscriberPtr performance_metric_sub_
ros::ServiceServer clear_joint_forces_service_
void walkChildAddRobotNamespace(TiXmlNode *model_xml)
bool setLightProperties(gazebo_msgs::SetLightProperties::Request &req, gazebo_msgs::SetLightProperties::Response &res)
gazebo::event::ConnectionPtr load_gazebo_ros_api_plugin_event_
ros::ServiceServer get_physics_properties_service_
bool pausePhysics(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
ros::ServiceServer set_link_state_service_
ros::ServiceServer delete_model_service_
boost::shared_ptr< ros::AsyncSpinner > async_ros_spin_
~GazeboRosApiPlugin()
Destructor.
void publishModelStates()
ros::ServiceServer unpause_physics_service_
void shutdownSignal()
\bried Detect if sig-int shutdown signal is recieved
gazebo::physics::LinkPtr body
ros::ServiceServer set_joint_properties_service_
gazebo::event::ConnectionPtr wrench_update_event_
ros::ServiceServer spawn_sdf_model_service_
ros::ServiceServer pause_physics_service_
void publishSimTime()
Callback to WorldUpdateBegin that publishes /clock. If pub_clock_frequency_ <= 0 (default behavior),...
bool getModelProperties(gazebo_msgs::GetModelProperties::Request &req, gazebo_msgs::GetModelProperties::Response &res)
void onResponse(ConstResponsePtr &response)
Unused.
boost::shared_ptr< ros::NodeHandle > nh_
ros::CallbackQueue gazebo_queue_
bool setModelState(gazebo_msgs::SetModelState::Request &req, gazebo_msgs::SetModelState::Response &res)
bool getLightProperties(gazebo_msgs::GetLightProperties::Request &req, gazebo_msgs::GetLightProperties::Response &res)
gazebo::event::ConnectionPtr pub_link_states_event_
ros::ServiceServer get_link_state_service_
void onLinkStatesDisconnect()
Callback for a subscriber disconnecting from LinkStates ros topic.
gazebo::transport::NodePtr gazebonode_
void stripXmlDeclaration(std::string &model_xml)
ros::ServiceServer get_model_state_service_
ignition::math::Vector3d torque
ros::ServiceServer set_physics_properties_service_
bool getPhysicsProperties(gazebo_msgs::GetPhysicsProperties::Request &req, gazebo_msgs::GetPhysicsProperties::Response &res)
void wrenchBodySchedulerSlot()
void forceJointSchedulerSlot()
bool isURDF(std::string model_xml)
utility for checking if string is in URDF format
void physicsReconfigureThread()
waits for the rest of Gazebo to be ready before initializing the dynamic reconfigure services
ros::ServiceServer get_model_properties_service_
std::vector< GazeboRosApiPlugin::ForceJointJob * > force_joint_jobs_
gazebo::physics::JointPtr joint
bool spawnAndConform(TiXmlDocument &gazebo_model_xml, const std::string &model_name, gazebo_msgs::SpawnModel::Response &res)
bool clearJointForces(gazebo_msgs::JointRequest::Request &req, gazebo_msgs::JointRequest::Response &res)
gazebo::transport::SubscriberPtr response_sub_
gazebo_ros
Author(s): John Hsu, Nate Koenig, Dave Coleman
autogenerated on Thu Sep 5 2024 02:49:51