Gazebo | Ignition | Community
Ask Your Question

Pausing the physics in sensor's OnUpdate function gives "Took over 1.0 seconds to update a sensor."

asked 2017-07-10 09:35:57 -0600

hamzamerzic gravatar image

Hi. I am making a simulation which I can step through. Each step of the simulation corresponds to a single sensor measurement, i.e. when I call the step function, simulation is run until the next measurement is received.

Once the measurement is received, I pause the physics, process the measurement data and send it back via a ROS service (since I want to make sure that the message is delivered). The OnUpdate function looks something like:

void ObservationPlugin::OnUpdate() {
  if (!ros::service::exists("/gazebo_sim/transfer_obs", false)) {
  std::cerr << world_->GetSimTime() << " ";
  std::cerr << world_->GetSimTime() << " ";

  // Process the observations.
  ...;  // ROS service call which forwards the observation.

But, I keep getting the following error:

void gazebo::sensors::SensorManager::SensorContainer::RunLoop(): Assertion `(diffTime.sec < 1)&&("Took over 1.0 seconds to update a sensor.")' failed.

and when I check the output, I see that the simulation time increases during SetPaused operation - sometimes for even more than 2 seconds, which is rather strange as I am not unpausing the simulation anywhere else in the code, only in the step function.

Is this the expected behavior of the SetPaused function? If so, is there a way to make the unpause instantaneous?

edit retag flag offensive close merge delete



What type of plugin is ObservationPlugin?

nkoenig gravatar imagenkoenig ( 2017-07-10 16:41:19 -0600 )edit

ObservationPlugin inherits from a SensorPlugin. I made it by adapting the Contact Sensor from Gazebo tutorials.

hamzamerzic gravatar imagehamzamerzic ( 2017-07-11 03:39:41 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-07-10 13:25:40 -0600

hamzamerzic gravatar image

I had noticed that when gzclient was open, the simulation made sense, which is what I had noticed before on a different problem. So now the only issue is to make the behavior the same in both cases. I briefly tested a workaround by basically subscribing to a high bw topic. It seems to work, but I am not really satisfied with this "fix"...

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-07-10 09:35:57 -0600

Seen: 869 times

Last updated: Jul 10 '17