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)
| 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`. |
no outgoing calls