How to modify existing gz/sensor/Sensor.hh from plugin?

I would like control a sensor that was instantiated from a SDF file from a Plugin. My intentions are disabling it on command, and possibly modifying the publishing rate.

First attemtp

    auto sensorComp = _ecm.Component<gz::sim::components::NavSat>(this->navSatEntity_)->Data();
    auto sensorSdfElementPtr = sensorComp.ToElement();
    this->navSatSensor_.Load(sensorSdfElementPtr);

This creates a new sensor with its own publisher, thus modifications do not affect the original.

Second attemtp

    this->navSatEntity_ = _ecm.EntityByComponents(
        gz::sim::components::Name("navsat_sensor"),
        gz::sim::components::Sensor()
    );
    gz::sensors::Manager manager;
    gz::sensors::Sensor *s = manager.Sensor(this->navSatEntity_);

The sensor does not have the same ID as the Entity which holds it, so can not access the original.


How this should be done? Should I create and manage my own sensor in order to have the manager instance? Is there any other way?

Best,

Hey, did you manage to solve it? I am facing the same issue trying the approach 2, the pointer that I am getting is null