Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Ok I found it.

For those interested, here it is:

void MyPlugin::Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf)
{
  // Get then name of the parent sensor
  sensor_ = std::dynamic_pointer_cast<sensors::MySensor>(_parent);

  if (!sensor_) {
    gzthrow("[MyPlugin] Sensor error");
  }

  // Get world
  world_ = physics::get_world(sensor_->WorldName());

  if (!world_) {
    gzthrow("[MyPlugin] World error");
  }

  // Get parent link
  link_ = world_->EntityByName(sensor_->ParentName());

  if (!link_) {
    gzthrow("[MyPlugin] Link error");
  }

  ...
}

and then

 ignition::math::Vector3d sensor_velocity = link_->RelativeLinearVel()

Ok I found it.

For those interested, here it is:

void MyPlugin::Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf)
{
  // Get then name of the parent sensor
  sensor_ = std::dynamic_pointer_cast<sensors::MySensor>(_parent);

  if (!sensor_) {
    gzthrow("[MyPlugin] Sensor error");
  }

  // Get world
  world_ = physics::get_world(sensor_->WorldName());

  if (!world_) {
    gzthrow("[MyPlugin] World error");
  }

  // Get parent link
  link_ = world_->EntityByName(sensor_->ParentName());

  if (!link_) {
    gzthrow("[MyPlugin] Link error");
  }

  ...
}

and then

 ignition::math::Vector3d sensor_velocity = link_->RelativeLinearVel()