25 #if GAZEBO_MAJOR_VERSION >= 8 26 namespace math = ignition::math;
28 namespace math = gazebo::math;
51 ROS_ERROR(
"Parent model is NULL! MimicJointPlugin could not be loaded.");
57 ROS_ERROR(
"A ROS node for Gazebo has not been initialized, unable to load plugin.");
62 if (_sdf->HasElement(
"robotNamespace")) {
68 if (!_sdf->HasElement(
"joint")) {
69 ROS_ERROR(
"No joint element present. MimicJointPlugin could not be loaded.");
73 joint_name_ = _sdf->GetElement(
"joint")->Get<std::string>();
76 if (!_sdf->HasElement(
"mimicJoint")) {
77 ROS_ERROR(
"No mimicJoint element present. MimicJointPlugin could not be loaded.");
84 has_pid_ = _sdf->HasElement(
"hasPID");
86 std::string name = _sdf->GetElement(
"hasPID")->Get<std::string>();
96 if (_sdf->HasElement(
"multiplier"))
97 multiplier_ = _sdf->GetElement(
"multiplier")->Get<
double>();
101 if (_sdf->HasElement(
"offset"))
102 offset_ = _sdf->GetElement(
"offset")->Get<
double>();
106 if (_sdf->HasElement(
"sensitiveness"))
107 sensitiveness_ = _sdf->GetElement(
"sensitiveness")->Get<
double>();
122 #if GAZEBO_MAJOR_VERSION > 2 127 if (_sdf->HasElement(
"maxEffort")) {
128 max_effort_ = _sdf->GetElement(
"maxEffort")->Get<
double>();
133 #if GAZEBO_MAJOR_VERSION > 2 147 <<
", Multiplier: " <<
multiplier_ <<
", Offset: " << offset_
148 <<
", MaxEffort: " <<
max_effort_ <<
", Sensitiveness: " << sensitiveness_);
153 #if GAZEBO_MAJOR_VERSION >= 8 160 #if GAZEBO_MAJOR_VERSION >= 8 172 double error = angle - a;
177 #if GAZEBO_MAJOR_VERSION >= 9 179 #elif GAZEBO_MAJOR_VERSION > 2 180 ROS_WARN_ONCE(
"The mimic_joint plugin is using the Joint::SetPosition method without preserving the link velocity.");
181 ROS_WARN_ONCE(
"As a result, gravity will not be simulated correctly for your model.");
182 ROS_WARN_ONCE(
"Please set gazebo_pid parameters or upgrade to Gazebo 9.");
183 ROS_WARN_ONCE(
"For details, see https://github.com/ros-simulation/gazebo_ros_pkgs/issues/612");
control_toolbox::Pid pid_
ROSCPP_DECL bool isInitialized()
std::string robot_namespace_
virtual void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf) override
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
event::ConnectionPtr update_connection_
#define ROS_WARN_ONCE(...)
GZ_REGISTER_MODEL_PLUGIN(DisableLinkPlugin)
std::string mimic_joint_name_
#define ROS_INFO_STREAM(args)
#define ROS_ERROR_STREAM(args)
physics::JointPtr mimic_joint_
virtual ~MimicJointPlugin() override