Resets internal variables of the simulation, possibly to a keyframe. Args: keyframe_id: Optional integer specifying the index of a keyframe defined in the model XML to which the simulation state should be initialized. Must be between 0 and `self.model.nkey - 1` (inclusive)
(self, keyframe_id=None)
| 304 | return new_obj |
| 305 | |
| 306 | def reset(self, keyframe_id=None): |
| 307 | """Resets internal variables of the simulation, possibly to a keyframe. |
| 308 | |
| 309 | Args: |
| 310 | keyframe_id: Optional integer specifying the index of a keyframe defined |
| 311 | in the model XML to which the simulation state should be initialized. |
| 312 | Must be between 0 and `self.model.nkey - 1` (inclusive). |
| 313 | |
| 314 | Raises: |
| 315 | ValueError: If `keyframe_id` is out of range. |
| 316 | """ |
| 317 | if keyframe_id is None: |
| 318 | mujoco.mj_resetData(self.model.ptr, self.data.ptr) |
| 319 | else: |
| 320 | if not 0 <= keyframe_id < self.model.nkey: |
| 321 | raise ValueError(_KEYFRAME_ID_OUT_OF_RANGE.format( |
| 322 | max_valid=self.model.nkey-1, actual=keyframe_id)) |
| 323 | mujoco.mj_resetDataKeyframe(self.model.ptr, self.data.ptr, keyframe_id) |
| 324 | |
| 325 | # Disable actuation since we don't yet have meaningful control inputs. |
| 326 | with self.model.disable('actuation'): |
| 327 | self.forward() |
| 328 | |
| 329 | def after_reset(self): |
| 330 | """Runs after resetting internal variables of the physics simulation.""" |