Skip to content

Commit 2f1ff79

Browse files
expose "mj_setConst" functionality. (#386)
* Initialize perturbations properly. * Expose "set constants" mujoco operation.
1 parent a1b6e31 commit 2f1ff79

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

mujoco_py/mjrendercontext.pyx

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from threading import Lock
22
from mujoco_py.generated import const
33

4+
45
cdef class MjRenderContext(object):
56
"""
67
Class that encapsulates rendering functionality for a
@@ -35,6 +36,7 @@ cdef class MjRenderContext(object):
3536
maxgeom = 1000
3637
mjv_makeScene(self._model_ptr, &self._scn, maxgeom)
3738
mjv_defaultCamera(&self._cam)
39+
mjv_defaultPerturb(&self._pert)
3840
mjv_defaultOption(&self._vopt)
3941
mjr_defaultContext(&self._con)
4042

@@ -55,8 +57,11 @@ cdef class MjRenderContext(object):
5557
self.cam = WrapMjvCamera(&self._cam)
5658
self.vopt = WrapMjvOption(&self._vopt)
5759
self.con = WrapMjrContext(&self._con)
60+
5861
self._pert.active = 0
5962
self._pert.select = 0
63+
self._pert.skinselect = -1
64+
6065
self.pert = WrapMjvPerturb(&self._pert)
6166

6267
self._markers = []

mujoco_py/mjsim.pyx

+7
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ cdef class MjSim(object):
105105
with wrap_mujoco_warning():
106106
mj_forward(self.model.ptr, self.data.ptr)
107107

108+
def set_constants(self):
109+
"""
110+
Set constant fields of mjModel, corresponding to qpos0 configuration.
111+
"""
112+
with wrap_mujoco_warning():
113+
mj_setConst(self.model.ptr, self.data.ptr)
114+
108115
def step(self, with_udd=True):
109116
"""
110117
Advances the simulation by calling ``mj_step``.

0 commit comments

Comments
 (0)