gz-sim icon indicating copy to clipboard operation
gz-sim copied to clipboard

Sensor component name not set from the SDF

Open Myzhar opened this issue 1 year ago • 1 comments

Environment

  • OS Version: Ubuntu 20.04
  • Source or binary build? Binay Fortress

Description

  • Expected behavior: When I retrieve a sensor component in the Config function I expect to get the correct name as set in the SDF.
  • Actual behavior: sensor component name is always __default__

Steps to reproduce

Example with a camera sensor:

auto camComp = _ecm.Component<ignition::gazebo::components::Camera>(_entity);
igndbg << "Camera name (from sensor): " << camComp->Data().CameraSensor()->Name() << std::endl;
igndbg << "Camera name (from component): " << camComp->Data().Name() << std::endl;

Output

[Dbg] [CameraSystem.cc:78] Camera name (from sensor): __default__
[Dbg] [CameraSystem.cc:79] Camera name (from component): camera

Myzhar avatar Jul 12 '22 14:07 Myzhar

The recommended way of getting an entity's name from the ECM is through the components::Name component. The sensor components holding SDF elements will often not have duplicated data that's already available on other components.

chapulina avatar Jul 27 '22 18:07 chapulina