Gazebo | Ignition | Community
Ask Your Question
0

Howto access a model's dimensions from inside a ModelPlugin

asked 2016-05-02 13:16:03 -0500

Illuminatur gravatar image

updated 2016-05-02 13:18:18 -0500

Hi guys,

i have implemented a model plugin, which is automatically instantiated embedding a sdf in my simulated world. With the use of a model ptr i should have, as the function name indicates, access to the collision box by

math::Box GetCollisionBox() const

Unfortunately, this function always returns a zero vector for the dimension of this box, though Gazebo's collision view in the GUI displays the correct dimension. Another method, which is provided by the model pointer,

math::Box GetBoundingBox() const

provides values of which it isn't obvious how they are calculated, related to the sdf definition of the model. Having a look at the current code in Model.cc on bitbucket, following up l.748, it seems to be calculated iterating through all links, aggregating over all the bounding boxes of the links.

So my question is, how can the bounding box be specified the right way in order to derive the appropriate dimensions of a model?

Best regards!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-05-02 18:41:24 -0500

chapulina gravatar image

I believe you're looking for information on a model's geometry. First, let's understand the structure of a model in Gazebo.

  • A model is a collection of links

  • A link can contain several collisions

  • Each collision has a shape. The shape can be something like a box, cylinder, sphere or a mesh.

So if you have a model which you know has a single link, which has a single collision, which is a sphere, you can get to its radius like this:

  1. Model::GetLink

    auto link = model->GetLink();
    
  2. Link::GetCollisions

    auto collision = link->GetCollisions()[0];
    
  3. Collision::GetShape

    auto sphereShape = boost::dynamic_pointer_cast<physics::SphereShape>(collision->GetShape());
    
  4. SphereShape::GetRadius

    auto radius = sphereShape->GetRadius();
    

Regarding the rest of your question:

  • I couldn't find the GetCollisionBox function in Gazebo, where did you get it from?

  • As for GetBoundingBox, it represents the world axis-aligned bounding box [1]. That is the smallest box aligned with the world which fully contains the model.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2016-05-02 13:16:03 -0500

Seen: 1,699 times

Last updated: May 02 '16