Add method to check if link was initialized?

Issue #2599 new
Koen Lekkerkerker
created an issue

The Link class has a protected bool "initialized", but there is no way to query it (its only used by inherited classes, so it seems). Would it be useful to add a public bool getInitialized() const or bool isInitialized() const to the class, similar to the bool GetEnabled() const?

My use case is this:

I don't want to add the example actor collision plugin to all my actors / world files.

You don't really need the plugin if you don't need to scale or adjust pose of the collision bodies (which is odd to do in the plugin anyway? it seems like the plugin corrects for a poor specification in the actor model itself, right?). The only thing you need to do is call this once per actor:

if (model->HasType(gazebo::physics::Base::EntityType::ACTOR) {
    // by calling the actor's canonical link, all children should become initialized as well I think?

Now I'm checking for objects on every ConnectWorldUpdateBegin event callback. So I'm concerned to run the Init every time, as the implementation seems costly (especially considering I have several tens of actors based on the CitySim world).

I tried to find a way if I can see if the links are already initialized, but there really seems no way. I tried if I could tell using a try/catch, but I haven't found any illegal call that gives me something catchable that will tell me to Init the actor links.

By the way, you could also consider making the init call cheaper by having it check if "initialized == true" and if yes, return immediately, rather than running init again. I'm not sure if this might break any use cases in which a re-init is needed? In that case, you could adjust it to be a void Init(bool force_reinit = true), such that no existing code breaks?

Lastly: why are actor links not initialized by default? is it considered too costly? Does it impact the physics engine a lot to have "collidable" actors? In that case, wouldn't it be an idea to have a SDF element for the actor that sets "collidable" to true or false?

And wouldn't you agree that the scaling of collision bodies is not a proper 'after the fact' fix, it should be correct in the model itself right? Now if you scale collision bodies using the example plugin, Gazebo GUI still renders unscaled collision bodies (if you enabled collision bodies from the View menu).

Comments (1)

  1. Log in to comment