Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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)) {
    return;
  }
  std::cerr << world_->GetSimTime() << " ";
  world_->SetPaused(true);
  std::cerr << world_->GetSimTime() << " ";

  // Process the observations.
  ...

  obs_client_.call(obs);  // 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?