Mujoco-py: Change Mujoco Model Parameters online

Created on 10 Mar 2017  Â·  11Comments  Â·  Source: openai/mujoco-py

Hi there,

I am not sure if this is the correct forum for this question but I would like to ask whether it is possible, using your python wrappers, to change the Mujoco model parameters dynamically between time steps. For example, in inverted pendulum, can I change the mass or length of the pendulum at each time step?

Thanks!

v0.5

Most helpful comment

Uncomment the definition of mj_setConst here: https://github.com/openai/mujoco-py/blob/master/mujoco_py/mjlib.py#L77 and you should be able to call it.

All 11 comments

There's no high-level API through Mujoco-py. It might be possible using Mujoco's C API. See http://mujoco.org/book/programming.html.

Yeah it is definitely possible using Mujoco's C API. The only issue is that I will need to recompute parameters that are saved in mjModel on the fly, by calling mj_setConst on the C side. Do you see a way for me to modify the python code to perform this call on the fly from the python side?

Uncomment the definition of mj_setConst here: https://github.com/openai/mujoco-py/blob/master/mujoco_py/mjlib.py#L77 and you should be able to call it.

Great thanks Trevor!

Hi,

Could you explain how you solved this problem?
I am not sure how to use Mujoco's C Api with openai Gym Wrapper.

Thank you.

hi @MankowitzProjects,
I wonder how you change the mass of certain object in mujoco.
I just umcomment this line, and then I'm at lost :(

Thanks I solved it

Hi Andrew,

I hadn't gotten around to implementing the model parameter changes as yet.
I am glad you solved it!

Cheers,
Dan

On Fri, Apr 14, 2017 at 10:54 AM, Andrew notifications@github.com wrote:

Thanks I solved it

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/openai/mujoco-py/issues/33#issuecomment-294110729,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA1-RSaLQA8koh6y1qlyMU3cLfH6It-Iks5rvyYxgaJpZM4MZuXn
.

hi @tlbtlbtlb
I'm still new to mujoco. Can you give us an example use of mjlib.mj_setConst??
It seems that the argument should be [POINTER(MJMODEL), POINTER(MJDATA), c_int]
Whereas, I still don't know how to use it

I just found same question in mujoco forum and it answers more specifically.

http://www.mujoco.org/forum/index.php?threads/can-the-parameters-of-a-model-be-changed-on-the-fly.3354/

hi @MankowitzProjects,
how to use mj_setConst on the python side.
thanks

Was this page helpful?
0 / 5 - 0 ratings