mujoco_mpc icon indicating copy to clipboard operation
mujoco_mpc copied to clipboard

Running MJPC without GUI

Open kgimbergh opened this issue 1 year ago • 6 comments

Hi! I am a student at the TU Delft, I use MuJoCo for my research on balanced standing for an exoskeleton.

I use MJPC in C++ with MuJoCo version 3.1.4 on ubuntu 22.04.

To tune the weights in my cost function, I would like to be able to run MJPC without the GUI of MuJoCo. Now I have read that headless rendering is possible, but I have not been able to accomplish it.

The first option I saw was to install OSMesa or EGL and to set MUJOCO_GL to 'osmesa' or 'egl', respectively. Unfortunately nothing changed in doing this and the MuJoCo GUI launched as it would normally.

When trying to disable the launch of the GUI manually in say simulate.cc, I run into segmentation faults.

I have also seen that it might be possible using python, but I would prefer to keep to C++.

Is there anything that I have looked over? Is there a simple way to get headless rendering? Thanks!

kgimbergh avatar Nov 21 '24 13:11 kgimbergh

Hi @kgimbergh,

What you are asking might be possible, but could you please explain your reasoning? Why do you want this? Generally speaking, MJPC should be used either online-interactive with a GUI or offline via gRPC (no rendering). Are you thinking of the online or offline use case? If the latter, why do you need rendering at all?

Note that the offline functionality is implemented via gRPC. It is possible to talk gRPC over Python but of course it is also possible via C++.

yuvaltassa avatar Nov 21 '24 14:11 yuvaltassa

hello, have you successfully achieved using mjpc without gui?

ppap36 avatar Aug 18 '25 13:08 ppap36

Hi @kgimbergh, did you manage to run mjpc without the GUI after all?

My goal is to run a predefined amount of episodes for a specific task using MJPC. Currently, I have implemented this feature inside the transition function of my task and used a GUI button to start the ``experiment". However, I would like to move to cloud computing for running more experiments and ideally I would like to:

  • Configure the task, planner and physics parameters via corresponding config files instead of using the GUI.
  • Run MJPC with the provided config files without rendering the environment. I expect that what I have implemented in the transition function will log the episode's outcome together with some other metrics and take care of resetting the environment after each episode. One thing I am missing is how to terminate the mjpc app inside the transition function once the desired number of episodes has been completed.

@yuvaltassa do you maybe have any pointers on how to achieve this with MJPC?

boo555 avatar Aug 21 '25 14:08 boo555

Why are you not using the gRPC API again?

yuvaltassa avatar Aug 26 '25 17:08 yuvaltassa

Thanks for the reply. I am not familiar with the gRPC API, are there any examples on how to use it?

What I have done so far is to define my task, my planner, implement what I needed as part of the task.cc file and then run the simulator by executing mjpc. What I want to do now is to start mjpc without the graphical window and then be able somehow to "toggle buttons" or "adjust sliders" via adjusting their corresponding variable's value through terminal or code.

boo555 avatar Aug 27 '25 16:08 boo555

@thowell do we not have documentation for this? If not, is there an example somewhere?

yuvaltassa avatar Aug 27 '25 20:08 yuvaltassa