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

Port sensor update rate fix #3353

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions gazebo/sensors/Sensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,18 @@ void Sensor::Update(const bool _force)
{
if (this->useStrictRate)
{
// rendering sensors (IMAGE category) has its own mechanism
// for throttling and lockstepping with physics. So throttle just
// physics sensors
if (this->dataPtr->category != IMAGE && !this->NeedsUpdate() && !_force)
return;

if (this->UpdateImpl(_force))
{
std::lock_guard<std::mutex> lock(this->dataPtr->mutexLastUpdateTime);
this->lastUpdateTime = this->world->SimTime();;
this->updated();
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion gazebo/sensors/SensorManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ void SensorManager::SensorContainer::RunLoop()
if (!g_sensorsDirty)
return;

// Get the minimum update rate from the sensors.
// Get the maximum update rate from the sensors.
for (Sensor_V::iterator iter = this->sensors.begin();
iter != this->sensors.end() && !this->stop; ++iter)
{
Expand Down
27 changes: 27 additions & 0 deletions test/worlds/laser_hit_strict_rate_test.world
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,32 @@
<static>true</static>
<link name="link">
<sensor name="laser" type="ray">
<ray>
<scan>
<horizontal>
<samples>4</samples>
<resolution>1</resolution>
<min_angle>-2.26889</min_angle>
<max_angle>2.268899</max_angle>
</horizontal>
</scan>
<range>
<min>0.0</min>
<max>20</max>
<resolution>0.01</resolution>
</range>
</ray>
<always_on>1</always_on>
<update_rate>250</update_rate>
<visualize>true</visualize>
</sensor>
</link>
</model>

<model name="ray_model2">
<static>true</static>
<link name="link2">
<sensor name="laser2" type="ray">
<ray>
<scan>
<horizontal>
Expand All @@ -53,5 +79,6 @@
</sensor>
</link>
</model>

</world>
</sdf>