UnderwaterObjectROSPlugin.cc
Go to the documentation of this file.
1 // Copyright (c) 2016 The UUV Simulator Authors.
2 // All rights reserved.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
17 
18 #include <gazebo/physics/Base.hh>
19 #include <gazebo/physics/Model.hh>
20 #include <gazebo/physics/World.hh>
21 #include <gazebo/physics/Link.hh>
22 
23 namespace uuv_simulator_ros
24 {
27 {
28 }
29 
32 {
33  this->rosNode->shutdown();
34 }
35 
37 void UnderwaterObjectROSPlugin::Load(gazebo::physics::ModelPtr _parent,
38  sdf::ElementPtr _sdf)
39 {
40  if (!ros::isInitialized())
41  {
42  gzerr << "Not loading plugin since ROS has not been "
43  << "properly initialized. Try starting gazebo with ros plugin:\n"
44  << " gazebo -s libgazebo_ros_api_plugin.so\n";
45  return;
46  }
47 
48  this->rosNode.reset(new ros::NodeHandle(""));
49 
50  try
51  {
52  UnderwaterObjectPlugin::Load(_parent, _sdf);
53  }
54  catch(gazebo::common::Exception &_e)
55  {
56  gzerr << "Error loading plugin."
57  << "Please ensure that your model is correct."
58  << '\n';
59  return;
60  }
61 
62  this->subLocalCurVel = this->rosNode->subscribe<geometry_msgs::Vector3>(
63  _parent->GetName() + "/current_velocity", 10,
65  this, _1));
66 
67  this->services["set_use_global_current_velocity"] =
68  this->rosNode->advertiseService(
69  _parent->GetName() + "/set_use_global_current_velocity",
71 
72  this->services["set_added_mass_scaling"] =
73  this->rosNode->advertiseService(
74  _parent->GetName() + "/set_added_mass_scaling",
76 
77  this->services["get_added_mass_scaling"] =
78  this->rosNode->advertiseService(
79  _parent->GetName() + "/get_added_mass_scaling",
81 
82  this->services["set_damping_scaling"] =
83  this->rosNode->advertiseService(
84  _parent->GetName() + "/set_damping_scaling",
86 
87  this->services["get_damping_scaling"] =
88  this->rosNode->advertiseService(
89  _parent->GetName() + "/get_damping_scaling",
91 
92  this->services["set_volume_scaling"] =
93  this->rosNode->advertiseService(
94  _parent->GetName() + "/set_volume_scaling",
96 
97  this->services["get_volume_scaling"] =
98  this->rosNode->advertiseService(
99  _parent->GetName() + "/get_volume_scaling",
101 
102  this->services["set_fluid_density"] =
103  this->rosNode->advertiseService(
104  _parent->GetName() + "/set_fluid_density",
106 
107  this->services["get_fluid_density"] =
108  this->rosNode->advertiseService(
109  _parent->GetName() + "/get_fluid_density",
111 
112  this->services["set_volume_offset"] =
113  this->rosNode->advertiseService(
114  _parent->GetName() + "/set_volume_offset",
116 
117  this->services["get_volume_offset"] =
118  this->rosNode->advertiseService(
119  _parent->GetName() + "/get_volume_offset",
121 
122  this->services["set_added_mass_offset"] =
123  this->rosNode->advertiseService(
124  _parent->GetName() + "/set_added_mass_offset",
126 
127  this->services["get_added_mass_offset"] =
128  this->rosNode->advertiseService(
129  _parent->GetName() + "/get_added_mass_offset",
131 
132  this->services["set_linear_damping_offset"] =
133  this->rosNode->advertiseService(
134  _parent->GetName() + "/set_linear_damping_offset",
136 
137  this->services["get_linear_damping_offset"] =
138  this->rosNode->advertiseService(
139  _parent->GetName() + "/get_linear_damping_offset",
141 
142  this->services["set_linear_forward_speed_damping_offset"] =
143  this->rosNode->advertiseService(
144  _parent->GetName() + "/set_linear_forward_speed_damping_offset",
146 
147  this->services["get_linear_forward_speed_damping_offset"] =
148  this->rosNode->advertiseService(
149  _parent->GetName() + "/get_linear_forward_speed_damping_offset",
151 
152  this->services["set_nonlinear_damping_offset"] =
153  this->rosNode->advertiseService(
154  _parent->GetName() + "/set_nonlinear_damping_offset",
156 
157  this->services["get_nonlinear_damping_offset"] =
158  this->rosNode->advertiseService(
159  _parent->GetName() + "/get_nonlinear_damping_offset",
161 
162  this->services["get_model_properties"] =
163  this->rosNode->advertiseService(
164  _parent->GetName() + "/get_model_properties",
166 
167  this->rosHydroPub["current_velocity_marker"] =
168  this->rosNode->advertise<visualization_msgs::Marker>
169  (_parent->GetName() + "/current_velocity_marker", 0);
170 
171  this->rosHydroPub["using_global_current_velocity"] =
172  this->rosNode->advertise<std_msgs::Bool>
173  (_parent->GetName() + "/using_global_current_velocity", 0);
174 
175  this->rosHydroPub["is_submerged"] =
176  this->rosNode->advertise<std_msgs::Bool>
177  (_parent->GetName() + "/is_submerged", 0);
178 
179  this->nedTransform.header.frame_id = this->model->GetName() + "/base_link";
180  this->nedTransform.child_frame_id = this->model->GetName() + "/base_link_ned";
181  this->nedTransform.transform.translation.x = 0;
182  this->nedTransform.transform.translation.y = 0;
183  this->nedTransform.transform.translation.z = 0;
184  tf2::Quaternion quat;
185  quat.setRPY(M_PI, 0, 0);
186  this->nedTransform.transform.rotation.x = quat.x();
187  this->nedTransform.transform.rotation.y = quat.y();
188  this->nedTransform.transform.rotation.z = quat.z();
189  this->nedTransform.transform.rotation.w = quat.w();
190 }
191 
194 {
195  UnderwaterObjectPlugin::Init();
196 }
197 
200 { }
201 
203 void UnderwaterObjectROSPlugin::Update(const gazebo::common::UpdateInfo &_info)
204 {
205  UnderwaterObjectPlugin::Update(_info);
206 
207  this->nedTransform.header.stamp = ros::Time::now();
209 }
210 
212 void UnderwaterObjectROSPlugin::InitDebug(gazebo::physics::LinkPtr _link,
214 {
215  UnderwaterObjectPlugin::InitDebug(_link, _hydro);
216 
217  // Publish the stamped wrench topics if the debug flag is on
218  for (std::map<std::string,
219  gazebo::transport::PublisherPtr>::iterator it = this->hydroPub.begin();
220  it != this->hydroPub.end(); ++it)
221  {
222  this->rosHydroPub[it->first] =
223  this->rosNode->advertise<geometry_msgs::WrenchStamped>(
224  it->second->GetTopic(), 10);
225  gzmsg << "ROS TOPIC: " << it->second->GetTopic() << std::endl;
226  }
227 }
228 
231  gazebo::physics::LinkPtr _link)
232 {
233  // Call base class method
234  UnderwaterObjectPlugin::PublishRestoringForce(_link);
235 
236  // Publish data in a ROS topic
237  if (this->models.count(_link))
238  {
239  if (!this->models[_link]->GetDebugFlag())
240  return;
241 
242  ignition::math::Vector3d restoring = this->models[_link]->GetStoredVector(
244 
245  geometry_msgs::WrenchStamped msg;
246  this->GenWrenchMsg(restoring,
247  ignition::math::Vector3d(0, 0, 0), msg);
248  this->rosHydroPub[_link->GetName() + "/restoring"].publish(msg);
249  }
250 }
251 
254 {
255  if (this->baseLinkName.empty())
256  gzwarn << "Base link name string is empty" << std::endl;
257  std_msgs::Bool isSubmerged;
258  isSubmerged.data = this->models[this->model->GetLink(this->baseLinkName)]->IsSubmerged();
259  this->rosHydroPub["is_submerged"].publish(isSubmerged);
260 }
261 
264 {
265  visualization_msgs::Marker marker;
266  marker.header.frame_id = "world";
267  marker.header.stamp = ros::Time();
268  marker.ns = this->model->GetName() + "/current_velocity_marker";
269  marker.id = 0;
270  marker.type = visualization_msgs::Marker::ARROW;
271  // Creating the arrow marker for the current velocity information
272  // (orientation only, magnitude has to be read from the topic)
273  if (this->flowVelocity.Length() > 0)
274  {
275  marker.action = visualization_msgs::Marker::ADD;
276  ignition::math::Pose3d pose;
277 #if GAZEBO_MAJOR_VERSION >= 8
278  pose = this->model->WorldPose();
279 #else
280  pose = this->model->GetWorldPose().Ign();
281 #endif
282  double yaw = std::atan2(this->flowVelocity.Y(), this->flowVelocity.X());
283  double pitch = std::atan2(
284  this->flowVelocity.Z(),
285  std::sqrt(std::pow(this->flowVelocity.X(), 2) +
286  std::pow(this->flowVelocity.Y(), 2)));
287 
288  ignition::math::Quaterniond qt(0.0, -pitch, yaw);
289  marker.pose.position.x = pose.Pos().X();
290  marker.pose.position.y = pose.Pos().Y();
291  marker.pose.position.z = pose.Pos().Z() + 1.5;
292  marker.pose.orientation.x = qt.X();
293  marker.pose.orientation.y = qt.Y();
294  marker.pose.orientation.z = qt.Z();
295  marker.pose.orientation.w = qt.W();
296  marker.scale.x = 1;
297  marker.scale.y = 0.1;
298  marker.scale.z = 0.1;
299  marker.color.a = 1.0;
300  marker.color.r = 0.0;
301  marker.color.g = 0.0;
302  marker.color.b = 1.0;
303  }
304  else
305  {
306  marker.action = visualization_msgs::Marker::DELETE;
307  }
308  // Publish current velocity RViz marker
309  this->rosHydroPub["current_velocity_marker"].publish(marker);
310  // Publishing flag for usage of global current velocity
311  std_msgs::Bool useGlobalMsg;
312  useGlobalMsg.data = this->useGlobalCurrent;
313  this->rosHydroPub["using_global_current_velocity"].publish(useGlobalMsg);
314 }
315 
318  gazebo::physics::LinkPtr _link)
319 {
320  // Call base class method
321  UnderwaterObjectPlugin::PublishRestoringForce(_link);
322 
323  // Publish data in a ROS topic
324  if (this->models.count(_link))
325  {
326  if (!this->models[_link]->GetDebugFlag())
327  return;
328  geometry_msgs::WrenchStamped msg;
329  ignition::math::Vector3d force, torque;
330 
331  // Publish wrench generated by the acceleration of fluid around the object
332  force = this->models[_link]->GetStoredVector(UUV_ADDED_MASS_FORCE);
333  torque = this->models[_link]->GetStoredVector(UUV_ADDED_MASS_TORQUE);
334 
335  this->GenWrenchMsg(force, torque, msg);
336  this->rosHydroPub[_link->GetName() + "/added_mass"].publish(msg);
337 
338  // Publish wrench generated by the fluid damping
339  force = this->models[_link]->GetStoredVector(UUV_DAMPING_FORCE);
340  torque = this->models[_link]->GetStoredVector(UUV_DAMPING_TORQUE);
341 
342  this->GenWrenchMsg(force, torque, msg);
343  this->rosHydroPub[_link->GetName() + "/damping"].publish(msg);
344 
345  // Publish wrench generated by the Coriolis forces
346  force = this->models[_link]->GetStoredVector(UUV_ADDED_CORIOLIS_FORCE);
347  torque = this->models[_link]->GetStoredVector(UUV_ADDED_CORIOLIS_TORQUE);
348 
349  this->GenWrenchMsg(force, torque, msg);
350  this->rosHydroPub[_link->GetName() + "/added_coriolis"].publish(msg);
351  }
352 }
353 
356  ignition::math::Vector3d _force, ignition::math::Vector3d _torque,
357  geometry_msgs::WrenchStamped &_output)
358 {
359  _output.wrench.force.x = _force.X();
360  _output.wrench.force.y = _force.Y();
361  _output.wrench.force.z = _force.Z();
362 
363  _output.wrench.torque.x = _torque.X();
364  _output.wrench.torque.y = _torque.Y();
365  _output.wrench.torque.z = _torque.Z();
366 #if GAZEBO_MAJOR_VERSION >= 8
367  _output.header.stamp = ros::Time(this->world->SimTime().Double());
368 #else
369  _output.header.stamp = ros::Time(this->world->GetSimTime().Double());
370 #endif
371 }
372 
375  const geometry_msgs::Vector3::ConstPtr &_msg)
376 {
377  if (!this->useGlobalCurrent)
378  {
379  this->flowVelocity.X() = _msg->x;
380  this->flowVelocity.Y() = _msg->y;
381  this->flowVelocity.Z() = _msg->z;
382  }
383 }
384 
387  uuv_gazebo_ros_plugins_msgs::SetUseGlobalCurrentVel::Request& _req,
388  uuv_gazebo_ros_plugins_msgs::SetUseGlobalCurrentVel::Response& _res)
389 {
390  if (_req.use_global == this->useGlobalCurrent)
391  _res.success = true;
392  else
393  {
394  this->useGlobalCurrent = _req.use_global;
395  this->flowVelocity.X() = 0;
396  this->flowVelocity.Y() = 0;
397  this->flowVelocity.Z() = 0;
398  if (this->useGlobalCurrent)
399  gzmsg << this->model->GetName() <<
400  "::Now using global current velocity" << std::endl;
401  else
402  gzmsg << this->model->GetName() <<
403  "::Using the current velocity under the namespace " <<
404  this->model->GetName() << std::endl;
405  _res.success = true;
406  }
407  return true;
408 }
409 
412  uuv_gazebo_ros_plugins_msgs::GetModelProperties::Request& _req,
413  uuv_gazebo_ros_plugins_msgs::GetModelProperties::Response& _res)
414 {
415  for (std::map<gazebo::physics::LinkPtr,
416  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
417  it != models.end(); ++it)
418  {
419  gazebo::physics::LinkPtr link = it->first;
420  gazebo::HydrodynamicModelPtr hydro = it->second;
421 
422  _res.link_names.push_back(link->GetName());
423 
424  uuv_gazebo_ros_plugins_msgs::UnderwaterObjectModel model;
425  double param;
426  std::vector<double> mat;
427 
428  hydro->GetParam("volume", param);
429  model.volume = param;
430 
431  hydro->GetParam("fluid_density", param);
432  model.fluid_density = param;
433 
434  hydro->GetParam("bbox_height", param);
435  model.bbox_height = param;
436 
437  hydro->GetParam("bbox_length", param);
438  model.bbox_length = param;
439 
440  hydro->GetParam("bbox_width", param);
441  model.bbox_width = param;
442 
443  hydro->GetParam("added_mass", mat);
444  model.added_mass = mat;
445 
446  hydro->GetParam("linear_damping", mat);
447  model.linear_damping = mat;
448 
449  hydro->GetParam("linear_damping_forward_speed", mat);
450  model.linear_damping_forward_speed = mat;
451 
452  hydro->GetParam("quadratic_damping", mat);
453  model.quadratic_damping = mat;
454 
455  model.neutrally_buoyant = hydro->IsNeutrallyBuoyant();
456 
457  hydro->GetParam("center_of_buoyancy", mat);
458  model.cob.x = mat[0];
459  model.cob.y = mat[1];
460  model.cob.z = mat[2];
461 #if GAZEBO_MAJOR_VERSION >= 8
462  model.inertia.m = link->GetInertial()->Mass();
463  model.inertia.ixx = link->GetInertial()->IXX();
464  model.inertia.ixy = link->GetInertial()->IXY();
465  model.inertia.ixz = link->GetInertial()->IXZ();
466  model.inertia.iyy = link->GetInertial()->IYY();
467  model.inertia.iyz = link->GetInertial()->IYZ();
468  model.inertia.izz = link->GetInertial()->IZZ();
469 
470  model.inertia.com.x = link->GetInertial()->CoG().X();
471  model.inertia.com.y = link->GetInertial()->CoG().Y();
472  model.inertia.com.z = link->GetInertial()->CoG().Z();
473 #else
474  model.inertia.m = link->GetInertial()->GetMass();
475  model.inertia.ixx = link->GetInertial()->GetIXX();
476  model.inertia.ixy = link->GetInertial()->GetIXY();
477  model.inertia.ixz = link->GetInertial()->GetIXZ();
478  model.inertia.iyy = link->GetInertial()->GetIYY();
479  model.inertia.iyz = link->GetInertial()->GetIYZ();
480  model.inertia.izz = link->GetInertial()->GetIZZ();
481 
482  model.inertia.com.x = link->GetInertial()->GetCoG().x;
483  model.inertia.com.y = link->GetInertial()->GetCoG().y;
484  model.inertia.com.z = link->GetInertial()->GetCoG().z;
485 #endif
486  _res.models.push_back(model);
487  }
488  return true;
489 }
490 
493  uuv_gazebo_ros_plugins_msgs::SetFloat::Request& _req,
494  uuv_gazebo_ros_plugins_msgs::SetFloat::Response& _res)
495 
496 {
497  if (_req.data < 0)
498  {
499  _res.success = false;
500  _res.message = "Scaling factor cannot be negative";
501  }
502  else
503  {
504  for (std::map<gazebo::physics::LinkPtr,
505  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
506  it != models.end(); ++it)
507  {
508  gazebo::HydrodynamicModelPtr hydro = it->second;
509  hydro->SetParam("scaling_added_mass", _req.data);
510  }
511  _res.success = true;
512  _res.message = "All links set with new added-mass scaling factor";
513  }
514  return true;
515 }
516 
519  uuv_gazebo_ros_plugins_msgs::GetFloat::Request& _req,
520  uuv_gazebo_ros_plugins_msgs::GetFloat::Response& _res)
521 
522 {
523  models.begin()->second->GetParam("scaling_added_mass", _res.data);
524  return true;
525 }
526 
529  uuv_gazebo_ros_plugins_msgs::SetFloat::Request& _req,
530  uuv_gazebo_ros_plugins_msgs::SetFloat::Response& _res)
531 
532 {
533  if (_req.data < 0)
534  {
535  _res.success = false;
536  _res.message = "Scaling factor cannot be negative";
537  }
538  else
539  {
540  for (std::map<gazebo::physics::LinkPtr,
541  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
542  it != models.end(); ++it)
543  {
544  gazebo::HydrodynamicModelPtr hydro = it->second;
545  hydro->SetParam("scaling_damping", _req.data);
546  }
547  _res.success = true;
548  _res.message = "All links set with new damping scaling factor";
549  }
550  return true;
551 }
552 
555  uuv_gazebo_ros_plugins_msgs::GetFloat::Request& _req,
556  uuv_gazebo_ros_plugins_msgs::GetFloat::Response& _res)
557 
558 {
559  models.begin()->second->GetParam("scaling_damping", _res.data);
560  return true;
561 }
562 
565  uuv_gazebo_ros_plugins_msgs::SetFloat::Request& _req,
566  uuv_gazebo_ros_plugins_msgs::SetFloat::Response& _res)
567 
568 {
569  if (_req.data < 0)
570  {
571  _res.success = false;
572  _res.message = "Scaling factor cannot be negative";
573  }
574  else
575  {
576  for (std::map<gazebo::physics::LinkPtr,
577  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
578  it != models.end(); ++it)
579  {
580  gazebo::HydrodynamicModelPtr hydro = it->second;
581  hydro->SetParam("scaling_volume", _req.data);
582  }
583  _res.success = true;
584  _res.message = "All links set with new volume scaling factor";
585  }
586  return true;
587 }
588 
591  uuv_gazebo_ros_plugins_msgs::GetFloat::Request& _req,
592  uuv_gazebo_ros_plugins_msgs::GetFloat::Response& _res)
593 
594 {
595  models.begin()->second->GetParam("scaling_volume", _res.data);
596  return true;
597 }
598 
601  uuv_gazebo_ros_plugins_msgs::SetFloat::Request& _req,
602  uuv_gazebo_ros_plugins_msgs::SetFloat::Response& _res)
603 
604 {
605  if (_req.data < 0)
606  {
607  _res.success = false;
608  _res.message = "Scaling factor cannot be negative";
609  }
610  else
611  {
612  for (std::map<gazebo::physics::LinkPtr,
613  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
614  it != models.end(); ++it)
615  {
616  gazebo::HydrodynamicModelPtr hydro = it->second;
617  hydro->SetParam("fluid_density", _req.data);
618  }
619  _res.success = true;
620  _res.message = "All links set with new fluid density";
621  }
622  return true;
623 }
624 
627  uuv_gazebo_ros_plugins_msgs::GetFloat::Request& _req,
628  uuv_gazebo_ros_plugins_msgs::GetFloat::Response& _res)
629 
630 {
631  models.begin()->second->GetParam("fluid_density", _res.data);
632  return true;
633 }
634 
637  uuv_gazebo_ros_plugins_msgs::SetFloat::Request& _req,
638  uuv_gazebo_ros_plugins_msgs::SetFloat::Response& _res)
639 
640 {
641  for (std::map<gazebo::physics::LinkPtr,
642  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
643  it != models.end(); ++it)
644  {
645  gazebo::HydrodynamicModelPtr hydro = it->second;
646  hydro->SetParam("offset_volume", _req.data);
647  }
648  _res.success = true;
649  _res.message = "All links set with new volume offset";
650 
651  return true;
652 }
653 
656  uuv_gazebo_ros_plugins_msgs::GetFloat::Request& _req,
657  uuv_gazebo_ros_plugins_msgs::GetFloat::Response& _res)
658 
659 {
660  models.begin()->second->GetParam("offset_volume", _res.data);
661  return true;
662 }
663 
666  uuv_gazebo_ros_plugins_msgs::SetFloat::Request& _req,
667  uuv_gazebo_ros_plugins_msgs::SetFloat::Response& _res)
668 
669 {
670  for (std::map<gazebo::physics::LinkPtr,
671  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
672  it != models.end(); ++it)
673  {
674  gazebo::HydrodynamicModelPtr hydro = it->second;
675  hydro->SetParam("offset_added_mass", _req.data);
676  }
677  _res.success = true;
678  _res.message = "All links set with new added-mass identity offset";
679 
680  return true;
681 }
682 
685  uuv_gazebo_ros_plugins_msgs::GetFloat::Request& _req,
686  uuv_gazebo_ros_plugins_msgs::GetFloat::Response& _res)
687 
688 {
689  models.begin()->second->GetParam("offset_added_mass", _res.data);
690  return true;
691 }
692 
695  uuv_gazebo_ros_plugins_msgs::SetFloat::Request& _req,
696  uuv_gazebo_ros_plugins_msgs::SetFloat::Response& _res)
697 
698 {
699  for (std::map<gazebo::physics::LinkPtr,
700  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
701  it != models.end(); ++it)
702  {
703  gazebo::HydrodynamicModelPtr hydro = it->second;
704  hydro->SetParam("offset_linear_damping", _req.data);
705  }
706  _res.success = true;
707  _res.message = "All links set with new linear damping identity offset";
708 
709  return true;
710 }
711 
714  uuv_gazebo_ros_plugins_msgs::GetFloat::Request& _req,
715  uuv_gazebo_ros_plugins_msgs::GetFloat::Response& _res)
716 
717 {
718  models.begin()->second->GetParam("offset_linear_damping", _res.data);
719  return true;
720 }
721 
724  uuv_gazebo_ros_plugins_msgs::SetFloat::Request& _req,
725  uuv_gazebo_ros_plugins_msgs::SetFloat::Response& _res)
726 
727 {
728  for (std::map<gazebo::physics::LinkPtr,
729  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
730  it != models.end(); ++it)
731  {
732  gazebo::HydrodynamicModelPtr hydro = it->second;
733  hydro->SetParam("offset_lin_forward_speed_damping", _req.data);
734  }
735  _res.success = true;
736  _res.message = "All links set with new linear forward speed damping identity offset";
737 
738  return true;
739 }
740 
743  uuv_gazebo_ros_plugins_msgs::GetFloat::Request& _req,
744  uuv_gazebo_ros_plugins_msgs::GetFloat::Response& _res)
745 
746 {
747  models.begin()->second->GetParam("offset_lin_forward_speed_damping", _res.data);
748  return true;
749 }
750 
753  uuv_gazebo_ros_plugins_msgs::SetFloat::Request& _req,
754  uuv_gazebo_ros_plugins_msgs::SetFloat::Response& _res)
755 
756 {
757  for (std::map<gazebo::physics::LinkPtr,
758  gazebo::HydrodynamicModelPtr>::iterator it = models.begin();
759  it != models.end(); ++it)
760  {
761  gazebo::HydrodynamicModelPtr hydro = it->second;
762  hydro->SetParam("offset_nonlin_damping", _req.data);
763  }
764  _res.success = true;
765  _res.message = "All links set with new nonlinear damping identity offset";
766 
767  return true;
768 }
769 
772  uuv_gazebo_ros_plugins_msgs::GetFloat::Request& _req,
773  uuv_gazebo_ros_plugins_msgs::GetFloat::Response& _res)
774 
775 {
776  models.begin()->second->GetParam("offset_nonlin_damping", _res.data);
777  return true;
778 }
779 
781 }
std::map< gazebo::physics::LinkPtr, HydrodynamicModelPtr > models
void setRPY(const tf2Scalar &roll, const tf2Scalar &pitch, const tf2Scalar &yaw)
bool param(const std::string &param_name, T &param_val, const T &default_val)
std::map< std::string, gazebo::transport::PublisherPtr > hydroPub
bool GetOffsetLinearForwardSpeedDamping(uuv_gazebo_ros_plugins_msgs::GetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::GetFloat::Response &_res)
Return the offset factor for the linear forward speed damping matrix.
bool SetOffsetLinearDamping(uuv_gazebo_ros_plugins_msgs::SetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::SetFloat::Response &_res)
Set the offset factor for the linear damping matrix.
bool GetFluidDensity(uuv_gazebo_ros_plugins_msgs::GetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::GetFloat::Response &_res)
Get current value for the fluid density.
virtual void InitDebug(gazebo::physics::LinkPtr _link, gazebo::HydrodynamicModelPtr _hydro)
Sets the topics used for publishing the intermediate data during the simulation.
#define UUV_ADDED_CORIOLIS_FORCE
boost::scoped_ptr< ros::NodeHandle > rosNode
Pointer to this ROS node&#39;s handle.
bool SetUseGlobalCurrentVel(uuv_gazebo_ros_plugins_msgs::SetUseGlobalCurrentVel::Request &_req, uuv_gazebo_ros_plugins_msgs::SetUseGlobalCurrentVel::Response &_res)
Set flag to use the global current velocity topic input.
virtual void PublishHydrodynamicWrenches(gazebo::physics::LinkPtr _link)
Publish hydrodynamic wrenches.
ROSCPP_DECL bool isInitialized()
bool SetOffsetAddedMass(uuv_gazebo_ros_plugins_msgs::SetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::SetFloat::Response &_res)
Set the offset factor for the added-mass matrix.
bool GetModelProperties(uuv_gazebo_ros_plugins_msgs::GetModelProperties::Request &_req, uuv_gazebo_ros_plugins_msgs::GetModelProperties::Response &_res)
Return the model properties, along with parameters from the hydrodynamic and hydrostatic models...
gazebo::physics::WorldPtr world
GZ_REGISTER_MODEL_PLUGIN(UmbilicalPlugin)
ignition::math::Vector3d flowVelocity
void UpdateLocalCurrentVelocity(const geometry_msgs::Vector3::ConstPtr &_msg)
Update the local current velocity, this data will be used only if the useGlobalCurrent flag is set to...
std::map< std::string, ros::Publisher > rosHydroPub
Publisher for current actual thrust.
bool SetOffsetLinearForwardSpeedDamping(uuv_gazebo_ros_plugins_msgs::SetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::SetFloat::Response &_res)
Set the offset factor for the linear forward speed damping matrix.
virtual void PublishCurrentVelocityMarker()
Publishes the current velocity marker.
std::map< std::string, ros::ServiceServer > services
Map of services.
#define UUV_DAMPING_TORQUE
bool GetScalingAddedMass(uuv_gazebo_ros_plugins_msgs::GetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::GetFloat::Response &_res)
Return current scaling factor for the added-mass matrix.
bool SetScalingAddedMass(uuv_gazebo_ros_plugins_msgs::SetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::SetFloat::Response &_res)
Set the scaling factor for the added-mass matrix.
#define RESTORING_FORCE
bool GetOffsetNonLinearDamping(uuv_gazebo_ros_plugins_msgs::GetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::GetFloat::Response &_res)
Return the offset factor for the nonlinear damping matrix.
bool SetOffsetVolume(uuv_gazebo_ros_plugins_msgs::SetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::SetFloat::Response &_res)
Set offset factor for the model&#39;s volume (this will alter the value for the buoyancy force) ...
virtual void PublishIsSubmerged()
Publishes the state of the vehicle (is submerged)
#define UUV_ADDED_CORIOLIS_TORQUE
virtual void GenWrenchMsg(ignition::math::Vector3d _force, ignition::math::Vector3d _torque, geometry_msgs::WrenchStamped &_output)
Returns the wrench message for debugging topics.
void sendTransform(const geometry_msgs::TransformStamped &transform)
#define UUV_ADDED_MASS_FORCE
void Load(gazebo::physics::ModelPtr _parent, sdf::ElementPtr _sdf)
Load module and read parameters from SDF.
virtual void PublishRestoringForce(gazebo::physics::LinkPtr _link)
Publish restoring force.
bool SetScalingDamping(uuv_gazebo_ros_plugins_msgs::SetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::SetFloat::Response &_res)
Set a scaling factor for the overall damping matrix.
bool SetOffsetNonLinearDamping(uuv_gazebo_ros_plugins_msgs::SetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::SetFloat::Response &_res)
Set the offset factor for the nonlinear damping matrix.
bool GetOffsetLinearDamping(uuv_gazebo_ros_plugins_msgs::GetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::GetFloat::Response &_res)
Return the offset factor for the linear damping matrix.
bool GetScalingVolume(uuv_gazebo_ros_plugins_msgs::GetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::GetFloat::Response &_res)
Get scaling factor for the model&#39;s volume used for buoyancy force computation.
bool SetScalingVolume(uuv_gazebo_ros_plugins_msgs::SetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::SetFloat::Response &_res)
Set scaling factor for the model&#39;s volume used for buoyancy force computation.
ros::Subscriber subLocalCurVel
Subscriber to locally calculated current velocity.
bool GetOffsetAddedMass(uuv_gazebo_ros_plugins_msgs::GetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::GetFloat::Response &_res)
Return the offset factor for the added-mass matrix.
static Time now()
virtual void Update(const gazebo::common::UpdateInfo &_info)
Update the simulation state.
#define UUV_ADDED_MASS_TORQUE
gazebo::physics::ModelPtr model
bool GetOffsetVolume(uuv_gazebo_ros_plugins_msgs::GetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::GetFloat::Response &_res)
Return the offset factor for the model&#39;s volume.
#define UUV_DAMPING_FORCE
bool GetScalingDamping(uuv_gazebo_ros_plugins_msgs::GetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::GetFloat::Response &_res)
Return the scaling factor for the overall damping matrix.
bool SetFluidDensity(uuv_gazebo_ros_plugins_msgs::SetFloat::Request &_req, uuv_gazebo_ros_plugins_msgs::SetFloat::Response &_res)
Set new fluid density (this will alter the value for the buoyancy force)


uuv_gazebo_ros_plugins
Author(s): Musa Morena Marcusso Manhaes , Sebastian Scherer , Luiz Ricardo Douat
autogenerated on Mon Jul 1 2019 19:39:15