Skip to content

Use standalone MuJoCo 3.3.6 and jrl-cmakemodules v2#98

Draft
arntanguy wants to merge 9 commits intorohanpsingh:mainfrom
arntanguy:topic/nix-and-upgrade
Draft

Use standalone MuJoCo 3.3.6 and jrl-cmakemodules v2#98
arntanguy wants to merge 9 commits intorohanpsingh:mainfrom
arntanguy:topic/nix-and-upgrade

Conversation

@arntanguy
Copy link
Copy Markdown
Collaborator

@arntanguy arntanguy commented Mar 19, 2026

  • Upgrades to MuJoCo 3.3.6. Why 3.3.6? It's the version available in my current efforts in getting the framework in nixpkgs, and also happens to be the latest MuJoCo version I managed to build in Ubuntu 22.04 using the official cmake scripts.
  • Use jrl-cmakemodules v2 from Introduce JRL CMake Modules v2 jrl-umi3218/jrl-cmakemodules#798 (unifies how projects are defined and exported)

Now this is essentially a rewrite of the existing cmake scripts, and it has some implications:

  • Uses a version of MuJoCo officially exported with the official cmake scripts and consumed through a regular find_package(mujoco ...)
  • Removes the legacy uitools and related unused codepaths. This is unavailable since MuJoCo 2.x.
  • We must now use platform adapters, which is what is already done for MuJoCo 3.0. However, for some strange reason, the mujoco team did not see fit to export the simulate/ component containing a working adapter implementation. In the current version, we rely on building source files gathered directly from MuJoCo's source tree. This is both unavailable with the installed version (sources are not installed and the find_package does not report where the source tree lives), and not straightforward to do in Nix (each package is built in its own separated sandbox there). Thus I bundled the necessary files from the simulate/ folder of MuJoCo 3.3.6 into this repository. Not ideal as we will need to keep them in sync manually with future releases.
  • Linking against glfw/opengl. The current src/CMakeLists.txt is doing a lot of odd things here. I tried cleaning it up by linking against "sensible" targets, this works in Nix. However, so far I have been unable to make it work in my Ubuntu 22.04 devcontainer (running within NixOS), it segfaults at 0x0, never a great sign. This might however be due to my specific setup, further investigations needed.**. Considering the very specific linking step in the existing cmake files, I suspect there is some deeper incompatibilities going on there.

Leaving this as a WIP until I can look deeper into this.
@ThomasDuvinage if you wish to try, it requires mc-rtc/superbuild-extensions#5 to build (install MuJoCo as a regular cmake project)

@arntanguy
Copy link
Copy Markdown
Collaborator Author

I can confirm that building and running MuJoCo 3.3.6 with the existing cmake scripts of mc_mujoco main branch works on ubuntu 22.04, but not in my current rewrite attempt. I'll try and see tomorrow if I can figure out where the opengl library clashes come from and if we can resolve them in a sensible way.

Builds and run against mujoco 3.3.6 in nix
This relies on uitools.h deprecated since MuJoco 2.x, we will never use
it again and it makes code messy.
Significant changes around use of glfw target use, I am not sure I fully
understand the use-case for the complicated logic that used to exist
before (i.e merging static libraries), so this might need to be
revisited later on should issues arise.
@arntanguy arntanguy force-pushed the topic/nix-and-upgrade branch from 7a5d68a to 45b3fe8 Compare March 22, 2026 15:36
@arntanguy arntanguy changed the title Upgrade to MuJoCo 3.3.6 and jrl-cmakemodules v2 Use standalone MuJoCo 3.3.6 and jrl-cmakemodules v2 Mar 22, 2026
@arntanguy arntanguy force-pushed the topic/nix-and-upgrade branch from c4bdaab to a43b2af Compare March 24, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant