Skip to content

Commit

Permalink
expose "mj_setConst" functionality. (#386)
Browse files Browse the repository at this point in the history
* Initialize perturbations properly.

* Expose "set constants" mujoco operation.
  • Loading branch information
MillionIntegrals authored Apr 15, 2019
1 parent a1b6e31 commit 2f1ff79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mujoco_py/mjrendercontext.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from threading import Lock
from mujoco_py.generated import const


cdef class MjRenderContext(object):
"""
Class that encapsulates rendering functionality for a
Expand Down Expand Up @@ -35,6 +36,7 @@ cdef class MjRenderContext(object):
maxgeom = 1000
mjv_makeScene(self._model_ptr, &self._scn, maxgeom)
mjv_defaultCamera(&self._cam)
mjv_defaultPerturb(&self._pert)
mjv_defaultOption(&self._vopt)
mjr_defaultContext(&self._con)

Expand All @@ -55,8 +57,11 @@ cdef class MjRenderContext(object):
self.cam = WrapMjvCamera(&self._cam)
self.vopt = WrapMjvOption(&self._vopt)
self.con = WrapMjrContext(&self._con)

self._pert.active = 0
self._pert.select = 0
self._pert.skinselect = -1

self.pert = WrapMjvPerturb(&self._pert)

self._markers = []
Expand Down
7 changes: 7 additions & 0 deletions mujoco_py/mjsim.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ cdef class MjSim(object):
with wrap_mujoco_warning():
mj_forward(self.model.ptr, self.data.ptr)

def set_constants(self):
"""
Set constant fields of mjModel, corresponding to qpos0 configuration.
"""
with wrap_mujoco_warning():
mj_setConst(self.model.ptr, self.data.ptr)

def step(self, with_udd=True):
"""
Advances the simulation by calling ``mj_step``.
Expand Down

0 comments on commit 2f1ff79

Please sign in to comment.