You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a workaround sensor plugin you can attach to the affected sensors that will update the lastUpdateTime variable. Use this until a proper fix is merged. Be aware that this workaround doesn't lock the mutex that protects lastUpdateTime. However, the Gazebo 9 PR that fixed this bug also did not lock the mutex, so hopefully it's not a big issue.
#include<sstream>
#defineprotected public
#include<gazebo/sensors/Sensor.hh>
#undef protected
#include<gazebo/common/Plugin.hh>
#include<gazebo/physics/physics.hh>namespacegazebo
{
/** * \brief Workaround plugin sensor for issue https://github.com/gazebosim/gazebo-classic/issues/3336 in Gazebo 11. * * Just attach it to a sensor which forgets to update lastUpdateTime in lockstep mode and the time will get updated.*/classSensorUpdateTimeWorkaround : publicSensorPlugin
{
public:voidLoad(sensors::SensorPtr sensor_, sdf::ElementPtr sdf_) override
{
this->sensor = sensor_;
if (this->sensor == nullptr)
{
gzerr << "Error: SensorUpdateTimeWorkaround must be attached to a sensor!" << std::endl;
return;
}
if (this->sensor->StrictRate())
{
this->updateConnection = this->sensor->ConnectUpdated([this]() {
constauto world = gazebo::physics::get_world(this->sensor->WorldName());
this->sensor->lastUpdateTime = world->SimTime();
});
}
}
gazebo::event::ConnectionPtr updateConnection;
sensors::SensorPtr sensor {nullptr}; //!< The sensor of this plugin.
};
GZ_REGISTER_SENSOR_PLUGIN(SensorUpdateTimeWorkaround)
}
License of the code block: BSD-3-Clause. Copyright: Czech Technical University in Prague.
Environment
gazebo v11.12.0
Description
Steps to reproduce
Output
The gazebo11 branch appears to be missing a line that I see in the gazebo9 branch:
https://github.com/gazebosim/gazebo-classic/blob/gazebo9/gazebo/sensors/Sensor.cc#L185
https://github.com/gazebosim/gazebo-classic/blob/gazebo11/gazebo/sensors/Sensor.cc#L242
This line seems necessary to update the lastUpdateTime when running in lockstep mode that many of the sensor plugins use to timestamp their data.
The text was updated successfully, but these errors were encountered: