Contributing to the Package

The majority of the files in this package are auto-generated by a script which parses the original MuJoCo source code, found in gen/generator.jl.

This script performs the following operations:

  1. Generates the C bindings using Clang.jl, based on the compiled MuJoCo_jll package.
  2. Scrapes the introspect Python module found in the mujoco source code, and parses these files to extract docstrings and types.
  3. The C bindings are then cleaned to remove non-compiling generated expressions (due to the C macros)
  4. The documentation from step 2 is then injected to all the Julia generated methods and structs.
  5. Native Julia wrappers for the C level structs are written based on the MuJoCo C structs to make them easier to use in high-level Julia (including adding Garbage Collection)
  6. Next, the Named Access API is then automatically generated based on the X and XGROUP macros in the original source code (mujoco/include/mujoco/mjxmacro.h)
  7. Finally, we parse the file at mujoco/python/mujoco/functions.cc to re-write some of the MuJoCo functions in the same way that the Python bindings do to ensure error checking when passing array objects to these functions. These checks will make sure the arrays of the correct size and type, even checking to make sure the arrays are stored in row-major.

All the files generated by this process contain a warning to not modify the files. If you would like to change something or add it to one of these files, modify the gen/generator.jl script to include these. If the source code does not need to be automatically generated, consider adding a file or code directly into the src directory.

Warning

The source code under the gen folder is currently in need of a major refactor to make it more maintainable in the future. This refactoring work is expected to take place soon, but will not delay core use of the package.