How to get the gazebo::Entity from the entity's id in ignition

asked 2021-08-30 05:50:48 -0500

Tudala gravatar image

Hello all,

I am trying to get an entity from its id. As every entity in Ignition has a unique id, I think it is quiet a easy job, but unfortunately can't find a function to do that. I get the id from the contact sensor message (code shows below), also I get an entity of the collision object, but the type of the entity is msgs::Entity, which is not what I want.I have read the doc of the igition::gazebo, but no found.

-----------------------------------------#

auto contacts = _ecm.Component<components::contactsensordata>(entity); auto collisionEntity = contacts->Data().contact().Get(0).collision2(); long id = collisionEntity.id()

------------------------------------------#

I wonder:

  1. if there is any way to get the entity from the id;
  2. if there is any way to convert the msgs::Entity to the gazbo::Entity.

Either way will help me out. Many thanks!

edit retag flag offensive close merge delete