Add mj_copyState
PiperOrigin-RevId: 836588419 Change-Id: I7609e121dc0ac697d4d015d4244bdd5962650def
This commit is contained in:
committed by
Copybara-Service
parent
eac8e60037
commit
888d3a7b07
@@ -806,6 +806,13 @@ class MuJoCoBindingsTest(parameterized.TestCase):
|
||||
# Expect next states to be equal.
|
||||
np.testing.assert_array_equal(state1a, state1b)
|
||||
|
||||
# Test mj_copyState
|
||||
data2 = mujoco.MjData(self.model)
|
||||
mujoco.mj_copyState(self.model, self.data, data2, sig)
|
||||
state1c = np.empty(size, np.float64)
|
||||
mujoco.mj_getState(self.model, data2, state1c, sig)
|
||||
np.testing.assert_array_equal(state1a, state1c)
|
||||
|
||||
def test_mj_setKeyframe(self): # pylint: disable=invalid-name
|
||||
mujoco.mj_step(self.model, self.data)
|
||||
|
||||
|
||||
@@ -350,6 +350,7 @@ PYBIND11_MODULE(_functions, pymodule) {
|
||||
}
|
||||
return InterceptMjErrors(::mj_setState)(m, d, state.data(), sig);
|
||||
});
|
||||
Def<traits::mj_copyState>(pymodule);
|
||||
Def<traits::mj_setKeyframe>(pymodule);
|
||||
Def<traits::mj_addContact>(pymodule);
|
||||
Def<traits::mj_isPyramidal>(pymodule);
|
||||
|
||||
@@ -2520,6 +2520,36 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
|
||||
),
|
||||
doc='Set state.',
|
||||
)),
|
||||
('mj_copyState',
|
||||
FunctionDecl(
|
||||
name='mj_copyState',
|
||||
return_type=ValueType(name='void'),
|
||||
parameters=(
|
||||
FunctionParameterDecl(
|
||||
name='m',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='mjModel', is_const=True),
|
||||
),
|
||||
),
|
||||
FunctionParameterDecl(
|
||||
name='src',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='mjData', is_const=True),
|
||||
),
|
||||
),
|
||||
FunctionParameterDecl(
|
||||
name='dst',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='mjData'),
|
||||
),
|
||||
),
|
||||
FunctionParameterDecl(
|
||||
name='sig',
|
||||
type=ValueType(name='unsigned int'),
|
||||
),
|
||||
),
|
||||
doc='Copy state from src to dst.',
|
||||
)),
|
||||
('mj_setKeyframe',
|
||||
FunctionDecl(
|
||||
name='mj_setKeyframe',
|
||||
|
||||
Reference in New Issue
Block a user