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

Fix physics based sensor update rate in lockstep mode #2863

Merged
merged 2 commits into from
Oct 29, 2020

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Oct 24, 2020

closes issue #2861 - see issue on how to reproduce the problem

Problem was that the physics based sensors were all throttled by the max update rate of all sensors in lockstep mode. This PR applies proper throttling to the sensors.

I was also able to reproduce the problem by adding an additional ray sensor with different update rate to the laser strict rate integration test world file and that caused INTEGRATION_laser test to fail. Test should be fixed with these changes.

Signed-off-by: Ian Chen <ichen@osrfoundation.org>
@iche033 iche033 added the 9 Gazebo 9 label Oct 24, 2020
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried it manually, but the logic looks reasonable.

if (this->UpdateImpl(_force))
{
common::Time simTime = this->world->SimTime();
this->lastUpdateTime = simTime;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could avoid the temporary object here:

Suggested change
this->lastUpdateTime = simTime;
this->lastUpdateTime = this->world->SimTime();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. 4ab78c5

Signed-off-by: Ian Chen <ichen@osrfoundation.org>
@iche033 iche033 merged commit 7ffc25a into gazebo9 Oct 29, 2020
@iche033 iche033 deleted the sensor_rate_lockstep branch October 29, 2020 00:08
@peci1
Copy link
Contributor

peci1 commented Oct 12, 2023

This fix is very much needed in Gazebo 11, where it hasn't been ported!!! Without it, gazebo_ros_imu_sensor is broken and never publishes any ROS messages in lockstep mode (and gazebo_ros_block_laser and gazbeo_ros_range as well, as given by the search https://github.com/search?q=repo%3Aros-simulation%2Fgazebo_ros_pkgs%20lastupdatetime&type=code ).

When porting the fix, it should also be taken into account that lastUpdateTime is protected by mutex this->dataPtr->mutexLastUpdateTime, which wasn't locked in the code added by this PR.

@iche033 Do you want to prepare the forward port or should I?

@iche033
Copy link
Contributor Author

iche033 commented Oct 12, 2023

@iche033 Do you want to prepare the forward port or should I?

yep, created #3353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9 Gazebo 9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants