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

Method testNstep

dm_control/mujoco/engine_test.py:627–663  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

625 np.testing.assert_array_equal(spec.maximum, [mujoco.mjMAXVAL, 2.0])
626
627 def testNstep(self):
628 # Make initial state.
629 with self._physics.reset_context():
630 self._physics.data.qvel[0] = 1
631 self._physics.data.qvel[1] = 1
632 initial_state = self._physics.get_state()
633
634 # step() 4 times.
635 for _ in range(4):
636 self._physics.step()
637 for_loop_state = self._physics.get_state()
638
639 # Reset state, call step(4).
640 with self._physics.reset_context():
641 self._physics.set_state(initial_state)
642 self._physics.step(4)
643 nstep_state = self._physics.get_state()
644
645 np.testing.assert_array_equal(for_loop_state, nstep_state)
646
647 # Repeat test with with RK4 integrator:
648 self._physics.model.opt.integrator = enums.mjtIntegrator.mjINT_RK4
649
650 # step() 4 times.
651 with self._physics.reset_context():
652 self._physics.set_state(initial_state)
653 for _ in range(4):
654 self._physics.step()
655 for_loop_state_rk4 = self._physics.get_state()
656
657 # Reset state, call step(4).
658 with self._physics.reset_context():
659 self._physics.set_state(initial_state)
660 self._physics.step(4)
661 nstep_state_rk4 = self._physics.get_state()
662
663 np.testing.assert_array_equal(for_loop_state_rk4, nstep_state_rk4)
664
665if __name__ == '__main__':
666 absltest.main()

Callers

nothing calls this directly

Calls 4

reset_contextMethod · 0.80
get_stateMethod · 0.80
set_stateMethod · 0.80
stepMethod · 0.45

Tested by

no test coverage detected