Add mju_clip, mju_fill, mju_eye and mju_symmetrize to python bindings.
- Also change signatures of `mju_fill` and `mju_symmetrize` to conform to standard. PiperOrigin-RevId: 485613824 Change-Id: I8dd618bac92ef40aa6c76380fa73302e81968687
This commit is contained in:
committed by
Copybara-Service
parent
7458a6e90f
commit
c83be2bc05
@@ -1049,6 +1049,27 @@ Euler integrator, semi-implicit in velocity.
|
||||
rank = mujoco.mju_boxQP(res, r, index, h, g, lower, upper)
|
||||
self.assertGreater(rank, -1)
|
||||
|
||||
def test_mju_fill(self):
|
||||
res = np.empty(3, np.float64)
|
||||
mujoco.mju_fill(res, 1.5)
|
||||
np.testing.assert_array_equal(res, np.full(3, 1.5))
|
||||
|
||||
def test_mju_eye(self):
|
||||
eye4 = np.empty((4, 4), np.float64)
|
||||
mujoco.mju_eye(eye4)
|
||||
np.testing.assert_array_equal(eye4, np.eye(4))
|
||||
|
||||
def test_mju_symmetrize(self):
|
||||
mat = np.linspace(0, 1, 16).reshape(4, 4)
|
||||
res = np.empty((4, 4), np.float64)
|
||||
mujoco.mju_symmetrize(res, mat)
|
||||
np.testing.assert_array_equal(res, 0.5*(mat + mat.T))
|
||||
|
||||
def test_mju_clip(self):
|
||||
self.assertEqual(mujoco.mju_clip(1.5, 1.0, 2.0), 1.5)
|
||||
self.assertEqual(mujoco.mju_clip(1.5, 2.0, 3.0), 2.0)
|
||||
self.assertEqual(mujoco.mju_clip(1.5, 0.0, 1.0), 1.0)
|
||||
|
||||
def test_mju_mul_vec_mat_vec(self):
|
||||
vec1 = np.array([1., 2., 3.])
|
||||
vec2 = np.array([3., 2., 1.])
|
||||
|
||||
Reference in New Issue
Block a user