MuJoCo (Multi-Joint dynamics with Contact) physics-based simulation for micro-LF on POSIX platforms (Linux and macOS).
This package includes two interactive demos:
- Basic: a rectangular object that starts above a plane and falls onto it
- Car: a simple two-wheeled vehicle that can be driven with the arrow keys
- A C compiler (GCC or Clang)
- CMake ≥ 3.20
- reactor-uc, with
REACTOR_UC_PATHpointing at the clone:
git clone https://github.com/lf-lang/reactor-uc.git --recurse-submodules
export REACTOR_UC_PATH=$(pwd)/reactor-ucLinux (Ubuntu):
apt install libglfw3-devmacOS:
brew install glfwCMake looks for MuJoCo in this order:
- A CMake package (
find_package(mujoco)), for example an install under/usr/local - The official
MuJoCo.appbundle on macOS (/Applications/MuJoCo.app) - A prefix layout under
/opt/mujocoor/usr/local
Linux (Ubuntu): download a prebuilt release and install it to /opt/mujoco. The following is for
x86_64; for aarch64, use the matching archive from
https://github.com/google-deepmind/mujoco/releases:
wget https://github.com/google-deepmind/mujoco/releases/download/3.2.7/mujoco-3.2.7-linux-x86_64.tar.gz
tar xvf mujoco-*
sudo mv mujoco-3.2.7 /opt/mujocomacOS: either install the official app bundle, or build from source and
install to /opt/mujoco (or /usr/local):
git clone https://github.com/google-deepmind/mujoco.git -b 3.2.7
cd mujoco
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=/opt/mujoco
cmake --build build
sudo cmake --install buildIf MuJoCo is installed somewhere else, pass that prefix to CMake
(-DCMAKE_PREFIX_PATH=... or -DMUJOCO_PATH=...).
From the root of this repository, configure and build with the release preset. This generates code
for both programs and produces build/Basic and build/Car:
cmake --preset release
cmake --build --preset releaseIn VS Code or Cursor, CMake: Configure generates the code, and CMake: Build compiles it.
To build only one program:
cmake --preset release -DLF_MAIN=Basic
cmake --build --preset releaseReplace Basic with Car for the car demo. A debug build is available with the debug preset
(build-debug/ instead of build/).
./build/Basic
./build/CarBoth demos open a visualization window. Mouse scroll zooms, left-drag rotates the view, and
right-drag pans. Backspace resets the simulation; q quits.
In Car, the arrow keys set forward speed and steering.