Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom sensor system example ignoring sdf's update rate #2290

Open
5p00kk opened this issue Jan 17, 2024 · 2 comments
Open

Custom sensor system example ignoring sdf's update rate #2290

5p00kk opened this issue Jan 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@5p00kk
Copy link

5p00kk commented Jan 17, 2024

Description

In the implementation of a system for the custom sensor, the sensor is updated calling custom sensor's Update() method:

sensor->Update(_info.simTime);

This will result in sensor update for at each simulation step and the system will ignore the sdf's update_rate attribute.

To avoid it the parent (gz::sensors::Sensor) Update() function should be called that executes the update at given update_rate (if force flag is false). For instance:

sensor->gz::sensors::Sensor::Update(_info.simTime, false);

@5p00kk 5p00kk added the bug Something isn't working label Jan 17, 2024
@mjcarroll
Copy link
Contributor

In general, I believe that our sensor systems are guarded with logic like this:

for (auto &it : this->dataPtr->entitySensorMap)
{
if (it.second->NextDataUpdateTime() <= _info.simTime &&
it.second->HasConnections())
{
needsUpdate = true;
break;
}
}
if (!needsUpdate)
return;
this->dataPtr->Update(_ecm);

There has been discussion of a set of system callbacks that could fire at particular rates, but there are some intricacies to consider with the potential of rewinding or jumps in time.

@5p00kk
Copy link
Author

5p00kk commented Jan 19, 2024

Probably it's two approaches as the following call includes the same check (if forcing=False, the sensor will update itself only if it's time), the sensor's implementation is very similar to the guard in the system:

it.second->Update(_info.simTime, false);

https://github.com/gazebosim/gz-sensors/blob/d522779693916a81aac6360b049286e7ebb6cdb3/src/Sensor.cc#L456C4-L461C1

Regardless, the way OdometerSystem is implemented right now is incorrect because there is neither System level check or call to Sensor's class Update function that would check if it's time to update. Right now the direct Update implementation is being called, which results in Custom Sensor's update being called at the simulation rate.

@azeey azeey moved this from Inbox to To do in Core development Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: To do
Development

No branches or pull requests

2 participants