in mujoco_py/mjsim.pyx [0:0]
def step_udd(self):
if self._udd_callback is None:
self.udd_state = {}
else:
schema_example = self.udd_state
self.udd_state = self._udd_callback(self)
# Check to make sure the udd_state has consistent keys and dimension across steps
if schema_example is not None:
keys = set(schema_example.keys()) | set(self.udd_state.keys())
for key in keys:
assert key in schema_example, "Keys cannot be added to udd_state between steps."
assert key in self.udd_state, "Keys cannot be dropped from udd_state between steps."
if isinstance(schema_example[key], Number):
assert isinstance(self.udd_state[key], Number), \
"Every value in udd_state must be either a number or a numpy array"
else:
assert isinstance(self.udd_state[key], np.ndarray), \
"Every value in udd_state must be either a number or a numpy array"
assert self.udd_state[key].shape == schema_example[key].shape, \
"Numpy array values in udd_state must keep the same dimension across steps."