lab-key/zmujoco
A Thin Zig Wrapper For MuJoCo
This repository contains the Zig bindings for the MuJoCo C API.
Zig version 0.15.x
MuJoCo version 3.3.8
MuJoCo stands for Multi-Joint dynamics with Contact. It is a general purpose physics engine that aims to facilitate research and development in robotics, biomechanics, graphics and animation, machine learning, and other areas which demand fast and accurate simulation of articulated structures interacting with their environment.
https://github.com/user-attachments/assets/995fb256-6474-4927-a30c-a30a0602bb2f
Robotic Dog
https://github.com/user-attachments/assets/aac1e3ff-62da-447c-983c-6e3ec61d6b01
2D Self-Learning Agent. Works in 3D enviroments. Using a framework I am working on & integrating here as well. Coming soon.
For more higher level and a ( little bit of a ) Desktop app making framework checkout phyzx ( Still early stages )
This repository contains a thin wrapper for MuJoCo allowing for easier integration into other projects and direct programmatic usage of the C API.
MuJoCo has a C API and is intended for researchers and developers. The runtime simulation module is tuned to maximize performance and operates on low-level data structures that are preallocated by the built-in XML compiler.
MuJoCo further exposes a large number of utility functions for computing physics-related quantities.
You should be able to just:
git clone https://github.com/lab-key/zmujoco.git
# Everything in the examples directory gets built automatically
zig build
# So you can just
./zig-out/bin/control_model # Or load_model - until I integrate everything properly...
This repository is already setup so you don't really need the setup.zig & cleanup.zig it uses my mujoco dev branch as a git submodule to allow for updates.
In case you want to setup your own zmujoco basically you need to convert the CMakeLists.txt from mujoco into a build.zig and then configure everything into a Zig module. You can check the setup.zig there for some ideas as well.
Examples & Tests
A nice clean way to integrate or point to third party modelfiles.
All the demos and most things I am internally working on are done very ' dirty ' with direct C interop need to either properly wrap it or reprogram it..
All the documenatation is in the docs/ directory.
I highly recommend you look at the tests directory as well as it contains a lot of examples as does the phyzx[link] project.
MuJoCo's documentation can be found at mujoco.readthedocs.io. Upcoming features due for the next release can be found in the changelog in the "latest" branch.
If you use MuJoCo for published research, please cite:
@inproceedings{todorov2012mujoco,
title={MuJoCo: A physics engine for model-based control},
author={Todorov, Emanuel and Erez, Tom and Tassa, Yuval},
booktitle={2012 IEEE/RSJ International Conference on Intelligent Robots and Systems},
pages={5026--5033},
year={2012},
organization={IEEE},
doi={10.1109/IROS.2012.6386109}
}
Copyright 2021 DeepMind Technologies Limited.
Box collision code (engine_collision_box.c)
is Copyright 2016 Svetoslav Kolev.
ReStructuredText documents, images, and videos in the doc directory are made
available under the terms of the Creative Commons Attribution 4.0 (CC BY 4.0)
license. You may obtain a copy of the License at
https://creativecommons.org/licenses/by/4.0/legalcode.
Source code is licensed under the Apache License, Version 2.0. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0.
This is not an officially supported Google product.