Home | Tutorials | Wiki | Issues
Ask Your Question
0

Sensor plugin: how to access parent link velocity?

asked 2020-03-27 12:51:22 -0500

jlecoeur gravatar image

Hi,

I am writing a sensor plugin and I need to access the sensor relative linear velocity and sensor relative angular velocity.

I cannot find how to do it in the documentation, how can I do it?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-28 04:16:01 -0500

jlecoeur gravatar image

updated 2020-03-28 04:16:39 -0500

Ok I found it.

For those interested, here it is:

void MyPlugin::Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf)
{
  // Get 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()
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-03-27 12:51:22 -0500

Seen: 21 times

Last updated: Mar 28