25 #ifdef ENABLE_PROFILER
26 #include <ignition/common/Profiler.hh>
28 #include <ignition/math/Rand.hh>
64 if (_sdf->HasElement(
"robotNamespace"))
65 this->
robot_namespace_ = _sdf->GetElement(
"robotNamespace")->Get<std::string>() +
"/";
67 if (!_sdf->HasElement(
"jointName"))
69 ROS_FATAL_NAMED(
"ft_sensor",
"ft_sensor plugin missing <jointName>, cannot proceed");
73 this->
joint_name_ = _sdf->GetElement(
"jointName")->Get<std::string>();
88 if (!_sdf->HasElement(
"topicName"))
90 ROS_FATAL_NAMED(
"ft_sensor",
"ft_sensor plugin missing <topicName>, cannot proceed");
94 this->
topic_name_ = _sdf->GetElement(
"topicName")->Get<std::string>();
96 if (!_sdf->HasElement(
"gaussianNoise"))
98 ROS_INFO_NAMED(
"ft_sensor",
"ft_sensor plugin missing <gaussianNoise>, defaults to 0.0");
104 if (!_sdf->HasElement(
"updateRate"))
106 ROS_DEBUG_NAMED(
"ft_sensor",
"ft_sensor plugin missing <updateRate>, defaults to 0.0"
107 " (as fast as possible)");
111 this->
update_rate_ = _sdf->GetElement(
"updateRate")->Get<
double>();
116 ROS_FATAL_STREAM_NAMED(
"ft_sensor",
"A ROS node for Gazebo has not been initialized, unable to load plugin. "
117 <<
"Load the Gazebo system plugin 'libgazebo_ros_api_plugin.so' in the gazebo_ros package)");
163 #ifdef ENABLE_PROFILER
164 IGN_PROFILE(
"GazeboRosFT::UpdateChild");
165 IGN_PROFILE_BEGIN(
"fill ROS message");
167 #if GAZEBO_MAJOR_VERSION >= 8
168 common::Time cur_time = this->
world_->SimTime();
170 common::Time cur_time = this->
world_->GetSimTime();
181 physics::JointWrench wrench;
182 ignition::math::Vector3d torque;
183 ignition::math::Vector3d force;
190 wrench = this->
joint_->GetForceTorque(0);
191 #if GAZEBO_MAJOR_VERSION >= 8
192 force = wrench.body2Force;
193 torque = wrench.body2Torque;
195 force = wrench.body2Force.Ign();
196 torque = wrench.body2Torque.Ign();
203 #if GAZEBO_MAJOR_VERSION >= 8
217 #ifdef ENABLE_PROFILER
219 IGN_PROFILE_BEGIN(
"publish");
222 #ifdef ENABLE_PROFILER
225 this->
lock_.unlock();
239 double U = ignition::math::Rand::DblUniform();
242 double V = ignition::math::Rand::DblUniform();
244 double X = sqrt(-2.0 * ::log(U)) * cos(2.0*M_PI * V);
258 static const double timeout = 0.01;