0

With my simulations, I keep running into errors which only occur at runtime, such as

terminate called after throwing an instance of 'std::logic_error'
  what():  Vector appears to be nearly zero.

and

abort: Failure at multibody/plant/implicit_stribeck_solver.cc:216 in SolveQuadraticForTheSmallestPositiveRoot(): condition 'Delta > 0' failed.

I'd like to be able to log the time in which these problems occur to track down the specific state which causes these errors. I'd also like to be able to log different state parameters such as forces and positions of my different bodies, which I know how to do.

Functions for checking body positions and states at different times have been documented, such as EvalPoseInWorld(). What I'm looking for is some sort of failure trigger for outputting this data. I'd like to also be able to log the real_time_factor visible in the drake simulator, but don't know how to access it.

For reference, I'm running an example I made in this fork: https://github.com/joaqgira/drake

You can run the example within drake/ with bazel run examples/springboard:shape_collision.

1 Answers1

0

Look at Simulator::set_monitor for how to add a callback to the simulator. The callback could log a "last known good time" from which you could guess that the problematic time is not long after.

Look at Simulator::get_actual_realtime_rate for the rate. (Note that the visualizer doesn't use that method directly; drake/tools/workspace/drake_visualizer/plugin/show_time.py for the visualizer logic to compute the realtime factor.)

jwnimmer-tri
  • 1,994
  • 2
  • 5
  • 6