MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / check_invalid_state

Method check_invalid_state

dm_control/mujoco/engine.py:346–368  ·  view source on GitHub ↗

Checks whether the physics state is invalid at exit. Yields: None Raises: PhysicsError: if the simulation state is invalid at exit, unless this context is nested inside a `suppress_physics_errors` context, in which case a warning will be logged instead.

(self)

Source from the content-addressed store, hash-verified

344
345 @contextlib.contextmanager
346 def check_invalid_state(self):
347 """Checks whether the physics state is invalid at exit.
348
349 Yields:
350 None
351
352 Raises:
353 PhysicsError: if the simulation state is invalid at exit, unless this
354 context is nested inside a `suppress_physics_errors` context, in which
355 case a warning will be logged instead.
356 """
357 np.copyto(self._warnings_before, self._warnings)
358 yield
359 np.greater(self._warnings, self._warnings_before, out=self._new_warnings)
360 if any(self._new_warnings):
361 warning_names = np.compress(self._new_warnings,
362 list(mujoco.mjtWarning.__members__))
363 message = _INVALID_PHYSICS_STATE.format(
364 warning_names=', '.join(warning_names))
365 if self._warnings_cause_exception:
366 raise _control.PhysicsError(message)
367 else:
368 logging.warn(message)
369
370 def __getstate__(self):
371 return self.data # All state is assumed to reside within `self.data`.

Callers 5

stepMethod · 0.95
forwardMethod · 0.95
testBadQposMethod · 0.80
testNanControlMethod · 0.80

Calls

no outgoing calls

Tested by 3

testBadQposMethod · 0.64
testNanControlMethod · 0.64