diff --git a/.github/DISCUSSION_TEMPLATE/Asking-for-Help.yaml b/.github/DISCUSSION_TEMPLATE/Asking-for-Help.yaml deleted file mode 100644 index 46aff129..00000000 --- a/.github/DISCUSSION_TEMPLATE/Asking-for-Help.yaml +++ /dev/null @@ -1,68 +0,0 @@ -body: - - type: textarea - attributes: - label: Intro - description: Who are you, what do you use MuJoCo for? - value: | - Hi! - - I am a ([graduate / undergrad] student / professor / researcher) at XYZ, I use MuJoCo for my research on ABC. - validations: - required: true - - type: textarea - attributes: - label: My setup - description: MuJoCo / MJX version, API (C or Python), architecture, OS + version. - validations: - required: true - - type: textarea - attributes: - label: My question - description: What you are trying to do, what problem have you encountered? - - type: textarea - attributes: - label: Minimal model and/or code that explain my question - description: Please include a loadable MJCF, not a partial snippet. If your model requires binary assets to load, attach a zip file. - value: | - If you encountered the issue in a complex model, please simplify it as much as possible (while still reproducing the issue). - - Model: -
- minimal XML - - ```XML - - - - - - - - - ``` -
- - Code: - ```python - import mujoco - import mediapy as media - model = mujoco.MjModel.from_xml_string(xml) - data = mujoco.MjData(model) - - with mujoco.Renderer(model) as renderer: - mujoco.mj_forward(model, data) - renderer.update_scene(data) - - media.show_image(renderer.render()) - ``` - validations: - required: false - - type: checkboxes - attributes: - label: Confirmations - options: - - label: I searched the [latest documentation](https://mujoco.readthedocs.io/en/latest/overview.html) thoroughly before posting. - required: true - - label: I searched previous [Issues](https://github.com/google-deepmind/mujoco/issues) and [Discussions](https://github.com/google-deepmind/mujoco/discussions), I am certain this has not been raised before. - required: true - diff --git a/.github/ISSUE_TEMPLATE/Bug-Report.yaml b/.github/ISSUE_TEMPLATE/Bug-Report.yaml deleted file mode 100644 index dbac3604..00000000 --- a/.github/ISSUE_TEMPLATE/Bug-Report.yaml +++ /dev/null @@ -1,92 +0,0 @@ -name: 🐛 Bug Report -description: >- - Please only use this if you're sure you've found a bug. Thanks! 🙏 -labels: bug -body: - - type: textarea - attributes: - label: Intro - description: Who are you, what do you use MuJoCo for? - value: | - Hi! - - I am a ([graduate / undergrad] student / professor / researcher) at XYZ, I use MuJoCo for my research on ABC. - validations: - required: true - - type: textarea - attributes: - label: My setup - description: MuJoCo / MJX version, API (C or Python), architecture, OS + version. - validations: - required: true - - type: textarea - attributes: - label: What's happening? What did you expect? - description: A clear and concise description of the current behaviour vs what you expected. If helpful to understand the issue, attach screenshots/videos. - value: | - Setting `rgba="1 0 0 1"` renders as **green**, I expected it to render as **red**. - - Here is a screen-shot showing a green sphere: - validations: - required: true - - type: textarea - attributes: - label: Steps for reproduction - description: Steps to reproduce the issue. - value: | - 1. Load the model below. - 2. Run the code below. - 3. See green sphere (should be red). - validations: - required: true - - type: textarea - attributes: - label: Minimal model for reproduction - description: Please include a loadable MJCF, not a partial snippet. If your model requires binary assets to load, attach a zip file. - value: | - If you encountered the issue in a complex model, please simplify it as much as possible (while still reproducing the issue). - -
- minimal XML - - ```XML - - - - - - - - - ``` -
- validations: - required: false - - type: textarea - attributes: - label: Code required for reproduction - description: Code required for reproduction of the bug. - value: | - ```python - import mujoco - import mediapy as media - model = mujoco.MjModel.from_xml_string(xml) - data = mujoco.MjData(model) - - with mujoco.Renderer(model) as renderer: - mujoco.mj_forward(model, data) - renderer.update_scene(data) - - media.show_image(renderer.render()) - ``` - validations: - required: false - - type: checkboxes - attributes: - label: Confirmations - options: - - label: I searched the [latest documentation](https://mujoco.readthedocs.io/en/latest/overview.html) thoroughly before posting. - required: true - - label: I searched previous [Issues](https://github.com/google-deepmind/mujoco/issues) and [Discussions](https://github.com/google-deepmind/mujoco/discussions), I am certain this has not been raised before. - required: true - diff --git a/.github/ISSUE_TEMPLATE/Feature-Request.yaml b/.github/ISSUE_TEMPLATE/Feature-Request.yaml deleted file mode 100644 index 5879099a..00000000 --- a/.github/ISSUE_TEMPLATE/Feature-Request.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: 🚀 Feature request -description: Submit a proposal/request for a new MuJoCo feature -labels: enhancement -body: -- type: textarea - attributes: - label: The feature, motivation and pitch - description: > - A clear and concise description of the feature proposal. Please outline the motivation for the proposal. Is your feature request related to a specific problem? e.g., *"I'm working on X and would like Y to be possible"*. If this is related to another GitHub issue, please link here too. - validations: - required: true -- type: textarea - attributes: - label: Alternatives - description: > - A description of any alternative solutions or features you've considered, if any. -- type: textarea - attributes: - label: Additional context - description: > - Add any other context or screenshots about the feature request. -- type: markdown - attributes: - value: > - Thanks for contributing 🎉! - diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index bee58251..00000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: 🙏 Asking for Help - about: Start a new discussion - url: https://github.com/google-deepmind/mujoco/discussions/categories/asking-for-help diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 575df0f3..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,447 +0,0 @@ -# This configuration is used to build and test on GitHub Actions only. -# It is not the same configuration that is used by Google DeepMind to create release binaries. -# The "official" binaries are built with Clang 13 on all platforms, and are linked against libc++ -# on Linux. -# -# We set CMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF here to reduce build time. -# It is highly recommended that this is set to ON for production builds. -# -# Build speed notes: -# * The compiler matrix lives in build_matrix.json. Pull requests build the -# representative "core" subset; pushes to main run the full compiler sweep. -# (See generate_matrix() in build_steps.sh.) -# * Studio/Filament and WASM are NOT built in the main matrix - they are covered -# by the dedicated `studio` and `wasm` jobs below. WASM in particular is built -# with emcc, which ignores the host compiler, so building it per-compiler added -# no coverage. -# * ccache is used to wrap the compiler. PR branches fall back to main's cache, so -# the expensive (and pinned) Filament build is restored rather than recompiled. - -# TODO(matijak): Consider switching Windows to Ninja builds only, this configures slightly faster -# and brings Windows in line with other OSes. Also we wouldn't need to specify the --config option -# in the build step because Ninja doesn't support multiple configurations (unlike MSBuild). - -name: build - -on: - push: - branches: - - main - paths-ignore: - - "doc/**" - - "**/README.md" - pull_request: - paths-ignore: - - "doc/**" - - "**/README.md" - -# Limit the default GITHUB_TOKEN to read-only. No job here writes via the token: -# checkout reads the repo; ccache/cache and upload-artifact use their own backend -# tokens; the chat notification uses a secret webhook. -permissions: - contents: read - -jobs: - # Compute the build matrix based on the event: PRs get the "core" representative - # compiler set, pushes to main get the full sweep. - setup: - name: "setup (compute matrix)" - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.generate.outputs.matrix }} - steps: - - uses: actions/checkout@v6 - - name: Generate build matrix - id: generate - env: - GITHUB_EVENT_NAME: ${{ github.event_name }} - run: bash ./.github/workflows/build_steps.sh generate_matrix - - mujoco: - needs: setup - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.setup.outputs.matrix) }} - - name: "${{ matrix.label }}" - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v6 - - - name: Prepare Linux - if: ${{ runner.os == 'Linux' }} - run: bash ./.github/workflows/build_steps.sh prepare_linux - - - name: Prepare macOS - if: ${{ runner.os == 'macOS' }} - run: brew install ninja - - - uses: actions/setup-python@v6 - with: - python-version: "3.11" - - # uv makes the dependency install much faster, with a cross-run cache. POSIX - # only: Windows stays on pip (it is not a Python-setup bottleneck, and this - # keeps the venv activate fixup path untouched there). - - name: Install uv - if: ${{ runner.os != 'Windows' }} - uses: astral-sh/setup-uv@v8.2.0 - with: - enable-cache: true - cache-dependency-glob: "python/build_requirements*.txt" - - - name: Prepare Python - shell: bash - env: - TMPDIR: ${{ matrix.tmpdir }} - run: bash ./.github/workflows/build_steps.sh prepare_python - - # ccache dramatically speeds up warm rebuilds. The key is the matrix label so - # each compiler gets its own cache; the action's restore-keys let PR branches - # fall back to main's cache. ccache on Windows/MSVC is finicky and Windows - # isn't the bottleneck, so we skip it there. - - name: Setup ccache - if: ${{ runner.os != 'Windows' }} - uses: hendrikmuhs/ccache-action@v1.2.23 - with: - key: ${{ matrix.label }} - max-size: "1.5G" - - - name: Configure MuJoCo - env: - TMPDIR: ${{ matrix.tmpdir }} - CMAKE_ARGS: ${{ matrix.cmake_args }} - run: bash ./.github/workflows/build_steps.sh configure_mujoco - - - name: Upload CMake Configure Log - if: always() - uses: actions/upload-artifact@v7 - with: - name: cmake-configure-log-${{ matrix.label }} - path: build/CMakeFiles/CMakeConfigureLog.yaml - retention-days: 5 - - - name: Build MuJoCo - working-directory: build - env: - CMAKE_BUILD_ARGS: ${{ matrix.cmake_build_args }} - run: bash ../.github/workflows/build_steps.sh build_mujoco - - - name: Test MuJoCo - working-directory: build - run: bash ../.github/workflows/build_steps.sh test_mujoco - - - name: Install MuJoCo - working-directory: build - run: bash ../.github/workflows/build_steps.sh install_mujoco - - - name: Copy plugins (POSIX) - if: ${{ runner.os != 'Windows' }} - working-directory: build - env: - TMPDIR: ${{ matrix.tmpdir }} - run: bash ../.github/workflows/build_steps.sh copy_plugins_posix - - - name: Copy plugins (Windows) - if: ${{ runner.os == 'Windows' }} - working-directory: build - env: - TMPDIR: ${{ matrix.tmpdir }} - run: bash ../.github/workflows/build_steps.sh copy_plugins_window - - - name: Configure samples - working-directory: sample - env: - TMPDIR: ${{ matrix.tmpdir }} - CMAKE_ARGS: ${{ matrix.cmake_args }} - run: bash ../.github/workflows/build_steps.sh configure_samples - - - name: Build samples - working-directory: sample/build - run: cmake --build . --config=Release ${{ matrix.cmake_build_args }} - - - name: Configure simulate - working-directory: simulate - env: - TMPDIR: ${{ matrix.tmpdir }} - CMAKE_ARGS: ${{ matrix.cmake_args }} - run: bash ../.github/workflows/build_steps.sh configure_simulate - - - name: Build simulate - working-directory: simulate/build - env: - CMAKE_BUILD_ARGS: ${{ matrix.cmake_build_args }} - run: bash ../../.github/workflows/build_steps.sh build_simulate - - - name: Make Python sdist - shell: bash - working-directory: python - env: - TMPDIR: ${{ matrix.tmpdir }} - run: bash ../.github/workflows/build_steps.sh make_python_sdist - - - name: Build Python bindings - if: ${{ runner.os != 'Windows' }} - shell: bash - working-directory: python/dist - env: - TMPDIR: ${{ matrix.tmpdir }} - CMAKE_ARGS: ${{ matrix.cmake_args }} - run: bash ../../.github/workflows/build_steps.sh build_python_bindings - - - name: Install Python bindings - if: ${{ runner.os != 'Windows' }} - shell: bash - working-directory: python/dist - env: - TMPDIR: ${{ matrix.tmpdir }} - run: bash ../../.github/workflows/build_steps.sh install_python_bindings - - - name: Test Python bindings - if: ${{ runner.os != 'Windows' }} - shell: bash - env: - MUJOCO_GL: disable - TMPDIR: ${{ matrix.tmpdir }} - run: bash ./.github/workflows/build_steps.sh test_python_bindings - - # MJX (mujoco.mjx) is covered by the dedicated `mjx` job below; it is - # compiler-independent so it does not need to run in every matrix job. - - - name: Notify team chat - shell: bash - env: - GCHAT_API_URL: ${{ secrets.GCHAT_API }} - JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - CHATMSG_AUTHOR_NAME: ${{ github.event.head_commit.author.name }} - CHATMSG_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }} - CHATMSG_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - CHATMSG_JOB_ID: ${{ matrix.label }} - if: failure() && github.ref_name == 'main' && github.event_name == 'push' && env.GCHAT_API_URL != '' - run: bash ./.github/workflows/build_steps.sh notify_team_chat - - # This job quickly determines if MuJoCo Studio is broken. It is the only place - # Filament is compiled in CI, so ccache here is what keeps the long pole short. - studio: - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-24.04 - label: "ubuntu-24.04-clang-18-studio" - cmake_args: >- - -G Ninja - -DCMAKE_C_COMPILER:STRING=clang-18 - -DCMAKE_CXX_COMPILER:STRING=clang++-18 - -DMUJOCO_HARDEN:BOOL=ON - # gcc canary: Filament is compiler-dependent and historically finicky on - # gcc, so keep one gcc Studio build even though the matrix no longer does. - - os: ubuntu-24.04 - label: "ubuntu-24.04-gcc-14-studio" - cmake_args: >- - -G Ninja - -DCMAKE_C_COMPILER:STRING=gcc-14 - -DCMAKE_CXX_COMPILER:STRING=g++-14 - -DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--no-as-needed - - os: windows-2025 - label: "windows-2025-ninja-studio" - cmake_args: >- - -G Ninja - -DCMAKE_SYSTEM_VERSION=10.0.26100.0 - - os: macos-15 - label: "macos-15-arm64-studio" - cmake_args: >- - -G Ninja - -DCMAKE_CXX_FLAGS="-Wno-error=deprecated-declarations" - -DMUJOCO_HARDEN:BOOL=ON - - name: "${{ matrix.label }}" - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v6 - - - name: Prepare Windows (setup MSVC) - if: ${{ runner.os == 'Windows' }} - uses: ilammy/msvc-dev-cmd@v1 - - - name: Prepare Linux - if: ${{ runner.os == 'Linux' }} - run: bash ./.github/workflows/build_steps.sh prepare_linux - - # Key the cache on the Filament pin: hashing cmake/third_party_deps/filament.cmake - # captures BOTH the pinned commit hash and the FILAMENT_* build flags, so bumping - # either starts a fresh cache namespace instead of restoring stale artifacts. - # (Correctness does not depend on this: ccache is content-addressed on the full - # compiler invocation, so changing any build flag forces a recompile regardless.) - - name: Setup ccache - if: ${{ runner.os != 'Windows' }} - uses: hendrikmuhs/ccache-action@v1.2.23 - with: - key: ${{ matrix.label }}-filament-${{ hashFiles('cmake/third_party_deps/filament.cmake') }} - restore-keys: ${{ matrix.label }}-filament- - max-size: "2.0G" - - - name: Configure Studio - env: - CMAKE_ARGS: ${{ matrix.cmake_args }} - run: bash ./.github/workflows/build_steps.sh configure_studio - - - name: Build Studio - run: bash ./.github/workflows/build_steps.sh build_studio - - - name: Notify team chat - shell: bash - env: - GCHAT_API_URL: ${{ secrets.GCHAT_API }} - JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - CHATMSG_AUTHOR_NAME: ${{ github.event.head_commit.author.name }} - CHATMSG_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }} - CHATMSG_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - CHATMSG_JOB_ID: ${{ matrix.label }} - if: failure() && github.ref_name == 'main' && github.event_name == 'push' && env.GCHAT_API_URL != '' - run: bash ./.github/workflows/build_steps.sh notify_team_chat - - - # This job quickly determines if WASM bindings are broken. - wasm: - name: "ubuntu-24.04-clang-18-wasm" - runs-on: ubuntu-24.04 - env: - label: "ubuntu-24.04-clang-18-wasm" - cmake_args: >- - -G Ninja - -DCMAKE_C_COMPILER:STRING=clang-18 - -DCMAKE_CXX_COMPILER:STRING=clang++-18 - -DMUJOCO_HARDEN:BOOL=ON - steps: - - uses: actions/checkout@v6 - - - name: Setup Node.js for WASM bindings - uses: actions/setup-node@v6 - with: - node-version: '24.x' - - - name: Prepare Linux - if: ${{ runner.os == 'Linux' }} - run: bash ./.github/workflows/build_steps.sh prepare_linux - - - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1.2.23 - with: - key: ${{ env.label }} - max-size: "1.5G" - - # For convenience run multiple build_steps functions in a single step. - - name: Prepare, Build and Test WASM bindings - env: - CMAKE_ARGS: ${{ env.cmake_args }} - run: | - bash ./.github/workflows/build_steps.sh npm_ci - bash ./.github/workflows/build_steps.sh setup_emsdk - bash ./.github/workflows/build_steps.sh build_test_wasm - - - name: Notify team chat - shell: bash - env: - GCHAT_API_URL: ${{ secrets.GCHAT_API }} - JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - CHATMSG_AUTHOR_NAME: ${{ github.event.head_commit.author.name }} - CHATMSG_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }} - CHATMSG_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - CHATMSG_JOB_ID: ${{ env.label }} - if: failure() && github.ref_name == 'main' && github.event_name == 'push' && env.GCHAT_API_URL != '' - run: bash ./.github/workflows/build_steps.sh notify_team_chat - - - # MJX (mujoco.mjx) is pure JAX/XLA and compiler-independent: it imports the - # mujoco Python package only as a reference, so its tests run once here instead - # of in every matrix job. MuJoCo is built WITHOUT the C++ test suite (MJX does - # not need it) to keep the build lean. - mjx: - name: "ubuntu-24.04-clang-18-mjx" - runs-on: ubuntu-24.04 - env: - TMPDIR: "/tmp" - CMAKE_ARGS: >- - -G Ninja - -DCMAKE_C_COMPILER:STRING=clang-18 - -DCMAKE_CXX_COMPILER:STRING=clang++-18 - -DMUJOCO_HARDEN:BOOL=ON - -DMUJOCO_BUILD_TESTS:BOOL=OFF - steps: - - uses: actions/checkout@v6 - - - name: Prepare Linux - run: bash ./.github/workflows/build_steps.sh prepare_linux - - - uses: actions/setup-python@v6 - with: - python-version: "3.11" - - - name: Install uv - uses: astral-sh/setup-uv@v8.2.0 - with: - enable-cache: true - cache-dependency-glob: "python/build_requirements*.txt" - - - name: Prepare Python - run: bash ./.github/workflows/build_steps.sh prepare_python - - - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1.2.23 - with: - key: ubuntu-24.04-clang-18-mjx - max-size: "1.0G" - - - name: Configure MuJoCo - run: bash ./.github/workflows/build_steps.sh configure_mujoco - - - name: Build MuJoCo - working-directory: build - run: bash ../.github/workflows/build_steps.sh build_mujoco - - - name: Install MuJoCo - working-directory: build - run: bash ../.github/workflows/build_steps.sh install_mujoco - - - name: Copy plugins - working-directory: build - run: bash ../.github/workflows/build_steps.sh copy_plugins_posix - - - name: Make Python sdist - working-directory: python - run: bash ../.github/workflows/build_steps.sh make_python_sdist - - - name: Build Python bindings - working-directory: python/dist - run: bash ../../.github/workflows/build_steps.sh build_python_bindings - - - name: Install Python bindings - working-directory: python/dist - run: bash ../../.github/workflows/build_steps.sh install_python_bindings - - - name: Package MJX - working-directory: mjx - run: bash ../.github/workflows/build_steps.sh package_mjx - - - name: Install MJX - working-directory: mjx - run: bash ../.github/workflows/build_steps.sh install_mjx - - - name: Test MJX - working-directory: mjx - run: bash ../.github/workflows/build_steps.sh test_mjx - - - name: Notify team chat - shell: bash - env: - GCHAT_API_URL: ${{ secrets.GCHAT_API }} - JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - CHATMSG_AUTHOR_NAME: ${{ github.event.head_commit.author.name }} - CHATMSG_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }} - CHATMSG_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - CHATMSG_JOB_ID: "ubuntu-24.04-clang-18-mjx" - if: failure() && github.ref_name == 'main' && github.event_name == 'push' && env.GCHAT_API_URL != '' - run: bash ./.github/workflows/build_steps.sh notify_team_chat diff --git a/.github/workflows/build_matrix.json b/.github/workflows/build_matrix.json deleted file mode 100644 index 03f25a19..00000000 --- a/.github/workflows/build_matrix.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "comment": "Build matrix for build.yml. 'tier' controls when an entry runs: 'core' runs on every pull_request and push; 'extended' runs only on push to main (full compiler sweep). See generate_matrix() in build_steps.sh.", - "include": [ - { - "os": "ubuntu-24.04", - "label": "ubuntu-24.04-gcc-14", - "cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=gcc-14 -DCMAKE_CXX_COMPILER:STRING=g++-14 -DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--no-as-needed", - "tmpdir": "/tmp", - "tier": "core" - }, - { - "os": "ubuntu-24.04", - "label": "ubuntu-24.04-gcc-13", - "cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=gcc-13 -DCMAKE_CXX_COMPILER:STRING=g++-13 -DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--no-as-needed", - "tmpdir": "/tmp", - "tier": "extended" - }, - { - "os": "ubuntu-22.04", - "label": "ubuntu-22.04-gcc-12", - "cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=gcc-12 -DCMAKE_CXX_COMPILER:STRING=g++-12 -DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--no-as-needed", - "tmpdir": "/tmp", - "tier": "core" - }, - { - "os": "ubuntu-24.04", - "label": "ubuntu-24.04-clang-18", - "cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=clang-18 -DCMAKE_CXX_COMPILER:STRING=clang++-18 -DMUJOCO_HARDEN:BOOL=ON", - "tmpdir": "/tmp", - "tier": "core" - }, - { - "os": "ubuntu-24.04", - "label": "ubuntu-24.04-clang-17", - "cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=clang-17 -DCMAKE_CXX_COMPILER:STRING=clang++-17 -DMUJOCO_HARDEN:BOOL=ON", - "tmpdir": "/tmp", - "tier": "extended" - }, - { - "os": "ubuntu-24.04", - "label": "ubuntu-24.04-clang-16", - "cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=clang-16 -DCMAKE_CXX_COMPILER:STRING=clang++-16 -DMUJOCO_HARDEN:BOOL=ON", - "tmpdir": "/tmp", - "tier": "extended" - }, - { - "os": "ubuntu-22.04", - "label": "ubuntu-22.04-clang-15", - "cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=clang-15 -DCMAKE_CXX_COMPILER:STRING=clang++-15 -DMUJOCO_HARDEN:BOOL=ON", - "tmpdir": "/tmp", - "tier": "extended" - }, - { - "os": "macos-15", - "label": "macos-15-arm64", - "cmake_args": "-G Ninja -DMUJOCO_HARDEN:BOOL=ON", - "tmpdir": "/tmp", - "tier": "core" - }, - { - "os": "windows-2025", - "label": "windows-2025", - "cmake_args": "-DCMAKE_SYSTEM_VERSION=\"10.0.26100.0\"", - "cmake_build_args": "-- -m", - "tmpdir": "C:/Temp", - "tier": "core" - } - ] -} diff --git a/.github/workflows/build_steps.sh b/.github/workflows/build_steps.sh deleted file mode 100755 index f10cebe4..00000000 --- a/.github/workflows/build_steps.sh +++ /dev/null @@ -1,430 +0,0 @@ -#!/bin/bash -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# TODO(matijak): Make all cmake commands run from the top-level directory, and -# consider making the builds parallel. - - -# Wrap the compiler with ccache when it is available (set up by ccache-action in -# CI). This makes warm rebuilds - including the expensive, pinned Filament build - -# much faster. ccache is content-addressed on the full compiler invocation, so -# changing a flag or source forces a recompile: a stale object is never reused. -# Guarded by `command -v` so the script still works locally without ccache. -CCACHE_ARGS="" -if command -v ccache >/dev/null 2>&1; then - CCACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" -fi - - -# Emit the build matrix for build.yml as a step output. On pull_request we run -# only the representative "core" compiler set; on push (e.g. to main) we run the -# full compiler sweep. Tiers are defined in build_matrix.json. -generate_matrix() { - echo "Generating build matrix for event '${GITHUB_EVENT_NAME}'..." - local file=".github/workflows/build_matrix.json" - local matrix - if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then - matrix="$(jq -c '{include: [.include[] | select(.tier == "core") | del(.tier)]}' "${file}")" - else - matrix="$(jq -c '{include: [.include[] | del(.tier)]}' "${file}")" - fi - echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}" - echo "${matrix}" | jq . -} - - -prepare_linux() { - echo "Preparing Linux..." - sudo apt-get update && sudo apt-get install \ - libgl1-mesa-dev \ - libwayland-dev \ - libxinerama-dev \ - libxcursor-dev \ - libxkbcommon-dev \ - libxrandr-dev \ - libxi-dev \ - ninja-build -} - - -prepare_python() { - echo "Preparing Python..." - repo="${PWD}" - pushd "${TMPDIR}" > /dev/null - python -m venv venv - if [[ $RUNNER_OS == "Windows" ]]; then - mkdir venv/bin - fixpath="$(s="$(cat venv/Scripts/activate | grep VIRTUAL_ENV=)"; echo "${s:13:-1}")" - sed -i "s#$(printf "%q" "${fixpath}")#$(cygpath "${fixpath}")#g" venv/Scripts/activate - ln -s ../Scripts/activate venv/bin/activate - fi - source venv/bin/activate - # Install build deps with uv when available (set up by setup-uv in CI on - # POSIX) - much faster than pip. Fall back to pip otherwise (e.g. Windows, - # local dev). The venv is still created by `python -m venv`, so pip stays - # available for later steps (pip wheel / python -m build). - if command -v uv > /dev/null 2>&1; then - uv pip install --require-hashes -r "${repo}/python/build_requirements.txt" - uv pip install --require-hashes -r "${repo}/python/build_requirements_usd.txt" - else - python -m pip install --upgrade --require-hashes -r "${repo}/python/build_requirements.txt" - python -m pip install --upgrade --require-hashes -r "${repo}/python/build_requirements_usd.txt" - fi - popd > /dev/null -} - - -npm_ci() { - echo "Installing NPM dependencies for WASM bindings..." - pushd wasm - npm ci - popd -} - - -setup_emsdk() { - echo "Setting up Emscripten..." - git clone https://github.com/emscripten-core/emsdk.git - ./emsdk/emsdk install 4.0.10 - ./emsdk/emsdk activate 4.0.10 - # Force installing emscripten's typescript dependencies. This is a - # workaround for the github update to a newer typescript, which gives an - # error on the deprecated `--outFile` flag. - pushd emsdk/upstream/emscripten - npm i - popd -} - - -configure_mujoco() { - echo "Configuring MuJoCo..." - # Disable IPO/LTO to cut build time. Skip this on Windows: turning off MSVC's - # whole-program optimization (/GL) exposes a latent heap corruption in - # SetConstTest.SleepingNotAllowed (a real bug worth a separate investigation), - # and Windows build time is not a CI bottleneck. - local ipo_off="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF" - if [[ "${RUNNER_OS}" == "Windows" ]]; then - ipo_off="" - fi - mkdir build && - cd build && - cmake .. \ - -DCMAKE_BUILD_TYPE:STRING=Release \ - ${ipo_off} \ - -DCMAKE_INSTALL_PREFIX:STRING=${TMPDIR}/mujoco_install \ - -DMUJOCO_BUILD_EXAMPLES:BOOL=OFF \ - ${CCACHE_ARGS} \ - ${CMAKE_ARGS} -} - - -build_mujoco() { - echo "Building MuJoCo..." - cmake --build . --config=Release ${CMAKE_BUILD_ARGS} -} - - -test_mujoco() { - echo "Testing MuJoCo..." - # ctest defaults to serial. The suite is ~1650 independent tests that use - # unique temp files (mkstemp / testing::TempDir) and declare no RUN_SERIAL / - # RESOURCE_LOCK, so running them in parallel is safe and ~2x faster on POSIX. - # Windows is kept serial conservatively: parallel-safety on the Windows file - # system is unverified and its test time is not a CI bottleneck. - if [[ "${RUNNER_OS}" == "Windows" ]]; then - ctest -C Release --output-on-failure . - else - local ncpu - ncpu="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo "${NUMBER_OF_PROCESSORS:-2}")" - ctest -C Release --output-on-failure --parallel "${ncpu}" . - fi -} - - -install_mujoco() { - echo "Installing MuJoCo..." - cmake --install . -} - - -copy_plugins_posix() { - echo "Copying plugins..." - mkdir -p ${TMPDIR}/mujoco_install/mujoco_plugin && - cp lib/libactuator.* ${TMPDIR}/mujoco_install/mujoco_plugin && - cp lib/libelasticity.* ${TMPDIR}/mujoco_install/mujoco_plugin && - cp lib/libsensor.* ${TMPDIR}/mujoco_install/mujoco_plugin && - cp lib/libsdf_plugin.* ${TMPDIR}/mujoco_install/mujoco_plugin -} - - -copy_plugins_window() { - echo "Copying plugins..." - mkdir -p ${TMPDIR}/mujoco_install/mujoco_plugin && - cp bin/Release/actuator.dll ${TMPDIR}/mujoco_install/mujoco_plugin && - cp bin/Release/elasticity.dll ${TMPDIR}/mujoco_install/mujoco_plugin && - cp bin/Release/sensor.dll ${TMPDIR}/mujoco_install/mujoco_plugin -} - - -configure_samples() { - echo "Configuring samples..." - # Samples are tiny, so they keep the default IPO/LTO: disabling it saves no - # meaningful build time and would expose the same gcc -Werror false positives - # that -O3-without-LTO triggers (see configure_mujoco). - mkdir build && - cd build && - cmake .. \ - -DCMAKE_BUILD_TYPE:STRING=Release \ - -Dmujoco_ROOT:STRING=${TMPDIR}/mujoco_install \ - ${CCACHE_ARGS} \ - ${CMAKE_ARGS} -} - - -configure_simulate() { - echo "Configuring simulate..." - # See configure_samples: keep the default IPO/LTO for this small build. - mkdir build && - cd build && - cmake .. \ - -DCMAKE_BUILD_TYPE:STRING=Release \ - -Dmujoco_ROOT:STRING=${TMPDIR}/mujoco_install \ - ${CCACHE_ARGS} \ - ${CMAKE_ARGS} -} - - -build_simulate() { - echo "Building simulate..." - cmake --build . --config=Release ${CMAKE_BUILD_ARGS} -} - - -configure_studio() { - echo "Configuring Studio..." - cmake -B build \ - -DCMAKE_BUILD_TYPE:STRING=Release \ - -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF \ - -DUSE_STATIC_LIBCXX=OFF \ - -DBUILD_SHARED_LIBS=OFF \ - -DMUJOCO_BUILD_EXAMPLES=OFF \ - -DMUJOCO_BUILD_SIMULATE=OFF \ - -DMUJOCO_BUILD_STUDIO=ON \ - -DMUJOCO_BUILD_TESTS=OFF \ - -DMUJOCO_TEST_PYTHON_UTIL=OFF \ - -DMUJOCO_WITH_USD=OFF \ - -DMUJOCO_USE_FILAMENT=ON \ - ${CCACHE_ARGS} \ - ${CMAKE_ARGS} - echo "Configuring Studio... DONE" -} - - -build_studio() { - echo "Building Studio..." - cmake --build build --config=Release --target mujoco_studio --parallel - echo "Building Studio... DONE" -} - - -make_python_sdist() { - echo "Making Python sdist..." - source ${TMPDIR}/venv/bin/activate && - ./make_sdist.sh -} - - -build_python_bindings() { - echo "Building Python bindings..." - source ${TMPDIR}/venv/bin/activate - # pip unpacks the sdist into a randomized temp dir every run, so the absolute - # source/include paths differ each time and defeat ccache (0% hit, full - # recompile). CCACHE_BASEDIR rewrites absolute paths under it to paths relative - # to the (also-in-temp) build cwd, cancelling the random component so objects - # hash identically across runs. CCACHE_SLOPPINESS ignores timestamp/path noise. - # - # Do NOT add system_headers here: CMake adds the imported mujoco target's - # include dir (MUJOCO_PATH/include) as -isystem, so ccache would treat the - # public MuJoCo headers as system headers and skip hashing them. A change that - # lives only in those headers (a new mjData field, a new enum value) would then - # go undetected and ccache would reuse an object compiled against the old struct - # layout, producing an ABI-mismatched binding (wrong field offsets, stale - # mjNENABLE, signature mismatch). The mtime/ctime flags are kept: they handle the - # temp-dir churn without affecting header content detection. - export CCACHE_BASEDIR="${TMPDIR}" - export CCACHE_SLOPPINESS="time_macros,include_file_mtime,include_file_ctime,pch_defines,locale" - MUJOCO_PATH="${TMPDIR}/mujoco_install" \ - MUJOCO_PLUGIN_PATH="${TMPDIR}/mujoco_install/mujoco_plugin" \ - MUJOCO_CMAKE_ARGS="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF ${CCACHE_ARGS} ${CMAKE_ARGS}" \ - pip wheel -v --no-deps mujoco-*.tar.gz -} - - -install_python_bindings() { - echo "Installing Python bindings..." - source ${TMPDIR}/venv/bin/activate && - pip install --no-index mujoco-*.whl -} - - -test_python_bindings() { - echo "Testing Python bindings..." - source ${TMPDIR}/venv/bin/activate && - pytest -v --pyargs mujoco -} - - -build_test_wasm() { - echo "Building and testing WASM bindings..." - source emsdk/emsdk_env.sh - export PATH="$(pwd)/node_modules/.bin:$PATH" - echo "Build MuJoCo with Emscripten (Multi-Threaded)..." - emcmake cmake -B build_wasm_mt \ - -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF \ - -DMUJOCO_WASM_THREADS=ON \ - ${CCACHE_ARGS} \ - $WASM_CMAKE_ARGS - cmake --build build_wasm_mt --parallel $(nproc) - - echo "Run bindings tests for Multi-Threaded version..." - npm run test --prefix ./wasm - - echo "Moving Multi-Thread version under mt subfolder..." - mkdir -p wasm/dist/mt - mv wasm/dist/mujoco.* wasm/dist/mt/ - - echo "Build MuJoCo with Emscripten (Single-Threaded)..." - emcmake cmake -B build_wasm_st \ - -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF \ - -DMUJOCO_WASM_THREADS=OFF \ - ${CCACHE_ARGS} \ - $WASM_CMAKE_ARGS - cmake --build build_wasm_st --parallel $(nproc) - - echo "Run bindings tests for Single-Threaded version..." - npm run test --prefix ./wasm -} - -package_wasm() { - echo "Publishing WASM bindings..." - cp wasm/package.npm.json wasm/dist/package.json - cp wasm/README.md wasm/dist/README.md - VERSION="${VERSION:-${GITHUB_REF#refs/tags/}}" - npm --prefix wasm/dist version "${VERSION}" --no-git-tag-version - npm pack --dry-run ./wasm/dist - npm publish ./wasm/dist --access public --provenance -} - - -package_mjx() { - echo "Packaging MJX..." - source ${TMPDIR}/venv/bin/activate && - python -m build . -} - - -install_mjx() { - echo "Installing MJX..." - source ${TMPDIR}/venv/bin/activate - # The MJX requirements (jax, jaxlib, scipy, ...) are a big install; use uv when - # available. Keep pip for the local --no-index wheel. - if command -v uv > /dev/null 2>&1; then - uv pip install --require-hashes -r requirements.txt - else - pip install --require-hashes -r requirements.txt - fi - pip install --no-index dist/mujoco_mjx-*.whl -} - - -test_mjx() { - echo "Testing MJX..." - source ${TMPDIR}/venv/bin/activate && - pytest -n auto -v -k 'not IntegrationTest' --pyargs mujoco.mjx -} - - -notify_team_chat() { - CHATMSG="$(cat <<-'EOF' | python3 -import json -import os -env = lambda x: os.getenv(x, '') -data = dict( - result=env('JOB_URL'), - job=env('CHATMSG_JOB_ID'), - commit=env('GITHUB_SHA')[:6], - name=env('CHATMSG_AUTHOR_NAME').replace('```', ''), - email=env('CHATMSG_AUTHOR_EMAIL'), - msg=env('CHATMSG_COMMIT_MESSAGE').replace('```', '') -) -text = '<{result}|*FAILURE*>: job `{job}` commit `{commit}`\n```Author: {name} <{email}>\n\n{msg}```'.format(**data) -print(json.dumps({'text' : text})) -EOF -)" && - - curl "$GCHAT_API_URL&threadKey=$GITHUB_SHA&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD" \ - -X POST \ - -H "Content-Type: application/json" \ - --data-raw "${CHATMSG}" -} - - -build_mujoco_live() { - echo "Setting up Emscripten SDK..." - source emsdk/emsdk_env.sh - - echo "Building Filament tools, targeting host platform..." - cmake -S . -B build_host -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DUSE_STATIC_LIBCXX=OFF \ - -DMUJOCO_BUILD_STUDIO=ON \ - -DMUJOCO_USE_FILAMENT=ON \ - -DMUJOCO_BUILD_TESTS=OFF \ - -DMUJOCO_BUILD_EXAMPLES=OFF \ - -DMUJOCO_BUILD_SIMULATE=OFF - cmake --build build_host --target matc resgen cmgen mujoco_filament_assets -j$(nproc) - - echo "Building WASM app..." - emcmake cmake -S . -B build_wasm -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DMUJOCO_BUILD_STUDIO=ON \ - -DMUJOCO_USE_FILAMENT=ON \ - -DMUJOCO_BUILD_TESTS_WASM=OFF \ - -DMUJOCO_NATIVE_BUILD_DIR=$(pwd)/build_host - cmake --build build_wasm --target mujoco_studio -j$(nproc) -} - - -# Discover functions defined in this script by finding identifiers followed by -# "()" and capturing the identifier as a valid function name. -VALID_FUNCTIONS=() -while IFS= read -r func_name; do - VALID_FUNCTIONS+=("$func_name") -done < <(grep -E '^[[:alnum:]_]+\(\)' "$0" | sed 's/().*$//') - -# Exit with an error if the requested function is not found. -if [[ ! " ${VALID_FUNCTIONS[*]} " =~ " ${1} " ]]; then - echo "Usage: $0 {$(IFS='|'; echo "${VALID_FUNCTIONS[*]}")}, got '$1'" - exit 1 -fi - -# Set options to print the commands being run, and cause the script to exit with -# an error code if any command fails. Note we do this just before executing -# the requested function to avoid cluttering the output with the above command -# discovery code. -set -xe - -# Execute the requested function. -"$1" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ba76d32d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: web-platform-ci + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + quality: + name: TypeScript、Lint、Unit、Build + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: 24 + cache: npm + - run: npm ci + - run: npm run check + + e2e: + name: Playwright E2E + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: 24 + cache: npm + - run: npm ci + - run: npm run build + - run: npm run test:e2e diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 5432ac60..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Run pre-commit hooks on files changed in the PR only. -name: lint - -on: - pull_request: - -permissions: - contents: read - -jobs: - pre-commit: - name: pre-commit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - uses: actions/setup-python@v6 - with: - python-version: "3.12" - - uses: pre-commit/action@v3.0.1 - with: - extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/live.yml b/.github/workflows/live.yml deleted file mode 100644 index e8c6e4cb..00000000 --- a/.github/workflows/live.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: live - -on: - push: - branches: - - live - -permissions: - contents: read - pages: write - id-token: write - -jobs: - build-and-upload-artifacts: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v6 - - - name: Prepare Linux - run: bash ./.github/workflows/build_steps.sh prepare_linux - - - name: Setup Emscripten - run: bash ./.github/workflows/build_steps.sh setup_emsdk - - - name: Build MuJoCo Live - env: - CC: clang-18 - CXX: clang++-18 - run: bash ./.github/workflows/build_steps.sh build_mujoco_live - - - name: Prepare files for GitHub Pages - run: | - mkdir -p dist/bin - cp -r build_wasm/bin/* dist/bin/ - cp src/experimental/studio/live.html dist/index.html - cp src/experimental/studio/live.css dist/live.css - cp src/experimental/studio/live.js dist/live.js - cp src/experimental/studio/favicon.ico dist/favicon.ico - COMMIT_HASH=$(git rev-parse HEAD 2>/dev/null || true) - if [ -n "$COMMIT_HASH" ]; then - sed -i "s/__COMMIT_HASH_PLACEHOLDER__/$COMMIT_HASH/g" dist/index.html - fi - - - name: Upload GitHub Pages artifacts - uses: actions/upload-pages-artifact@v3 - with: - path: dist - - deploy-pages: - needs: build-and-upload-artifacts - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 diff --git a/.github/workflows/publish-wasm.yml b/.github/workflows/publish-wasm.yml deleted file mode 100644 index e840a67c..00000000 --- a/.github/workflows/publish-wasm.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: publish-wasm - -on: - push: - tags: - - '[0-9]*.[0-9]*.[0-9]*' - - workflow_dispatch: - inputs: - tag_version: - description: 'Release tag version to deploy' - required: true - default: '0.0.0' - -permissions: - id-token: write - contents: read - -jobs: - publish: - name: Publish MuJoCo WASM package - runs-on: ubuntu-24.04 - - env: - VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_version || github.ref_name }} - - steps: - - uses: actions/checkout@v6 - - - name: Setup Node.js for WASM bindings - uses: actions/setup-node@v6 - with: - node-version: '24.x' - - - name: Prepare Linux - run: bash ./.github/workflows/build_steps.sh prepare_linux - - - name: Install NPM Dependencies for WASM bindings - run: bash ./.github/workflows/build_steps.sh npm_ci - - - name: Setup Emscripten for WASM bindings - run: bash ./.github/workflows/build_steps.sh setup_emsdk - - - name: Build WASM bindings - run: bash ./.github/workflows/build_steps.sh build_test_wasm - - - name: Package WASM bindings - env: - VERSION: ${{ env.VERSION }} - run: bash ./.github/workflows/build_steps.sh package_wasm diff --git a/.github/workflows/update_live.yml b/.github/workflows/update_live.yml deleted file mode 100644 index 4f102474..00000000 --- a/.github/workflows/update_live.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: update-live - -on: - release: - types: [published] # Trigger when publishing releases ... - workflow_dispatch: # or manually (updates to main HEAD). - -permissions: - contents: write - -jobs: - merge-branch: - runs-on: ubuntu-latest - steps: - - name: Checkout MuJoCo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Fast-forward the live branch - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - git fetch origin main:refs/remotes/origin/main - REF_NAME="origin/main" - else - REF_NAME="${{ github.ref_name }}" - fi - git push origin ${REF_NAME}:refs/heads/live diff --git a/.gitignore b/.gitignore index e7fd79e4..7cdc71b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,49 +1,29 @@ -# Don't commit binaries -*.a -*.asm -*.dll -*.dylib -*.exe -*.lib -*.out -*.o -*.so -*.so.* +# Node / frontend +node_modules/ +web-platform-dist/ +coverage/ +test-results/ +playwright-report/ +web_platform/test-results/ +web_platform/playwright-report/ +web_platform/node_modules/.vite/ +*.tsbuildinfo -# Exclude editor config -.vscode/ -.vs/ - -# Exclude temporary folders -*.egg-info/ -build/ -build_cmake/ -python/dist/ -doc/_build - -# Exclude macOS folder attributes -.DS_Store - -# Exclude macOS Info.framework.plist -Info.framework.plist - -# Python byte-compiled / optimized / DLL files +# Python +.venv/ __pycache__/ *.py[cod] -*$py.class +*.egg-info/ -# MuJoCo's default log file -MUJOCO_LOG.TXT - -# Clang cache +# Local build and cache directories +build/ .cache/ -# JavaScript bindings build -wasm/**/dist/ -wasm/web-platform-dist/ -wasm/test-results/ -wasm/web_platform/test-results/ -wasm/web_platform/node_modules/.vite/ -**/node_modules/ +# Editors and operating systems +.vscode/ +.vs/ +.DS_Store -.venv/ +# Runtime logs +*.log +MUJOCO_LOG.TXT diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 97758ecd..00000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,7 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 - hooks: - - id: trailing-whitespace - exclude: \.patch$ - - id: end-of-file-fixer diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index 89ef662f..00000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,49 +0,0 @@ -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -version: 2 - -# TODO(robotics-simulation): pdf format fails to build on readthedocs -# formats: -# - pdf - -build: - os: ubuntu-24.04 - tools: - python: "3.12" - apt_packages: - - libgl-dev - jobs: - create_environment: - # install uv - - asdf plugin add uv - - asdf install uv latest - - asdf global uv latest - - uv venv $READTHEDOCS_VIRTUALENV_PATH - # install doc requirements - - | - UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH \ - uv pip install \ - -r doc/requirements.txt \ - pip setuptools absl-py - # generate and install doc-only mujoco stubs (no C build required) - - python doc/make_mujoco_stubs.py python/mujoco_doc - - | - UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH \ - uv pip install --no-deps python/mujoco_doc - # install mjx and mujoco_warp (mujoco dep satisfied by stubs above) - - UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv pip install -e mjx - - | - find mjx/mujoco/mjx/third_party/mujoco_warp -type f -exec \ - sed -i 's/mujoco\.mjx\.third_party\.mujoco_warp/mujoco_warp/g' {} \; - - python doc/mjwarp/update_types.py mjx/mujoco/mjx/third_party/mujoco_warp/_src/types.py - - | - UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH \ - uv pip install mjx/mujoco/mjx/third_party/mujoco_warp - install: - - "true" # skip default install - -sphinx: - builder: html - configuration: doc/conf.py - fail_on_warning: false diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 317301fa..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,358 +0,0 @@ -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MUJOCO_CMAKE_MIN_REQ "3.16") -cmake_minimum_required(VERSION ${MUJOCO_CMAKE_MIN_REQ}) - -# Make CMAKE_C_VISIBILITY_PRESET work properly. -set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) -# INTERPROCEDURAL_OPTIMIZATION is enforced when enabled. -set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) -# Default to GLVND if available. -set(CMAKE_POLICY_DEFAULT_CMP0072 NEW) -# Avoid BUILD_SHARED_LIBS getting overridden by an option() in ccd. -set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) - -# This line has to appear before 'PROJECT' in order to be able to disable incremental linking -set(MSVC_INCREMENTAL_DEFAULT ON) - -project( - mujoco - VERSION 3.12.0 - DESCRIPTION "MuJoCo Physics Simulator" - HOMEPAGE_URL "https://mujoco.org" -) - -enable_language(C) -enable_language(CXX) - -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") - -if(NOT EMSCRIPTEN) - option(MUJOCO_BUILD_EXAMPLES "Build samples for MuJoCo" ON) - option(MUJOCO_BUILD_SIMULATE "Build simulate library for MuJoCo" ON) - option(MUJOCO_BUILD_STUDIO "Build studio library for MuJoCo" OFF) - option(MUJOCO_BUILD_TESTS "Build tests for MuJoCo" ON) - option(MUJOCO_TEST_PYTHON_UTIL "Build and test utility libraries for Python bindings" ON) - option(MUJOCO_WITH_USD "Build with OpenUSD" OFF) - option(MUJOCO_USE_FILAMENT "Use filament rendering" OFF) - # Allows filament renderer to be used with mjr API; disables src/render to prevent conflicts. - option(MUJOCO_USE_FILAMENT_MJR_COMPAT "Use filament mjr compatibility layer" OFF) -endif() - -if(EMSCRIPTEN) - option(MUJOCO_BUILD_TESTS_WASM "Build tests for WASM bindings" ON) - option(MUJOCO_BUILD_STUDIO "Build studio for MuJoCo (WASM)" OFF) - option(MUJOCO_USE_FILAMENT "Use filament rendering" OFF) - option(MUJOCO_WASM_THREADS "Build with multi-threading support" ON) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -O3 -fexceptions") - if(MUJOCO_WASM_THREADS) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") - endif() - - # Filament uses the WASM variable (not EMSCRIPTEN) to identify web builds. - # Without this, it falls into the LINUX path and tries to compile with - # futex, X11, Vulkan, etc. - if(MUJOCO_USE_FILAMENT) - set(WASM ON CACHE BOOL "Filament WASM mode" FORCE) - endif() - - # Automatically generate host tool imports for Filament cross-compilation. - # When WASM is true, Filament hardcodes the path to: - # ${FILAMENT}/${IMPORT_EXECUTABLES_DIR}/ImportExecutables-Release.cmake - # So we write our file with that exact name and set IMPORT_EXECUTABLES_DIR - # to point at CMAKE_BINARY_DIR (which is ../../ relative to filament-src). - set(MUJOCO_NATIVE_BUILD_DIR "${PROJECT_SOURCE_DIR}/build-host" CACHE PATH "Path to native build directory containing host tools") - find_program(MATC_EXE matc PATHS "${MUJOCO_NATIVE_BUILD_DIR}/bin" NO_DEFAULT_PATH) - find_program(RESGEN_EXE resgen PATHS "${MUJOCO_NATIVE_BUILD_DIR}/bin" NO_DEFAULT_PATH) - find_program(CMGEN_EXE cmgen PATHS "${MUJOCO_NATIVE_BUILD_DIR}/bin" NO_DEFAULT_PATH) - - if(MATC_EXE AND RESGEN_EXE AND CMGEN_EXE) - message(STATUS "Found host tools in ${MUJOCO_NATIVE_BUILD_DIR}/bin") - set(IMPORT_EXECUTABLES_FILE "${CMAKE_BINARY_DIR}/ImportExecutables-Release.cmake") - file(WRITE "${IMPORT_EXECUTABLES_FILE}" - "add_executable(matc IMPORTED)\n" - "set_property(TARGET matc PROPERTY IMPORTED_LOCATION \"${MATC_EXE}\")\n" - "add_executable(resgen IMPORTED)\n" - "set_property(TARGET resgen PROPERTY IMPORTED_LOCATION \"${RESGEN_EXE}\")\n" - "add_executable(cmgen IMPORTED)\n" - "set_property(TARGET cmgen PROPERTY IMPORTED_LOCATION \"${CMGEN_EXE}\")\n" - ) - # Filament's WASM path resolves: ${FILAMENT}/${IMPORT_EXECUTABLES_DIR}/ImportExecutables-Release.cmake - # FILAMENT = _deps/filament-src, so ../../ resolves to CMAKE_BINARY_DIR. - set(IMPORT_EXECUTABLES_DIR "../../" CACHE PATH "" FORCE) - else() - message(WARNING "Host tools (matc, resgen, cmgen) not found in ${MUJOCO_NATIVE_BUILD_DIR}/bin. WASM build of Studio might fail.") - endif() -endif() - -if(APPLE AND (MUJOCO_BUILD_EXAMPLES OR MUJOCO_BUILD_SIMULATE OR MUJOCO_USE_FILAMENT)) - # NOTE: OBJC* languages are proactively enabled when using Filament to - # workaround a CMake bug triggered by Filament recently adding: - # set(EXTRA_LANGS OBJC OBJCXX) - # See also: https://gitlab.kitware.com/cmake/cmake/-/work_items/24104 - enable_language(OBJC) - enable_language(OBJCXX) -endif() - -include(MujocoOptions) -include(MujocoMacOS) -include(MujocoDependencies) - -set(MUJOCO_HEADERS - include/mujoco/mjassert.h - include/mujoco/mjdata.h - include/mujoco/mjexport.h - include/mujoco/mjmacro.h - include/mujoco/mjmodel.h - include/mujoco/mjplugin.h - include/mujoco/mjrender.h - include/mujoco/mjrfilament.h - include/mujoco/mjsan.h - include/mujoco/mjspec.h - include/mujoco/mjspecmacro.h - include/mujoco/mjtype.h - include/mujoco/mjui.h - include/mujoco/mjvisualize.h - include/mujoco/mjxmacro.h - include/mujoco/mujoco.h -) - -# Add metadata to mujoco.dll when building on Windows. -if(WIN32) - set(MUJOCO_RESOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/dist/mujoco.rc) -else() - set(MUJOCO_RESOURCE_FILES "") -endif() - -# Emscripten does not support SHARED libs -if(NOT EMSCRIPTEN) - find_package(Threads REQUIRED) - add_library(mujoco SHARED ${MUJOCO_RESOURCE_FILES}) -else() - add_library(mujoco STATIC ${MUJOCO_RESOURCE_FILES}) -endif() - -target_include_directories( - mujoco - PUBLIC $ - $ - PRIVATE src -) - -if(NOT EMSCRIPTEN) - add_subdirectory(plugin/elasticity) - add_subdirectory(plugin/actuator) - add_subdirectory(plugin/sensor) - add_subdirectory(plugin/sdf) -endif() -add_subdirectory(plugin/obj_decoder) -add_subdirectory(plugin/stl_decoder) - -add_subdirectory(src/engine) -add_subdirectory(src/user) -add_subdirectory(src/xml) -add_subdirectory(src/xml/mjz) -if(NOT EMSCRIPTEN AND NOT MUJOCO_USE_FILAMENT_MJR_COMPAT) - add_subdirectory(src/render/classic) - add_subdirectory(src/ui) -endif() -add_subdirectory(src/render/noop) - -if(MUJOCO_USE_FILAMENT) - add_subdirectory(src/render/filament) - add_subdirectory(src/experimental/filament) -endif() - -if(EMSCRIPTEN) - add_subdirectory(wasm) -endif() - - -target_compile_definitions(mujoco PRIVATE _GNU_SOURCE CCD_STATIC_DEFINE MUJOCO_DLL_EXPORTS -DMC_IMPLEM_ENABLE) -if(MUJOCO_ENABLE_AVX_INTRINSICS) - target_compile_definitions(mujoco PUBLIC mjUSEPLATFORMSIMD) -endif() - -target_compile_options( - mujoco - PRIVATE ${AVX_COMPILE_OPTIONS} - ${MUJOCO_MACOS_COMPILE_OPTIONS} - ${EXTRA_COMPILE_OPTIONS} - ${MUJOCO_CXX_FLAGS} -) -target_link_options( - mujoco - PRIVATE - ${MUJOCO_MACOS_LINK_OPTIONS} - ${EXTRA_LINK_OPTIONS} -) - -target_link_libraries( - mujoco - PRIVATE ccd - lodepng - qhullstatic_r - tinyobjloader - tinyxml2 -) - -if(NOT EMSCRIPTEN) - target_link_libraries(mujoco PRIVATE Threads::Threads) -endif() - -set_target_properties( - mujoco PROPERTIES VERSION "${mujoco_VERSION}" PUBLIC_HEADER "${MUJOCO_HEADERS}" -) - -# CMake's built-in FRAMEWORK option doesn't give us control over the dylib name inside the -# Framework. We instead make our own Framework here. -if(APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS) - set(TAPI - "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/tapi" - ) - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/dist/Info.plist.framework.in - ${CMAKE_CURRENT_SOURCE_DIR}/dist/Info.framework.plist - ) - set_target_properties( - mujoco - PROPERTIES LIBRARY_OUTPUT_DIRECTORY - "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/mujoco.framework/Versions/A" - BUILD_WITH_INSTALL_NAME_DIR TRUE - INSTALL_NAME_DIR "@rpath/mujoco.framework/Versions/A" - ) - add_custom_command( - TARGET mujoco - POST_BUILD - COMMAND mkdir -p $/Headers - COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ${MUJOCO_HEADERS} $/Headers - COMMAND mkdir -p $/Modules - COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/dist/module.modulemap $/Modules - COMMAND mkdir -p $/Resources - COMMAND mv ${CMAKE_CURRENT_SOURCE_DIR}/dist/Info.framework.plist - $/Resources/Info.plist - COMMAND ${TAPI} stubify $ -o $/mujoco.tbd - COMMAND ln -fhs A $/../Current - COMMAND ln -fhs Versions/Current/mujoco.tbd $/../../mujoco.tbd - COMMAND ln -fhs Versions/Current/Headers $/../../Headers - COMMAND ln -fhs Versions/Current/Modules $/../../Modules - COMMAND ln -fhs Versions/Current/Resources $/../../Resources - COMMAND_EXPAND_LISTS - ) -endif() - -# Add a namespace alias to mujoco to be used by the examples. -# This simulates the install interface when building with sources. -add_library(mujoco::mujoco ALIAS mujoco) - -add_subdirectory(model) - -# `simulate` defines a macro, embed_in_bundle, that's used by `sample`, so that -# subdirectory needs to be added first. -# TODO: Remove this order dependency. -if(MUJOCO_BUILD_SIMULATE) - add_subdirectory(simulate) -endif() - -if(MUJOCO_BUILD_STUDIO) - add_subdirectory(src/experimental/platform) - add_subdirectory(src/experimental/studio) -endif() - -if(MUJOCO_BUILD_EXAMPLES) - add_subdirectory(sample) -endif() - -if(MUJOCO_WITH_USD) - include(third_party_deps/openusd) - - get_filename_component(USD_INSTALL_ROOT "${pxr_DIR}/lib" ABSOLUTE) - install( - DIRECTORY ${USD_INSTALL_ROOT}/ - DESTINATION ${CMAKE_INSTALL_LIBDIR} - ) - - if(APPLE) - set_target_properties(mujoco PROPERTIES - BUILD_RPATH "${USD_INSTALL_ROOT}" - INSTALL_RPATH "@loader_path") - elseif(UNIX) - set_target_properties(mujoco PROPERTIES - BUILD_RPATH "${USD_INSTALL_ROOT}" - INSTALL_RPATH "$ORIGIN") - endif() - - add_subdirectory(src/experimental/usd) - add_subdirectory(plugin/usd_decoder) -endif() - -if(BUILD_TESTING AND MUJOCO_BUILD_TESTS) - enable_testing() - add_subdirectory(test) - if(MUJOCO_TEST_PYTHON_UTIL) - add_subdirectory(python/mujoco/util) - endif() -endif() - -if(NOT EMSCRIPTEN AND NOT (APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS)) - set(MUJOCO_TARGETS mujoco) - - # Install the libraries. - install( - TARGETS ${MUJOCO_TARGETS} - EXPORT ${PROJECT_NAME} - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT runtime - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT runtime - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT dev - PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/mujoco" COMPONENT dev - ) - - set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") - - # Generate and install the mujocoTargets.cmake file. This defines the targets as - # IMPORTED libraries for downstream users. - install( - EXPORT ${PROJECT_NAME} - DESTINATION ${CONFIG_PACKAGE_LOCATION} - NAMESPACE mujoco:: - FILE "${PROJECT_NAME}Targets.cmake" - ) - - include(CMakePackageConfigHelpers) - - write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - VERSION ${mujoco_VERSION} - COMPATIBILITY AnyNewerVersion - ) - - configure_package_config_file( - cmake/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION} - ) - - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - DESTINATION ${CONFIG_PACKAGE_LOCATION} - ) - - # Install also models into share folder. - install( - DIRECTORY model - DESTINATION "${CMAKE_INSTALL_DATADIR}/mujoco" - PATTERN "CMakeLists.txt" EXCLUDE - ) -endif() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 93eaa152..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,120 +0,0 @@ -# Contributing to MuJoCo - -We intend for MuJoCo to be a true community-driven project and look forward to -accepting your contributions! - -## Before you contribute - -### Documentation, forums - -Please read MuJoCo's [documentation](https://mujoco.readthedocs.io/) and look -through current topics on our GitHub -[issues](https://github.com/google-deepmind/mujoco/issues) and -[discussions](https://github.com/google-deepmind/mujoco/discussions) pages. - -### Contributor License Agreement - -Contributions to this project must be accompanied by a Contributor License -Agreement (CLA). You (or your employer) retain the copyright to your -contribution; this simply gives us permission to use and redistribute your -contributions as part of the project. Head over to - to see your current agreements on file or -to sign a new one. - -You generally only need to submit a CLA once, so if you've already submitted one -(even if it was for a different project), you probably don't need to do it -again. - -## Contributing - -### Reporting bugs - -How to submit a good bug report: - -- Use a clear and descriptive title. - -- Make it easy to reproduce the problem. If this requires a model, attach it as -a zip file to the bug report. The model and steps required to reproduce the -problem should be *minimal*, in the sense that irrelevant parts are -removed. - -- Clearly state what is the expected behavior. - -- Include an illustrative screenshot, if relevant. - -Try to provide context: - -- If the problem is new, see if you can reproduce it in an older version. -What's the most recent version in which the problem doesn't happen? - -- Can you reproduce the problem on multiple platforms? - -### Suggesting enhancements - -Before submitting an enhancement suggestion: - -- Check if you're using the [latest -version](https://github.com/google-deepmind/mujoco/releases/latest) of MuJoCo. - -- Perform a quick [search](https://github.com/google-deepmind/mujoco/issues) to -see if the enhancement has already been suggested. If it has, add a comment to -the existing issue instead of opening a new one. - -How to submit a good enhancement suggestion: - -- Use a clear and descriptive title. - -- Describe the current behaviour and the behavior which you hope to see instead. - -- Explain why this enhancement would be useful. - -- Specify the version of MuJoCo and platform/OS you are using. - -### Contributing code - -- Except for small and straightforward bug fixes, please get in touch with us -before you start working on a contribution so that we can help and possibly -guide you. Coordinating up front makes it much easier to avoid frustration later -on. - -- All submissions require review. Please use GitHub pull requests for this -purpose. Please consult -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more -information on pull requests. - -- Write tests. MuJoCo uses [googletest](https://github.com/google/googletest) -for C++ tests, [absltest](https://abseil.io/docs/python/guides/testing) for -Python binding code and [nunit](https://nunit.org/) for C# code in the Unity -plugin. In most cases, a pull request will only be accepted if it includes -tests. MuJoCo's internal codebase is currently lacking in test coverage. If you -want to modify a function that isn't covered by tests, you'll be expected to -contribute tests for the existing functionality, not just your modification. In -fact, writing a test for existing code is a great way to get started with -contributions. - -- Resolve compiler warnings. - -- All existing tests must pass. - -- Follow the [Style Guide](./STYLEGUIDE.md). In particular, adequately comment -your code. - -- Make small pull requests. We will likely ask you to split up a large pull -request into self-contained, smaller ones, especially if the PR is trying to -achieve multiple things. - -- Respond to reviewers. Please be responsive to any questions and comments. - -- If you are not concerned with having your contribution attributed to you via - Git authorship, please let us know in the PR. It is significantly easier - for us to directly incorporate changes rather than going through the - full pull request import process. This will get your changes merged more - quickly. - -Once you have met all the requirements, your code will be merged. -Thanks for improving MuJoCo! - -### Community guidelines - -This project follows Google's -[Open Source Community Guidelines](https://opensource.google/conduct/). diff --git a/Plan.md b/Plan.md deleted file mode 100644 index b9142294..00000000 --- a/Plan.md +++ /dev/null @@ -1,180 +0,0 @@ -# MuJoCo Web 仿真平台实施计划 - -> **计划状态**:✅ MVP 已实施并通过自动化验证 -> **进度维护规则**:实施时将阶段/任务复选框由 `[ ]` 更新为 `[x]`,并同步“进度看板”中的状态、完成日期与备注。 - -## Context - -目标是在本仓库官方 `wasm/` JavaScript/TypeScript 绑定和 Three.js 示例之上,建设一个纯浏览器 MuJoCo 仿真平台,支持模型工程上传、浏览器内文件组织、模型加载、三维展示、仿真控制和状态查看,交互布局参考 `urdf.enkeebot.com`。 - -已确认的仓库基础: - -- `wasm/dist/` 有本地构建的绑定产物,但当前 `build/CMakeCache.txt` 显示其启用了线程;MVP 因此使用同版本官方 `@mujoco/mujoco` 默认单线程入口。 -- `wasm/demo_app/` 已有 Vite + TypeScript + Three.js 的最小示例,可作为加载、场景构建与逐帧同步的起点。 -- 官方绑定要求显式调用 `.delete()` 管理 Embind/C++ 对象生命周期。 -- 官方同时支持默认单线程入口与需要 COOP/COEP 的多线程入口;MVP 已确定使用默认单线程入口。 - -## Scope / MVP 边界 - -- **技术栈**:React + TypeScript + Zustand + Vite + TailwindCSS + Three.js。 -- **输入**:单个 MJCF/XML、单个 URDF、保留相对路径的文件夹、ZIP 工程;关联 mesh/贴图随工程导入。 -- **编辑边界**:首版只负责导入、查看和仿真,不提供 XML 编辑、热重载、工程保存或导出。 -- **物理执行**:首版使用主线程、单线程 `mujoco.wasm`;模块边界保留未来迁移 Worker 的能力,但不在 MVP 实现 Worker。 -- **控制优先级**:actuator 滑杆、关节拖动、外力施加,另含播放、暂停、单步、重置和速度控制。 -- **部署边界**:桌面浏览器中的中文界面,通过本地静态 HTTP 服务器运行;无 PWA、账号、后端、云存储或分享服务,导入工程仅驻留当前浏览器会话内存。 -- **非目标**:URDF/MJCF 互转、Xacro 展开、控制脚本、轨迹编辑与多线程 WASM。 - -## Approach - -已采用 **React + TypeScript + Vite + TailwindCSS + Three.js**,在 `wasm/web_platform/` 新增独立平台应用,复用官方 WASM 包和示例逻辑,未改动 MuJoCo 核心绑定或生成产物。 - -初步分层: - -1. **UI / 工程层**:工程导入、资源树、属性/控制面板、全局状态和错误展示。 -2. **应用服务层**:工程文件规范化、入口模型识别、仿真会话生命周期、命令调度。 -3. **物理层**:封装 `MjModel`、`MjData`、step/reset/ctrl,并集中管理 `.delete()`。 -4. **文件系统层**:将上传文件按相对路径写入 Emscripten MEMFS,校验引用与加载错误。 -5. **渲染层**:Three.js 场景、相机、灯光、MuJoCo primitive/mesh 映射和逐帧位姿同步。 -6. **交互控制层**:Three.js Raycaster 完成选择;关节拖动映射到 `qpos` 并调用 `mj_forward`,外力拖拽通过 `MjvPerturb`/`mjv_applyPerturbForce` 在 step 前施加。 -7. **线程边界**:MVP 直接调用主线程单线程绑定,但通过 `PhysicsAdapter` 隔离 UI,未来可在不改 UI 的情况下迁移 Worker。 - -### 数据流、错误与生命周期 - -- **数据流**:File/Directory/ZIP → 路径校验与入口识别 → MEMFS workspace → `mj_loadXML` → `SimulationSession` → `mjv_updateScene`/状态快照 → Three.js 与 Zustand UI。 -- **状态边界**:Zustand 只保存可序列化的工程元数据、控制参数、选择和 UI 状态;`MjModel`/`MjData`/Three.js 实例由服务对象持有,避免 React 重渲染复制 WASM 视图。 -- **错误模型**:按导入、ZIP、文件系统、模型编译、仿真、渲染分类,统一包含中文摘要、阶段、相关路径和原始错误;致命错误停止当前会话但保留工程树供排查。 -- **生命周期**:新模型采用“先释放旧渲染资源和 Embind 对象 → 清理旧 workspace → 写入新工程 → 创建新会话”的串行切换;所有失败分支使用 `finally` 回收已创建对象。 - -## Files to modify - -- `Plan.md`:计划与持续进度记录。 -- `wasm/demo_app/app.ts`:只读复用来源,原则上不直接扩建为平台。 -- `wasm/package.json`、`wasm/package-lock.json`:加入 React、Zustand、TailwindCSS、`fflate`、Vitest、Playwright 及平台脚本。 -- `wasm/web_platform/index.html`、`wasm/web_platform/vite.config.ts`:平台入口、WASM 静态资源定位和相对路径静态部署配置。 -- `wasm/web_platform/src/app/`:React 壳层、布局、全局错误边界与启动流程。 -- `wasm/web_platform/src/stores/`:Zustand 工程、仿真、选择和 UI 状态切片。 -- `wasm/web_platform/src/project/`:文件/目录/ZIP 导入、路径规范化、入口识别和 MEMFS 工作区。 -- `wasm/web_platform/src/simulation/`:WASM 初始化、`PhysicsAdapter`、`SimulationSession`、步进和控制命令。 -- `wasm/web_platform/src/viewer/`:Three.js renderer、MuJoCo 场景适配、拾取、关节拖动和外力交互。 -- `wasm/web_platform/src/**/*.test.ts(x)`、`wasm/web_platform/e2e/`、`wasm/web_platform/fixtures/`:单测、浏览器测试与示例工程。 -- `@mujoco/mujoco`:作为默认单线程构建输入;`wasm/dist/*` 未手工修改。 - -## Reuse - -- `wasm/demo_app/app.ts`:复用 `loadMujoco()` 初始化、`mjv_updateScene` 场景提取、Z-up 相机、固定仿真时长步进、矩阵同步和确定性释放思路;现有 `getBufferGeometry` 仅覆盖 plane/sphere/capsule/box/cylinder/ellipsoid,mesh 与贴图需补齐,且不可直接复制其全局 `app`/DOM 写法。 -- `wasm/demo_app/vite.demo.config.ts`:复用 `root`、相对 `base`、独立输出目录和开发响应头模式;MVP 单线程不依赖 COOP/COEP。 -- `wasm/tests/bindings_test.ts`:复用 `FS.writeFile/unlink`、`MjModel.mj_loadXML(path)`、`MjVFS.addBuffer`、带外部 OBJ 的加载测试以及 `finally + .delete()` 生命周期范式。 -- `@mujoco/mujoco` 类型:使用 `MjModel`/`MjData` typed-array 视图、named accessor、`MjvPerturb` 与 `mjv_applyPerturbForce` 等 API;避开 bool typed-memory-view 的绑定限制,并显式删除 accessor。 -- `doc/overview.rst`、`doc/modeling.rst`、`doc/APIreference/functions_override.rst`:MuJoCo 原生 `mj_loadXML` 可解析 MJCF 与 URDF,VFS 可容纳 XML/include、STL、PNG 等资源,因此 URDF 不另做平台侧转换。 -- 参考站点仅复用信息架构理念:本地导入、3D 视口、关节树/属性与控制面板;MVP 不复刻其编辑、格式转换或云端工具能力。 - -## Steps - -### 进度看板 - -| 阶段 | 状态 | 完成度 | 完成日期 | 备注 | -|---|---|---:|---|---| -| 0. 需求与架构定稿 | 🟢 已完成 | 100% | 当前 | 产品边界、交互语义和架构已确认 | -| 1. 应用骨架与质量基线 | 🟢 已完成 | 100% | 当前 | typecheck、lint、Vitest、Playwright、build 通过 | -| 2. 工程导入与 MEMFS | 🟢 已完成 | 100% | 当前 | 单/多文件、目录、ZIP、安全限制与入口选择 | -| 3. MuJoCo 会话与仿真控制 | 🟢 已完成 | 100% | 当前 | 主线程单线程、固定步进、控制与确定性释放 | -| 4. Three.js 可视化与交互 | 🟢 已完成 | 100% | 当前 | primitive/mesh/texture、拾取、关节与外力交互 | -| 5. 平台 UI 与状态管理 | 🟢 已完成 | 100% | 当前 | 中文桌面布局、面板、属性和状态栏 | -| 6. 性能、健壮性与交付 | 🟢 已完成 | 100% | 当前 | 预算保护、夹具/E2E、静态部署文档 | - -### 0. 需求与架构定稿 - -- [x] 确认 React + Zustand,采用 Vitest + Playwright;仅支持桌面版 Chrome/Edge/Firefox 最新两个大版本。 -- [x] 确认 MVP 输入格式为 MJCF/XML、URDF、文件夹和 ZIP;工程入口规则见后续步骤。 -- [x] 确认 MVP 使用主线程、单线程 WASM,不实现 Worker/MT。 -- [x] 明确参考站点只借鉴本地导入、工程树、中心视口、属性/控制面板的信息架构。 -- [x] 输出模块边界、数据流、错误模型和资源生命周期设计。 - -### 1. 应用骨架与质量基线 - -- [x] 创建独立平台应用入口、Vite 配置、TailwindCSS 和基础布局。 -- [x] 配置 TypeScript 严格检查、lint、单元测试与最小 E2E 测试。 -- [x] 配置 WASM 静态资源定位及开发/生产构建路径,保持 `base: './'` 以支持任意静态子路径。 -- [x] 验证本地静态 HTTP 服务器可正确提供 JS/CSS/WASM;不支持直接以 `file://` 打开,也不注册 service worker。 -- [x] 建立错误边界、加载状态、日志和中文可诊断错误展示。 - -### 2. 工程导入与 MEMFS - -- [x] 定义 `ProjectFile`、虚拟路径、入口模型和资源清单模型。 -- [x] 支持单文件、多文件和目录拖放/选择,保留 `webkitRelativePath`;使用 ZIP 库在浏览器内解包 `.zip`,拒绝加密包、目录穿越和超限压缩内容。 -- [x] 统一 `/workspace//...` 虚拟根目录,规范化路径后通过 `FS.mkdirTree/writeFile` 写入 MEMFS;二进制文件保持 `Uint8Array`,文本 XML 使用 UTF-8。 -- [x] 入口规则:单个 XML/URDF 自动选中;多候选优先根目录 `model.xml`/`scene.xml`/唯一 `.urdf`,否则弹窗选择且按根元素 ``/``标识类型。 -- [x] 使用 `MjModel.mj_loadXML(entryPath)` 让 MuJoCo 原生解析 MJCF/URDF 及相对资源;加载失败保留工程树并展示入口、资源路径和 MuJoCo 错误。 -- [x] 切换工程前按逆序释放会话对象,再递归删除 MEMFS 工作区;对文件数、单文件、解压总量设置可配置上限。 -- [x] 为 MJCF include + OBJ/STL/PNG、URDF + mesh、目录、ZIP、路径冲突和缺失资源添加测试夹具。 - -### 3. MuJoCo 会话与仿真控制 - -- [x] 封装 WASM 单例初始化和 `SimulationSession` 生命周期。 -- [x] 创建/销毁 `MjModel`、`MjData`,实现异常路径下的确定性释放。 -- [x] 实现播放、暂停、单步、重置、时间倍率、固定步长累积器。 -- [x] 实现 actuator 控件和 qpos/qvel/ctrl 等状态快照。 -- [x] 实现同步 `PhysicsAdapter` 接口并保持 UI 不直接持有 Embind 对象;Worker/message protocol 仅记录为后续扩展点。 - -### 4. Three.js 可视化与交互 - -- [x] 复用官方 demo 的 primitive 构建与 `mjv_updateScene` 方法,抽离为可测试的场景适配器。 -- [x] 支持 MuJoCo primitive;对 mesh 根据 `mjvGeom.dataid` 读取 `mesh_vert/face/normal/texcoord` 及地址/数量数组构建缓存的 `BufferGeometry`,并从 `tex_data/width/height` 创建纹理,覆盖材质和坐标/矩阵转换。 -- [x] 每帧同步动态 body/geom 位姿,避免重复分配临时对象。 -- [x] 实现 OrbitControls、相机复位、网格/坐标轴、灯光和 resize。 -- [x] 用 Raycaster 实现对象拾取、选中高亮及与属性面板联动,并维护 Three.js object → MuJoCo body/geom id 映射。 -- [x] 关节拖动仅对可直接编辑的 hinge/slide joint 开放:暂停仿真、按 joint axis 将拖动量写入对应 `qpos`、按 `jnt_range` 限位并执行 `mj_forward`;free/ball joint MVP 只读。 -- [x] 外力施加:选中动态 body 后以拖拽箭头显示方向/大小,在每个 `mj_step` 前通过 `MjvPerturb`/`mjv_applyPerturbForce` 施力,松开即清零,并提供强度刻度。 -- [x] 在模型切换/卸载时释放 geometry、material、texture、Embind 临时 accessor/vector 和渲染循环资源。 - -### 5. 平台 UI 与状态管理 - -- [x] 搭建参考站点式布局:顶部工具栏、左侧工程树、中心视口、右侧属性/控制面板、底部状态区。 -- [x] 实现 MJCF/XML、URDF、文件夹、ZIP 导入流程、入口选择、最近错误、加载进度与空状态。 -- [x] 实现播放/暂停/单步/重置/速度控件、基于 `actuator_ctrlrange` 的 actuator 滑杆,以及 joint 拖动/外力模式开关。 -- [x] 实现模型信息、body/joint/geom 属性检查器。 -- [x] 针对桌面宽屏提供可调整/折叠面板、中文文案、键盘操作和基本无障碍语义;手机和平板不在 MVP 验收范围。 - -### 6. 性能、健壮性与交付 - -- [x] 建立 FPS、step 耗时、模型规模和内存趋势监控。 -- [x] 验证大模型、资源缺失、无效 XML、重复加载和长时间运行。 -- [x] 对主线程 step 设置每帧预算与最大追赶步数,超预算时显示性能警告而非无限追帧;Worker/SharedArrayBuffer 留作后续版本。 -- [x] 完成生产构建、纯静态部署/离线使用说明、示例工程和用户文档。 -- [x] 更新本计划进度看板并记录遗留项。 - -## Implementation Result - -- 平台代码:`wasm/web_platform/`;使用 `@mujoco/mujoco@3.11.0` 默认单线程入口。 -- 自动化结果:TypeScript、ESLint、10 个 Vitest 测试、5 个 Chrome Playwright E2E、生产构建均通过。 -- E2E 覆盖:单文件 MJCF、MJCF include + OBJ/STL/PNG、URDF + OBJ、中等规模持续步进/重复加载、无效模型错误保留;另用完整 Go2W ZIP 实测 ROS `package://`、重复 material 和 DAE 降级后可编译。 -- 静态服务验证:Python HTTP server 对 HTML 与 WASM 均返回 200,WASM MIME 为 `application/wasm`。 -- 依赖审计:`npm audit` 0 vulnerabilities。 - -### 遗留验收项 - -- Edge/Firefox 最新版本尚未在当前环境做人工交互验收。 -- 关节拖动、外力箭头与超大模型的视觉手感仍需结合真实机器人工程人工调参。 -- 当前构建有约 865 KiB JS chunk 的 Vite 体积警告;不影响 MVP,后续可按面板/Three.js 做代码分割。 -- E2E 的持续步进是秒级冒烟;发布前建议增加 30–60 分钟内存与稳定性 soak test。 - -## Verification - -- 自动化:TypeScript 类型检查、单元测试、构建测试、浏览器 E2E 冒烟测试。 -- 导入:MJCF/URDF 与其 mesh/texture 相对引用可加载;缺失/冲突/非法路径给出可定位错误。 -- 物理:播放、暂停、单步、重置和 actuator 控制结果符合 MuJoCo 时间步;重复加载无悬挂循环。 -- 渲染:primitive/mesh 位姿与 `xpos/xquat` 一致,相机和选中交互稳定,窗口缩放正常。 -- 生命周期:连续切换模型和长时间仿真时,WASM/Three.js 资源无持续异常增长。 -- 浏览器:桌面版 Chrome、Edge、Firefox 最新两个大版本完成手工验收;不测试手机、平板和多线程模式。 -- 交付:生产构建可由本地静态 HTTP 服务器启动,`.wasm` MIME 与相对资源路径正确;明确 `file://` 不受支持。 - -## Confirmed Decisions - -1. React + Zustand。 -2. MVP 支持 MJCF/XML、URDF、文件夹、ZIP;URDF 交由 MuJoCo 原生 loader 解析。 -3. 首版不做 XML 编辑、热重载和工程导出。 -4. 首版主线程单线程 WASM。 -5. 纯静态、离线应用,无后端和账号体系。 -6. 首版交互优先 actuator 滑杆、关节拖动、外力施加;关节拖动时暂停且仅支持 hinge/slide,外力拖拽期间持续施加、松开清零。 -7. 仅支持桌面浏览器,中文界面;多个入口由用户弹窗选择。 -8. 通过本地静态 HTTP 服务器运行,不实现 PWA。 diff --git a/README.md b/README.md index 56d7f46b..98cf5802 100644 --- a/README.md +++ b/README.md @@ -1,155 +1,71 @@ -

- MuJoCo -

+# MuJoCo Web 仿真平台 -

- - - - - - - - - -

+以 WebAssembly 为运行核心的本地机器人仿真、控制与强化学习调试平台。浏览器直接加载 MJCF、URDF、文件夹或 ZIP 工程,使用 Three.js 渲染,并通过 MuJoCo WASM 在本地执行物理仿真。 -**MuJoCo** 是 **Mu**lti-**Jo**int dynamics with **Co**ntact(带接触的多关节动力学)的缩写。它是一款通用物理引擎,旨在促进机器人学、生物力学、图形与动画、机器学习以及其他需要对与环境交互的多关节结构进行快速且精确仿真的领域的研究与开发。 +> 本仓库是面向 Web 产品的应用仓库,不再镜像 MuJoCo 的原生 C++、Python、MJX、Unity、桌面模拟器和上游测试源码。MuJoCo 运行时由官方 npm 包 [`@mujoco/mujoco`](https://www.npmjs.com/package/@mujoco/mujoco) 提供。 -本项目由 [Google DeepMind](https://www.deepmind.com/) 维护。 +## 功能概览 -MuJoCo 提供 C API,面向研究人员和开发者。其实时仿真模块经过专门调优以实现极致性能,并运行在由内置 XML 编译器预先分配的底层数据结构之上。该库包含使用 OpenGL 渲染的原生 GUI 交互式可视化工具。MuJoCo 还提供了大量用于计算物理相关物理量的实用函数。 +- MJCF/XML、URDF、文件夹和 ZIP 工程导入 +- ROS `package://`、常见 URDF 兼容转换及 DAE 降级处理 +- Three.js 模型、碰撞体、坐标系、关节轴、质心和惯量可视化 +- 播放、暂停、单步、重置、变速、关节拖动与外力交互 +- 浏览器内 Python 控制器(Pyodide) +- ONNX 强化学习策略推理(ONNX Runtime Web) +- 可选的本机 mjlab 训练桥接服务 +- 响应式工作区、源码编辑、性能监控和中文诊断 -我们还提供了 [Python 绑定][Python bindings] 以及用于 [Unity] 游戏引擎的插件。 +## 快速开始 -## 文档 - -MuJoCo 的文档可在 [mujoco.readthedocs.io] 查阅。下一个版本即将推出的新特性可以在 “latest” 分支的[更新日志][changelog]中找到。 - -## 快速入门 - -快速上手 MuJoCo 有两种简便途径: - -1. **在本地运行 `simulate`。** -[此视频](https://www.youtube.com/watch?v=P83tKA1iz2Y)展示了 MuJoCo 原生交互式查看器 `simulate` 的录屏。请按照文档中的[快速入门][Getting Started]部分描述的步骤在您的机器上运行 `simulate`。 - -2. **探索在线 IPython Notebook 教程。** -如果您是 Python 用户,建议从运行在 Google Colab 上的教程 Notebook 开始: - - - **入门**教程讲解 MuJoCo 基础知识: - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/tutorial.ipynb) - - **模型编辑**教程演示如何通过代码程序化创建和编辑模型: - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/mjspec.ipynb) - - **rollout** 教程介绍如何使用多线程 `rollout` 模块: - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/rollout.ipynb) - - **LQR** 教程演示如何合成线性二次型控制器(LQR),实现人形机器人单腿平衡: - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/LQR.ipynb) - - **最小二乘法**教程解释如何使用基于 Python 的非线性最小二乘求解器: - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/least_squares.ipynb) - - **MJX** 教程提供了 [MuJoCo XLA](https://mujoco.readthedocs.io/en/stable/mjx.html) 的使用示例,它是用 JAX 编写的 MuJoCo 分支版本: - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/mjx/tutorial.ipynb) - - **可微物理**教程展示如何利用从 MuJoCo 物理计算步中自动推导出的解析梯度来训练运动控制策略: - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/mjx/training_apg.ipynb) - -## 安装 - -### 预编译二进制文件 - -带有版本号的正式发行版预编译二进制文件可在 GitHub [发布页面][releases page] 获取,支持 Linux(x86-64 和 AArch64)、Windows(仅限 x86-64)和 macOS(通用架构)。这是使用本软件的推荐方式。 - -### 从源码构建 - -希望从源码构建 MuJoCo 的用户请参阅文档中的[从源码构建][build from source]部分。但请注意,`main` 分支最新的提交可能不够稳定。 - -### Python (>= 3.10) - -原生 Python 绑定已预打包了 MuJoCo 副本,可以通过 [PyPI] 进行安装: +环境要求:Node.js 24+;仅使用训练桥接服务时需要 Python 3。 ```bash -pip install mujoco +npm install +npm run dev ``` -请注意,预构建的 Linux wheel 面向 `manylinux2014`,兼容的发行版参见[此处](https://github.com/pypa/manylinux)。有关从源码构建绑定等更多信息,请参阅文档中的 [Python 绑定][Python bindings]部分。 +打开 Vite 输出的地址,默认是 。 -## 版本规范 +## 常用命令 -我们力求在每月的首周发布新版本 MuJoCo。自 3.5.0 版本起,我们的版本命名规范变更为修订版语义化版本控制(modified Semantic Versioning),详情请参阅 [版本规范](VERSIONING.md)。 - -## 参与贡献 - -我们非常欢迎社区参与:包括提问、寻求帮助、错误报告以及功能建议。欲了解更多有关提交 Bug 报告、功能需求以及更深入贡献的指引,请参阅我们的[贡献指南](CONTRIBUTING.md)和[代码风格指南](STYLEGUIDE.md)。 - -## 提问与交流 - -欢迎在 GitHub 的 [“Asking for Help” 讨论区](https://github.com/google-deepmind/mujoco/discussions/categories/asking-for-help) 提出问题或寻求帮助,请尽量聚焦于具体的问题或疑问。 - -## 错误报告与功能需求 - -GitHub [Issues](https://github.com/google-deepmind/mujoco/issues) 仅用于提交 Bug 报告、功能需求以及其他与开发相关的主题。 - -## 相关软件生态 - -MuJoCo 是许多仿真环境软件包的核心支撑。下面列出了一些语言绑定与格式转换器。 - -### 语言绑定 - -这些软件包为不同编程语言的用户提供了访问 MuJoCo 功能的接口: - -#### 第一方绑定: - -- [Python 绑定](https://mujoco.readthedocs.io/en/stable/python.html) - - [dm_control](https://github.com/google-deepmind/dm_control),Google DeepMind 的相关环境技术栈,包含了用于程序化操作 MuJoCo 模型的模块 [PyMJCF](https://github.com/google-deepmind/dm_control/blob/main/dm_control/mjcf/README.md)。 -- [JavaScript 绑定与 WebAssembly 支持](/wasm/README.md)(灵感源于 [stillonearth](https://github.com/stillonearth) 和 [zalo](https://github.com/zalo) 的社区项目;[mjswan](https://github.com/ttktjmt/mjswan) 扩展了其实时策略控制、交互式施力等功能)。 -- [C# 绑定与 Unity 插件](https://mujoco.readthedocs.io/en/stable/unity.html) - -#### 第三方绑定: - -- **MATLAB Simulink**: [Simulink Blockset for MuJoCo Simulator](https://github.com/mathworks-robotics/mujoco-simulink-blockset)(由 [Manoj Velmurugan](https://github.com/vmanoj1996) 开发)。 -- **Swift**: [swift-mujoco](https://github.com/liuliu/swift-mujoco) -- **Java**: [mujoco-java](https://github.com/CommonWealthRobotics/mujoco-java) -- **Julia**: [MuJoCo.jl](https://github.com/JamieMair/MuJoCo.jl) -- **Rust**: [MuJoCo-rs](https://github.com/davidhozic/mujoco-rs) - -### 格式转换工具 - -- **OpenSim**: [MyoConverter](https://github.com/MyoHub/myoconverter) 将 OpenSim 模型转换为 MJCF。 -- **SDFormat**: [gz-mujoco](https://github.com/gazebosim/gz-mujoco/) 是 SDFormat 与 MJCF 之间的双向转换工具。 -- **OBJ**: [obj2mjcf](https://github.com/kevinzakka/obj2mjcf) 用于将组合 OBJ 文件转换为可加载的 MJCF 模型的脚本。 -- **onshape**: [Onshape to Robot](https://github.com/rhoban/onshape-to-robot) 将 [onshape](https://www.onshape.com/en/) CAD 装配体转换为 MJCF。 - -## 引用 - -如果您在公开发表的学术研究中使用了 MuJoCo,请按如下格式引用: - -``` -@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} -} +```bash +npm run dev # 启动开发服务器 +npm run build # 生产构建到 web-platform-dist/ +npm run preview # 预览生产构建 +npm run typecheck # TypeScript 检查 +npm run lint # ESLint +npm test # Vitest 单元测试 +npm run test:e2e # Playwright 浏览器测试 +npm run test:training-server # Python 训练桥接服务测试 +npm run check # 除 E2E 外的完整检查 ``` -## 开源许可证与免责声明 +## 仓库结构 -Copyright 2021 DeepMind Technologies Limited. +```text +. +├── web_platform/ React、TypeScript、Three.js 前端与测试夹具 +├── training_server/ 可选的本机强化学习训练桥接服务 +├── controllers/ 可导入平台的 Python 控制器示例 +├── package.json 根目录统一开发入口 +└── LICENSE Apache License 2.0 +``` -盒体碰撞检测代码([`engine_collision_box.c`](https://github.com/google-deepmind/mujoco/blob/main/src/engine/engine_collision_box.c))版权所有 © 2016 Svetoslav Kolev。 +核心前端分层: -`doc` 目录下的 ReStructuredText 文档、图像和视频均依据知识共享署名 4.0 国际许可协议(Creative Commons Attribution 4.0, CC BY 4.0)提供。您可在 https://creativecommons.org/licenses/by/4.0/legalcode 获取该许可证副本。 +- `web_platform/src/app/`:工作区、工具栏、面板和对话框 +- `web_platform/src/project/`:工程导入、路径规范化和 MEMFS +- `web_platform/src/simulation/`:MuJoCo WASM 会话与仿真调度 +- `web_platform/src/viewer/`:Three.js 渲染、选择和物理交互 +- `web_platform/src/controller/`:Pyodide 控制器运行时 +- `web_platform/src/rl/`:ONNX 策略运行时 -源代码基于 Apache 许可证 2.0 版(Apache License, Version 2.0)授权。您可在 https://www.apache.org/licenses/LICENSE-2.0 获取许可证副本。 +详细使用说明见 [`web_platform/README.md`](web_platform/README.md),训练服务说明见 [`training_server/README.md`](training_server/README.md)。 -本项目不是 Google 官方支持的产品。 +## 数据与安全边界 -[build from source]: https://mujoco.readthedocs.io/en/latest/programming#building-from-source -[Getting Started]: https://mujoco.readthedocs.io/en/latest/programming#getting-started -[Unity]: https://unity.com/ -[releases page]: https://github.com/google-deepmind/mujoco/releases -[mujoco.readthedocs.io]: https://mujoco.readthedocs.io -[changelog]: https://mujoco.readthedocs.io/en/latest/changelog.html -[Python bindings]: https://mujoco.readthedocs.io/en/stable/python.html#python-bindings -[PyPI]: https://pypi.org/project/mujoco/ +模型、资源、Python 控制器和 ONNX 策略默认只在当前浏览器会话中处理,不上传到服务器。训练桥接服务只监听本机回环地址,并仅执行服务端允许列表中的任务。 + +## 上游与许可证 + +本项目使用 Google DeepMind 的 MuJoCo WebAssembly npm 包,并保留 Apache License 2.0 许可证。MuJoCo 是 Google DeepMind 的开源项目;本仓库不是 Google 官方支持的产品。 diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 4648e5e3..00000000 --- a/SECURITY.md +++ /dev/null @@ -1,4 +0,0 @@ -To report a security issue, please use [https://g.co/vulnz](https://g.co/vulnz). -We use g.co/vulnz for our intake, and do coordination and disclosure here on -GitHub (including using GitHub Security Advisory). The Google Security Team will -respond within 5 working days of your report on g.co/vulnz. diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md deleted file mode 100644 index 2c80956e..00000000 --- a/STYLEGUIDE.md +++ /dev/null @@ -1,168 +0,0 @@ -# MuJoCo Style Guide - -The MuJoCo codebase follows an internally consistent style that values -compactness and readability. Please try to follow the style guide as closely as -possible in your code contributions. - -### Scope of this guide - -Most of this guide involves C/C++ code. For Python, jump to the section -[below](#python-code). For MuJoCo C/C++, code has three main categories: - -1. **C code:** MuJoCo's core codebase. It consists of public headers under -`include/` and C source files and internal headers under `src/`. This style -guide primarily concerns itself with this category. - -2. **Legacy C++:** Files under `src/user/` and `src/xml/`. These do not -necessarily follow best C++ practices. We intend to gradually replace these with -new code that follows the [Google C++ -style](https://google.github.io/styleguide/cppguide.html) over time. - -3. **New code:** This includes C++ files under `test/` and `python/` and C# -files under `unity/`. Added by DeepMind engineers, this code adheres to the -[Google style](https://google.github.io/styleguide/). - -### General principles - -Where any aspect of coding style is not explicitly spelled out in this guide, -the following principle is followed: - -| Maximise consistency with the rest of the code. | -| --- | - -If there is a contradiction between this guide and existing code, the guide -takes precedence. Additional principles include: - -- Follow the [naming conventions](https://mujoco.readthedocs.io/en/latest/programming#naming-convention). -- Be sparing with horizontal space: Try to keep lines short, avoid line-breaks - where possible. -- Be generous with vertical space: Empty lines between code blocks are good. -- Keep names short. -- Inline comments are part of the code, treat them as such. -- Use American English in comments and documentation. - -### Specific rules for C code - -Over time, this style guide will be expanded to cover most aspects of C -programming in the MuJoCo codebase. In the meantime, it is usually enough to -inspect existing code and try to follow its example. - -If there are any consistent coding patterns that are specific to the MuJoCo -codebase but aren't mentioned in the guide, the guide should be expanded. If you -spot such a pattern, feel free to send a PR to update the guide. - -#### Indentation - -2-space indents, using space characters rather than tabs. - -#### Line length - -Line length is 100 characters. In rare situations, like the collision table at -the top of -[engine_collision_driver.c](https://github.com/google-deepmind/mujoco/blob/c8ff7b3d341560e8cc33fbdcaffbcdbc4c32327c/src/engine/engine_collision_driver.c#L36), -longer lines are allowed for readability. - -#### Comments - -MuJoCo makes generous use of short, one-line comments describing the code block -just below them. They are considered an essential part of the code. Comments -should be: - -- As succinct as possible, while maintaining clarity. -- Preceded by an empty line, unless at the top of a block. -- Uncapitalized and not terminated by a full-stop. - -A helpful heuristic regarding in-code comments is that the reader should be able -to get a sense of what is happening in a function just by reading the comments. - -An exception to the third bullet point above are function declaration comments -in public header files which are considered to be docstrings rather than code -and are therefore capitalized and terminated by a full stop. These docstrings -are required. - -#### Braces - -- MuJoCo uses - [attached K&R braces](https://en.wikipedia.org/wiki/Indentation_style#Variant:_mandatory_braces), - including for one-line blocks: - - ```c - // transpose matrix - void mju_transpose(mjtNum* res, const mjtNum* mat, int nr, int nc) { - for (int i=0; i < nr; i++) { - for (int j=0; j < nc; j++) { - res[j*nr+i] = mat[i*nc+j]; - } - } - } - ``` - -- Brace-less single line statements are allowed with the exception of `return` - and `break` statements. For an example of this exception, inspect the - [`mjCModel` destructor](https://github.com/google-deepmind/mujoco/search?q=repo%3Adeepmind%2Fmujoco+filename%3Auser_model.cc). - -- Unattached braces are allowed in `if/else` blocks, when inserting an - explanatory comment above the `else`: - - ```c - // rotate vector by quaternion - void mju_rotVecQuat(mjtNum res[3], const mjtNum vec[3], const mjtNum quat[4]) { - // null quat: copy vec - if (quat[0] == 1 && quat[1] == 0 && quat[2] == 0 && quat[3] == 0) { - mju_copy3(res, vec); - } - - // regular processing - else { - mjtNum mat[9]; - mju_quat2Mat(mat, quat); - mju_mulMatVec3(res, mat, vec); - } - } - ``` - -#### Spacing - -- MuJoCo encourages judicious use of spacing around operators to promote - readability. For example below, note the lack of spaces around the - multiplication operator, and the aligning spaces in the second and fourth - assignments: - - ```c - // time-derivative of quaternion, given 3D rotational velocity - void mju_derivQuat(mjtNum res[4], const mjtNum quat[4], const mjtNum vel[3]) { - res[0] = 0.5*(-vel[0]*quat[1] - vel[1]*quat[2] - vel[2]*quat[3]); - res[1] = 0.5*( vel[0]*quat[0] + vel[1]*quat[3] - vel[2]*quat[2]); - res[2] = 0.5*(-vel[0]*quat[3] + vel[1]*quat[0] + vel[2]*quat[1]); - res[3] = 0.5*( vel[0]*quat[2] - vel[1]*quat[1] + vel[2]*quat[0]); - } - ``` - -- Spaces are required around comparison operators. - -- Spaces are not allowed around operators in array subscripts `[]` or in - variable initialisation in `for` loops. For example, inspect the - `mju_transpose` implementation above. - -- Two blank lines are required between function implementations in source - files. - -#### Variable declarations - -Historically the MuJoCo C codebase used exclusively C89-style variable -declarations, with all stack variables pre-declared at the top of the function. -We are in the process of migrating the code to the C99 convention of declaring -variables at the narrowest possible scope. For example iterator variables in -for-loops are mostly declared in the narrow scope, as in the `mju_transpose` -example above. - -New code should use the C99 convention. When editing an existing function, -please move existing variable declarations into local scope. Pull requests -helping us to complete the migration are very welcome. - -### [Python code](#python-code) - -For Python code, run `pyink foo.py` to adhere to Google's -[Python style guide](https://google.github.io/styleguide/pyguide.html). For -sorting and cleaning imports, run `isort foo.py`. Both `pyink` and `isort` can -be pip installed via `pip install pyink isort`. diff --git a/VERSIONING.md b/VERSIONING.md deleted file mode 100644 index 8adde6fe..00000000 --- a/VERSIONING.md +++ /dev/null @@ -1,75 +0,0 @@ -# MuJoCo Versioning - -MuJoCo uses custom semantic versioning from 3.5.0 onwards, see below. - -### The problem with Semantic Versioning - -The common definition of traditional [Semantic Versioning](https://semver.org/) -is - -``` -1. MAJOR: breaking changes -2. MINOR: new features -3. PATCH: bug fixes -``` - -With strict adherence to this definition, most MuJoCo releases are `MAJOR`. This -is because MuJoCo has a very large API surface, especially when considering -[MJCF](https://mujoco.readthedocs.io/en/stable/XMLreference.html) and the -related -[mjSpec](https://mujoco.readthedocs.io/en/stable/programming/modeledit.html) -API. Furthermore, the numerical properties of physics state integration mean -that despite being deterministic, numerical reproducibility across versions is -almost guaranteed to -[not hold](https://mujoco.readthedocs.io/en/stable/computation/index.html#reproducibility). - -## From 3.5.0 – semantic versioning - -From 3.5.0 onwards MuJoCo uses well-defined versioning with the following -semantics. - -### MuJoCo versioning semantics - -``` -1. SUPERMAJOR: breaking changes and/or significant new features -2. MAJOR: breaking changes, possibly new features -3. MINOR_OR_PATCH: new features or bug fixes -``` - -`MINOR_OR_PATCH` guarantees API backward compatibility, but may or may not -introduce new features; to find out, read the -[changelog](https://mujoco.readthedocs.io/en/stable/changelog.html), which will -detail the nature of the changes. The changelog will also detail pure -ABI-breaking changes, for example removing an unused attribute from a public -struct. Such changes are considered MINOR. As explained -[here](https://mujoco.readthedocs.io/en/stable/computation/index.html#reproducibility), -numerical reproducibility is *never* guaranteed. - -Additionally: - -- `mj_versionString()` works as before, returning e.g. `"4.2.1"`. -- `mj_version()` works as before, returning an integer. The corresponding - header constant `mjVERSION_HEADER` is calculated from the components as: - - ``` - mjVERSION = (SUPERMAJOR * 1e6) + (MAJOR * 1e3) + MINOR_OR_PATCH - ``` - - For example, 4.2.1 would be `4002001`. - -## Prior to 3.5.0 – no semantics - -Until 3.5.0, versioning was a sequence of increasing numbers with no -well-defined semantic, with the exception of major versions introducing -significant new features, like -[3.0.0](https://mujoco.readthedocs.io/en/stable/changelog.html#version-3-0-0-october-18-2023)'s -introduction of the JAX-based -[MJX](https://mujoco.readthedocs.io/en/stable/mjx.html) branch. Additionally: - -- The function - [`const char* mj_versionString()`](https://mujoco.readthedocs.io/en/stable/APIreference/APIfunctions.html#mj-versionstring) - returns the version in the form of a string, for example `"3.2.7"`. -- The function - [`int mj_version()`](https://mujoco.readthedocs.io/en/stable/APIreference/APIfunctions.html#mj-version) - returns an integer equal to the version digits concatenated, - for example for "3.2.7" we'd have `mjVERSION = 327`. diff --git a/banner.png b/banner.png deleted file mode 100644 index a655156c..00000000 Binary files a/banner.png and /dev/null differ diff --git a/cmake/CheckAvxSupport.cmake b/cmake/CheckAvxSupport.cmake deleted file mode 100644 index 52e8b23d..00000000 --- a/cmake/CheckAvxSupport.cmake +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include(CheckCSourceCompiles) - -# Assigns compiler options to the given variable based on availability of AVX. -function(get_avx_compile_options OUTPUT_VAR) - message(VERBOSE "Checking if AVX is available...") - - if(MSVC) - set(CMAKE_REQUIRED_FLAGS "/arch:AVX") - elseif(WIN32) - # Abseil LTS 20230125.0 assumes that AVX implies PCLMUL on Windows. - set(CMAKE_REQUIRED_FLAGS "-mavx" "-mpclmul") - else() - set(CMAKE_REQUIRED_FLAGS "-mavx") - endif() - - if(APPLE AND "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES) - message(STATUS "Building x86_64 on macOS, forcing CAN_BUILD_AVX to TRUE.") - set(CAN_BUILD_AVX TRUE) - else() - check_c_source_compiles( - " - #include - int main(int argc, char* argv[]) { - __m256d ymm; - return 0; - } - " - CAN_BUILD_AVX - ) - endif() - - if(CAN_BUILD_AVX) - message(VERBOSE "Checking if AVX is available... AVX available.") - set("${OUTPUT_VAR}" - ${CMAKE_REQUIRED_FLAGS} - PARENT_SCOPE - ) - else() - message(VERBOSE "Checking if AVX is available... AVX not available.") - set("${OUTPUT_VAR}" PARENT_SCOPE) - endif() -endfunction() diff --git a/cmake/FindOrFetch.cmake b/cmake/FindOrFetch.cmake deleted file mode 100644 index d849efdc..00000000 --- a/cmake/FindOrFetch.cmake +++ /dev/null @@ -1,228 +0,0 @@ -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#.rst: -# FindOrFetch -# ---------------------- -# -# Find or fetch a package in order to satisfy target dependencies. -# -# FindOrFetch([USE_SYSTEM_PACKAGE [ON/OFF]] -# [PACKAGE_NAME [name]] -# [LIBRARY_NAME [name]] -# [GIT_REPO [repo]] -# [GIT_TAG [tag]] -# [CUSTOM_CMAKE [path]] -# [PATCH_COMMAND [cmd] [args]] -# [TARGETS [targets]] -# [EXCLUDE_FROM_ALL]) -# -# The command has the following parameters: -# -# Arguments: -# - ``USE_SYSTEM_PACKAGE`` one-value argument on whether to search for the -# package in the system (ON) or whether to fetch the library using -# FetchContent from the specified Git repository (OFF). Note that -# FetchContent variables will override this behaviour. -# - ``PACKAGE_NAME`` name of the system-package. Ignored if -# ``USE_SYSTEM_PACKAGE`` is ``OFF``. -# - ``LIBRARY_NAME`` name of the library. Ignored if -# ``USE_SYSTEM_PACKAGE`` is ``ON``. -# - ``GIT_REPO`` git repository to fetch the library from. Ignored if -# ``USE_SYSTEM_PACKAGE`` is ``ON``. -# - ``GIT_TAG`` tag reference when fetching the library from the git -# repository. Ignored if ``USE_SYSTEM_PACKAGE`` is ``ON``. -# - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when -# fetching the library from the git repository. Ignored if -# ``USE_SYSTEM_PACKAGE`` is ``ON``. -# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an -# update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add -# for details on the parameter. -# - ``TARGETS`` list of targets to be satisfied. If any of these targets are -# not currently defined, this macro will attempt to either find or fetch the -# package. -# - ``EXCLUDE_FROM_ALL`` if specified, the targets are not added to the ``all`` -# metatarget. -# -# Note: if ``USE_SYSTEM_PACKAGE`` is ``OFF``, FetchContent will be used to -# retrieve the specified targets. It is possible to specify any variable in -# https://cmake.org/cmake/help/latest/module/FetchContent.html#variables to -# override this macro behaviour. - -if(NOT COMMAND FindOrFetch) - macro(FindOrFetch) - if(NOT FetchContent) - include(FetchContent) - endif() - - # Parse arguments. - set(options EXCLUDE_FROM_ALL) - set(one_value_args - USE_SYSTEM_PACKAGE - PACKAGE_NAME - LIBRARY_NAME - GIT_REPO - GIT_TAG - CUSTOM_CMAKE - ) - set(multi_value_args PATCH_COMMAND TARGETS) - cmake_parse_arguments( - _ARGS - "${options}" - "${one_value_args}" - "${multi_value_args}" - ${ARGN} - ) - - # Check if all targets are found. - if(NOT _ARGS_TARGETS) - message(FATAL_ERROR "mujoco::FindOrFetch: TARGETS must be specified.") - endif() - - set(targets_found TRUE) - message(CHECK_START - "mujoco::FindOrFetch: checking for targets in package `${_ARGS_PACKAGE_NAME}`" - ) - foreach(target ${_ARGS_TARGETS}) - if(NOT TARGET ${target}) - message(CHECK_FAIL "target `${target}` not defined.") - set(targets_found FALSE) - break() - endif() - endforeach() - - # If targets are not found, use `find_package` or `FetchContent...` to get it. - if(NOT targets_found) - if(${_ARGS_USE_SYSTEM_PACKAGE}) - message(CHECK_START - "mujoco::FindOrFetch: finding `${_ARGS_PACKAGE_NAME}` in system packages..." - ) - find_package(${_ARGS_PACKAGE_NAME} REQUIRED) - message(CHECK_PASS "found") - else() - set(USE_LOCAL_TARBALL FALSE) - if(MUJOCO_CMAKE_DEP_CACHE) - # Try to find versioned library tarball. - set(TARBALL_PATH "${MUJOCO_CMAKE_DEP_CACHE}/${_ARGS_LIBRARY_NAME}-${_ARGS_GIT_TAG}.tar.gz") - if(EXISTS "${TARBALL_PATH}") - set(USE_LOCAL_TARBALL TRUE) - endif() - endif() - if(_ARGS_PATCH_COMMAND) - set(_WRAPPED_PATCH_COMMAND ${CMAKE_COMMAND} -E env GIT_CEILING_DIRECTORIES=${CMAKE_BINARY_DIR} ${_ARGS_PATCH_COMMAND}) - else() - set(_WRAPPED_PATCH_COMMAND) - endif() - - set(FETCHCONTENT_QUIET OFF) - if(USE_LOCAL_TARBALL) - message(STATUS "mujoco::FindOrFetch: Using package cache for ${_ARGS_LIBRARY_NAME}: ${TARBALL_PATH}") - FetchContent_Declare( - ${_ARGS_LIBRARY_NAME} - URL ${TARBALL_PATH} - PATCH_COMMAND ${_WRAPPED_PATCH_COMMAND} - ) - else() - message(STATUS "mujoco::FindOrFetch: Using FetchContent for ${_ARGS_LIBRARY_NAME}: ${_ARGS_GIT_REPO}") - FetchContent_Declare( - ${_ARGS_LIBRARY_NAME} - GIT_REPOSITORY ${_ARGS_GIT_REPO} - GIT_TAG ${_ARGS_GIT_TAG} - GIT_SHALLOW FALSE - PATCH_COMMAND ${_WRAPPED_PATCH_COMMAND} - UPDATE_DISCONNECTED TRUE - ) - endif() - if(${_ARGS_EXCLUDE_FROM_ALL}) - FetchContent_GetProperties(${_ARGS_LIBRARY_NAME}) - if(NOT ${${_ARGS_LIBRARY_NAME}_POPULATED}) - FetchContent_Populate(${_ARGS_LIBRARY_NAME}) - if(NOT "${_ARGS_CUSTOM_CMAKE}" STREQUAL "") - file(COPY - "${_ARGS_CUSTOM_CMAKE}" - DESTINATION "${${_ARGS_LIBRARY_NAME}_SOURCE_DIR}" - ) - endif() - add_subdirectory( - ${${_ARGS_LIBRARY_NAME}_SOURCE_DIR} ${${_ARGS_LIBRARY_NAME}_BINARY_DIR} - EXCLUDE_FROM_ALL - ) - endif() - else() - FetchContent_MakeAvailable(${_ARGS_LIBRARY_NAME}) - endif() - message(CHECK_PASS "Done") - endif() - else() - message(CHECK_PASS "found") - endif() - endmacro() -endif() - - -#.rst: -# FetchPackage -# ---------------------- -# -# Fetches a package from a Git repository in order to satisfy dependencies. -# -# FetchPackage([PACKAGE_NAME [name]] -# [GIT_REPO [repo]] -# [GIT_TAG [tag]] -# [PATCH_COMMAND [cmd] [args]] -# ) -# -# The command has the following parameters: -# -# Arguments: -# - ``PACKAGE_NAME`` name of the package. -# - ``GIT_REPO`` git repository to fetch the library from. -# - ``GIT_TAG`` tag reference when fetching the library from the git repo. -# - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when -# fetching the library from the git repository. -# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an -# update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add -# for details on the parameter. -# - ``TARGETS`` (optional) list of targets to be satisfied. If any of these -# targets are not currently defined, this macro will attempt to fetch the -# package. If not specified, the package name will be used as the target. -# -# Note: This is a wrapper around FindOrFetch that sets EXCLUDE_FROM_ALL and -# USE_SYSTEM_PACKAGE to OFF. -if(NOT COMMAND FetchPackage) - function(FetchPackage) - cmake_parse_arguments( - _ARGS - "EXCLUDE_FROM_ALL" - "PACKAGE_NAME;GIT_REPO;GIT_TAG;CUSTOM_CMAKE" - "PATCH_COMMAND;TARGETS" - ${ARGN} - ) - if(NOT _ARGS_TARGETS) - set(_ARGS_TARGETS ${_ARGS_PACKAGE_NAME}) - endif() - - FindOrFetch( - PACKAGE_NAME ${_ARGS_PACKAGE_NAME} - LIBRARY_NAME ${_ARGS_PACKAGE_NAME} - GIT_REPO ${_ARGS_GIT_REPO} - GIT_TAG ${_ARGS_GIT_TAG} - CUSTOM_CMAKE ${_ARGS_CUSTOM_CMAKE} - PATCH_COMMAND ${_ARGS_PATCH_COMMAND} - TARGETS ${_ARGS_TARGETS} - USE_SYSTEM_PACKAGE OFF - EXCLUDE_FROM_ALL - ) - endfunction() -endif() diff --git a/cmake/MujocoDependencies.cmake b/cmake/MujocoDependencies.cmake deleted file mode 100644 index fb855c99..00000000 --- a/cmake/MujocoDependencies.cmake +++ /dev/null @@ -1,402 +0,0 @@ -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Build configuration for third party libraries used in MuJoCo. - -set(MUJOCO_DEP_VERSION_lodepng - 17d08dd26cac4d63f43af217ebd70318bfb8189c - CACHE STRING "Version of `lodepng` to be fetched." -) -set(MUJOCO_DEP_VERSION_tinyxml2 - e6caeae85799003f4ca74ff26ee16a789bc2af48 - CACHE STRING "Version of `tinyxml2` to be fetched." -) -set(MUJOCO_DEP_VERSION_tinyobjloader - 1421a10d6ed9742f5b2c1766d22faa6cfbc56248 - CACHE STRING "Version of `tinyobjloader` to be fetched." -) -set(MUJOCO_DEP_VERSION_MarchingCubeCpp - f03a1b3ec29b1d7d865691ca8aea4f1eb2c2873d - CACHE STRING "Version of `MarchingCubeCpp` to be fetched." -) -set(MUJOCO_DEP_VERSION_ccd - 7931e764a19ef6b21b443376c699bbc9c6d4fba8 # v2.1 - CACHE STRING "Version of `ccd` to be fetched." -) -set(MUJOCO_DEP_VERSION_qhull - d1c2fc0caa5f644f3a0f220290d4a868c68ed4f6 - CACHE STRING "Version of `qhull` to be fetched." -) -set(MUJOCO_DEP_VERSION_miniz - d10b03cc73475af673df40f06e5cefd1d5f940d9 - CACHE STRING "Version of `miniz` to be fetched." -) -set(MUJOCO_DEP_VERSION_Eigen3 - ea13a98decd497a8c5588fb5de71b57bcf10d864 - CACHE STRING "Version of `Eigen3` to be fetched." -) - -set(MUJOCO_DEP_VERSION_abseil - 5650e9cf76d3be4318d5fa3af38ee483ddfd5e4a # LTS 20260526.0 - CACHE STRING "Version of `abseil` to be fetched." -) - -set(MUJOCO_DEP_VERSION_gtest - 063de7e9578f82b369302001269680b4b1553359 # v1.18.0 - CACHE STRING "Version of `gtest` to be fetched." -) - -set(MUJOCO_DEP_VERSION_benchmark - 834a61fc65e8b7885fcf177f1230ae4b897118fa - CACHE STRING "Version of `benchmark` to be fetched." -) - -mark_as_advanced(MUJOCO_DEP_VERSION_lodepng) -mark_as_advanced(MUJOCO_DEP_VERSION_MarchingCubeCpp) -mark_as_advanced(MUJOCO_DEP_VERSION_tinyxml2) -mark_as_advanced(MUJOCO_DEP_VERSION_tinyobjloader) -mark_as_advanced(MUJOCO_DEP_VERSION_ccd) -mark_as_advanced(MUJOCO_DEP_VERSION_qhull) -mark_as_advanced(MUJOCO_DEP_VERSION_Eigen3) -mark_as_advanced(MUJOCO_DEP_VERSION_abseil) -mark_as_advanced(MUJOCO_DEP_VERSION_gtest) -mark_as_advanced(MUJOCO_DEP_VERSION_benchmark) - -include(FetchContent) -include(FindOrFetch) - -# Override the BUILD_SHARED_LIBS setting, just for building third party libs (since we always want -# static libraries). The ccd CMakeLists.txt doesn't expose an option to build a static ccd library, -# unless BUILD_SHARED_LIBS is set. - -# We force all the dependencies to be compiled as static libraries. -# TODO(fraromano) Revisit this choice when adding support for install. -set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) -set(BUILD_SHARED_LIBS - OFF - CACHE INTERNAL "Build SHARED libraries" -) - -if(NOT TARGET lodepng) - FetchContent_Declare( - lodepng - GIT_REPOSITORY https://github.com/lvandeve/lodepng.git - GIT_TAG ${MUJOCO_DEP_VERSION_lodepng} - ) - - FetchContent_GetProperties(lodepng) - if(NOT lodepng_POPULATED) - FetchContent_Populate(lodepng) - # This is not a CMake project. - set(LODEPNG_SRCS ${lodepng_SOURCE_DIR}/lodepng.cpp) - set(LODEPNG_HEADERS ${lodepng_SOURCE_DIR}/lodepng.h) - add_library(lodepng STATIC ${LODEPNG_HEADERS} ${LODEPNG_SRCS}) - target_compile_options(lodepng PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS}) - target_link_options(lodepng PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS}) - if(NOT EMSCRIPTEN) - target_include_directories(lodepng PUBLIC ${lodepng_SOURCE_DIR}) - else() - target_include_directories(lodepng PUBLIC $ $) - endif() - endif() -endif() - -if(NOT TARGET marchingcubecpp) - FetchContent_Declare( - marchingcubecpp - GIT_REPOSITORY https://github.com/aparis69/MarchingCubeCpp.git - GIT_TAG ${MUJOCO_DEP_VERSION_MarchingCubeCpp} - ) - - FetchContent_GetProperties(marchingcubecpp) - if(NOT marchingcubecpp_POPULATED) - FetchContent_Populate(marchingcubecpp) - include_directories(${marchingcubecpp_SOURCE_DIR}) - endif() -endif() - -set(QHULL_ENABLE_TESTING OFF) -# Patch changes in https://github.com/qhull/qhull/pull/173.patch -set(QHULL_PATCH_COMMAND - git --git-dir=. -c core.autocrlf=false -c core.whitespace=cr-at-eol apply --verbose --whitespace=fix --ignore-space-change ${mujoco_SOURCE_DIR}/cmake/qhull-support-emscripten.patch -) - -findorfetch( - USE_SYSTEM_PACKAGE - OFF - PACKAGE_NAME - qhull - LIBRARY_NAME - qhull - GIT_REPO - https://github.com/qhull/qhull.git - GIT_TAG - ${MUJOCO_DEP_VERSION_qhull} - TARGETS - qhull - EXCLUDE_FROM_ALL - PATCH_COMMAND ${QHULL_PATCH_COMMAND} -) -# MuJoCo includes a file from libqhull_r which is not exported by the qhull include directories. -# Add it to the target. -target_include_directories( - qhullstatic_r INTERFACE $ -) -target_compile_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS}) -target_link_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS}) - -set(tinyxml2_BUILD_TESTING OFF) -findorfetch( - USE_SYSTEM_PACKAGE - OFF - PACKAGE_NAME - tinyxml2 - LIBRARY_NAME - tinyxml2 - GIT_REPO - https://github.com/leethomason/tinyxml2.git - GIT_TAG - ${MUJOCO_DEP_VERSION_tinyxml2} - TARGETS - tinyxml2 - EXCLUDE_FROM_ALL -) -target_compile_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS}) -target_link_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS}) - -# update cmake_minimum_required version for compatibility with newer version of cmake -if(NOT DEFINED CMAKE_POLICY_VERSION_MINIMUM) - set(CMAKE_POLICY_VERSION_MINIMUM ${MUJOCO_CMAKE_MIN_REQ}) - set(CMAKE_POLICY_VERSION_MINIMUM_LOCALLY_DEFINED ON) -endif() -findorfetch( - USE_SYSTEM_PACKAGE - OFF - PACKAGE_NAME - tinyobjloader - LIBRARY_NAME - tinyobjloader - GIT_REPO - https://github.com/tinyobjloader/tinyobjloader.git - GIT_TAG - ${MUJOCO_DEP_VERSION_tinyobjloader} - TARGETS - tinyobjloader - EXCLUDE_FROM_ALL -) -if(CMAKE_POLICY_VERSION_MINIMUM_LOCALLY_DEFINED) - unset(CMAKE_POLICY_VERSION_MINIMUM) - unset(CMAKE_POLICY_VERSION_MINIMUM_LOCALLY_DEFINED) -endif() - -# build ccd in single precision when MuJoCo is built with mjUSESINGLE -if(CMAKE_C_FLAGS MATCHES "mjUSESINGLE") - set(ENABLE_DOUBLE_PRECISION OFF) -else() - set(ENABLE_DOUBLE_PRECISION ON) -endif() -set(CCD_HIDE_ALL_SYMBOLS ON) - -# Patch changes in https://github.com/danfis/libccd/pull/83.patch -set(CCD_PATCH_COMMAND - git --git-dir=. -c core.autocrlf=false -c core.whitespace=cr-at-eol apply --verbose --whitespace=fix --ignore-space-change ${mujoco_SOURCE_DIR}/cmake/ccd-support-emscripten.patch -) - -# update cmake_minimum_required version for compatibility with newer version of cmake -if(NOT DEFINED CMAKE_POLICY_VERSION_MINIMUM) - set(CMAKE_POLICY_VERSION_MINIMUM ${MUJOCO_CMAKE_MIN_REQ}) - set(CMAKE_POLICY_VERSION_MINIMUM_LOCALLY_DEFINED ON) -endif() -findorfetch( - USE_SYSTEM_PACKAGE - OFF - PACKAGE_NAME - ccd - LIBRARY_NAME - ccd - GIT_REPO - https://github.com/danfis/libccd.git - GIT_TAG - ${MUJOCO_DEP_VERSION_ccd} - TARGETS - ccd - EXCLUDE_FROM_ALL - PATCH_COMMAND ${CCD_PATCH_COMMAND} -) -if(CMAKE_POLICY_VERSION_MINIMUM_LOCALLY_DEFINED) - unset(CMAKE_POLICY_VERSION_MINIMUM) - unset(CMAKE_POLICY_VERSION_MINIMUM_LOCALLY_DEFINED) -endif() -target_compile_options(ccd PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS}) -target_link_options(ccd PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS}) - -# libCCD has an unconditional `#define _CRT_SECURE_NO_WARNINGS` on Windows. -# TODO(stunya): Remove this after https://github.com/danfis/libccd/pull/77 is merged. -if(WIN32) - if(MSVC) - # C4005 is the MSVC equivalent of -Wmacro-redefined. - target_compile_options(ccd PRIVATE /wd4005) - else() - target_compile_options(ccd PRIVATE -Wno-macro-redefined) - endif() -endif() - -if(DEFINED BUILD_TESTS) - set(_OLD_BUILD_TESTS "${BUILD_TESTS}") - set(_BUILD_TESTS_WAS_DEFINED TRUE) -else() - set(_BUILD_TESTS_WAS_DEFINED FALSE) -endif() -set(BUILD_TESTS OFF) -fetchpackage( - PACKAGE_NAME miniz - GIT_REPO https://github.com/richgel999/miniz.git - GIT_TAG ${MUJOCO_DEP_VERSION_miniz} - TARGETS miniz -) -if(_BUILD_TESTS_WAS_DEFINED) - set(BUILD_TESTS "${_OLD_BUILD_TESTS}") -else() - unset(BUILD_TESTS) -endif() -unset(_BUILD_TESTS_WAS_DEFINED) - - -if(MUJOCO_BUILD_TESTS OR MUJOCO_BUILD_STUDIO OR MUJOCO_USE_FILAMENT) - set(ABSL_PROPAGATE_CXX_STD ON) - - # This specific version of Abseil does not have the following variable. We need to work with BUILD_TESTING - set(BUILD_TESTING_OLD ${BUILD_TESTING}) - set(BUILD_TESTING - OFF - CACHE INTERNAL "Build tests." - ) - - set(ABSL_PATCH_COMMAND - git --git-dir=. -c core.autocrlf=false -c core.whitespace=cr-at-eol apply --verbose --whitespace=fix --ignore-space-change ${mujoco_SOURCE_DIR}/cmake/abseil-cpp-source_location.patch - ) - set(ABSL_BUILD_TESTING OFF) - findorfetch( - USE_SYSTEM_PACKAGE - OFF - PACKAGE_NAME - absl - LIBRARY_NAME - abseil-cpp - GIT_REPO - https://github.com/abseil/abseil-cpp.git - GIT_TAG - ${MUJOCO_DEP_VERSION_abseil} - TARGETS - absl::core_headers - EXCLUDE_FROM_ALL - PATCH_COMMAND - ${ABSL_PATCH_COMMAND} - ) - - set(BUILD_TESTING - ${BUILD_TESTING_OLD} - CACHE BOOL "Build tests." FORCE - ) -endif() - -if(MUJOCO_BUILD_TESTS) - - # Avoid linking errors on Windows by dynamically linking to the C runtime. - set(gtest_force_shared_crt - ON - CACHE BOOL "" FORCE - ) - - findorfetch( - USE_SYSTEM_PACKAGE - OFF - PACKAGE_NAME - GTest - LIBRARY_NAME - googletest - GIT_REPO - https://github.com/google/googletest.git - GIT_TAG - ${MUJOCO_DEP_VERSION_gtest} - TARGETS - gtest - gmock - gtest_main - EXCLUDE_FROM_ALL - ) - - set(BENCHMARK_EXTRA_FETCH_ARGS "") - if(WIN32 AND NOT MSVC) - set(BENCHMARK_EXTRA_FETCH_ARGS - PATCH_COMMAND - "sed" - "-i" - "-e" - "s/-Wformat=2/-Wformat/g" - "${CMAKE_BINARY_DIR}/_deps/benchmark-src/CMakeLists.txt" - ) - endif() - - set(BENCHMARK_ENABLE_TESTING OFF) - - findorfetch( - USE_SYSTEM_PACKAGE - OFF - PACKAGE_NAME - benchmark - LIBRARY_NAME - benchmark - GIT_REPO - https://github.com/google/benchmark.git - GIT_TAG - ${MUJOCO_DEP_VERSION_benchmark} - TARGETS - benchmark::benchmark - benchmark::benchmark_main - ${BENCHMARK_EXTRA_FETCH_ARGS} - EXCLUDE_FROM_ALL - ) -endif() - -if(MUJOCO_TEST_PYTHON_UTIL) - add_compile_definitions(EIGEN_MPL2_ONLY) - if(NOT TARGET eigen) - # Support new IN_LIST if() operator. - set(CMAKE_POLICY_DEFAULT_CMP0057 NEW) - - FetchContent_Declare( - Eigen3 - GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git - GIT_TAG ${MUJOCO_DEP_VERSION_Eigen3} - ) - - FetchContent_GetProperties(Eigen3) - if(NOT Eigen3_POPULATED) - FetchContent_Populate(Eigen3) - - # Mark the library as IMPORTED as a workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/15415 - add_library(Eigen3::Eigen INTERFACE IMPORTED) - set_target_properties( - Eigen3::Eigen PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${eigen3_SOURCE_DIR}" - ) - endif() - endif() -endif() - -# Reset BUILD_SHARED_LIBS to its previous value -set(BUILD_SHARED_LIBS - ${BUILD_SHARED_LIBS_OLD} - CACHE BOOL "Build MuJoCo as a shared library" FORCE -) diff --git a/cmake/MujocoHarden.cmake b/cmake/MujocoHarden.cmake deleted file mode 100644 index 7beb88fe..00000000 --- a/cmake/MujocoHarden.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2022 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -option(MUJOCO_HARDEN "Enable build hardening for MuJoCo." OFF) -if(MUJOCO_HARDEN - AND NOT - CMAKE_CXX_COMPILER_ID - MATCHES - ".*Clang.*" -) - message(FATAL_ERROR "MUJOCO_HARDEN is only supported when building with Clang") -endif() - -if(MUJOCO_HARDEN) - set(MUJOCO_HARDEN_COMPILE_OPTIONS -D_FORTIFY_SOURCE=2 -fstack-protector) - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(MUJOCO_HARDEN_LINK_OPTIONS -Wl,-bind_at_load) - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(MUJOCO_HARDEN_LINK_OPTIONS -Wl,-z,relro -Wl,-z,now) - endif() -else() - set(MUJOCO_HARDEN_COMPILE_OPTIONS "") - set(MUJOCO_HARDEN_LINK_OPTIONS "") -endif() diff --git a/cmake/MujocoLinkOptions.cmake b/cmake/MujocoLinkOptions.cmake deleted file mode 100644 index 4bed36c2..00000000 --- a/cmake/MujocoLinkOptions.cmake +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include(CheckCSourceCompiles) - -# Gets the appropriate linker options for building MuJoCo, based on features available on the -# linker. -function(get_mujoco_extra_link_options OUTPUT_VAR) - if(MSVC) - set(EXTRA_LINK_OPTIONS /OPT:REF /OPT:ICF=5 /STACK:16777216) - else() - set(EXTRA_LINK_OPTIONS) - - if(WIN32) - set(CMAKE_REQUIRED_FLAGS "-fuse-ld=lld-link") - check_c_source_compiles("int main() {}" SUPPORTS_LLD_LINK) - if(SUPPORTS_LLD_LINK) - set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -fuse-ld=lld-link -Wl,/STACK:16777216 -Wl,/OPT:REF -Wl,/OPT:ICF) - else() - set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -Wl,--stack,16777216) - endif() - else() - set(CMAKE_REQUIRED_FLAGS "-fuse-ld=lld") - check_c_source_compiles("int main() {}" SUPPORTS_LLD) - if(SUPPORTS_LLD) - set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -fuse-ld=lld) - else() - set(CMAKE_REQUIRED_FLAGS "-fuse-ld=gold") - check_c_source_compiles("int main() {}" SUPPORTS_GOLD) - if(SUPPORTS_GOLD) - set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -fuse-ld=gold) - endif() - endif() - - set(CMAKE_REQUIRED_FLAGS "${EXTRA_LINK_OPTIONS} -Wl,--gc-sections") - check_c_source_compiles("int main() {}" SUPPORTS_GC_SECTIONS) - if(SUPPORTS_GC_SECTIONS) - set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -Wl,--gc-sections) - else() - set(CMAKE_REQUIRED_FLAGS "${EXTRA_LINK_OPTIONS} -Wl,-dead_strip") - check_c_source_compiles("int main() {}" SUPPORTS_DEAD_STRIP) - if(SUPPORTS_DEAD_STRIP) - set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -Wl,-dead_strip) - endif() - endif() - endif() - endif() - - set("${OUTPUT_VAR}" - ${EXTRA_LINK_OPTIONS} - PARENT_SCOPE - ) -endfunction() diff --git a/cmake/MujocoMacOS.cmake b/cmake/MujocoMacOS.cmake deleted file mode 100644 index 8ff7cd30..00000000 --- a/cmake/MujocoMacOS.cmake +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2022 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if(APPLE) - # Target the oldest version of macOS that is still supported by Apple. - # We follow https://endoflife.date/macos, which considers a version to become - # unsupported the first time it is excluded from a macOS security update - # (e.g. https://github.com/endoflife-date/endoflife.date/issues/1602). - set(MUJOCO_MACOSX_VERSION_MIN 11) - - # We are setting the -mmacosx-version-min compiler flag directly rather than using the - # CMAKE_OSX_DEPLOYMENT_TARGET variable since we do not want to affect choice of SDK, - # and also we only want to apply the version restriction locally. - set(MUJOCO_MACOS_COMPILE_OPTIONS -mmacosx-version-min=${MUJOCO_MACOSX_VERSION_MIN} - -Werror=partial-availability -Werror=unguarded-availability - ) - set(MUJOCO_MACOS_LINK_OPTIONS -mmacosx-version-min=${MUJOCO_MACOSX_VERSION_MIN} - -Wl,-no_weak_imports - ) -else() - set(MUJOCO_MACOS_COMPILE_OPTIONS "") - set(MUJOCO_MACOS_LINK_OPTIONS "") -endif() - -function(enforce_mujoco_macosx_min_version) - if(APPLE) - add_compile_options(${MUJOCO_MACOS_COMPILE_OPTIONS}) - add_link_options(${MUJOCO_MACOS_LINK_OPTIONS}) - endif() -endfunction() diff --git a/cmake/MujocoOptions.cmake b/cmake/MujocoOptions.cmake deleted file mode 100644 index 74bf25bb..00000000 --- a/cmake/MujocoOptions.cmake +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Global compilation settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -if(EMSCRIPTEN) - set(CMAKE_C_EXTENSIONS ON) -else() - set(CMAKE_C_EXTENSIONS OFF) -endif() -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # For LLVM tooling - -if(NOT CMAKE_CONFIGURATION_TYPES) - if(NOT CMAKE_BUILD_TYPE) - message(STATUS "Setting build type to 'Release' as none was specified.") - set(CMAKE_BUILD_TYPE - "Release" - CACHE STRING "Choose the type of build, recommanded options are: Debug or Release" FORCE - ) - endif() - set(BUILD_TYPES - "Debug" - "Release" - "MinSizeRel" - "RelWithDebInfo" - ) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES}) -endif() - -include(GNUInstallDirs) - -# Change the default output directory in the build structure. This is not stricly needed, but helps -# running in Windows, such that all built executables have DLLs in the same folder as the .exe -# files. -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") - -set(OpenGL_GL_PREFERENCE GLVND) - -set(CMAKE_POSITION_INDEPENDENT_CODE ON) -set(CMAKE_C_VISIBILITY_PRESET hidden) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) - -if(MSVC) - add_compile_options(/Gy /Gw /Oi) -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-fdata-sections -ffunction-sections) -endif() - -# We default to shared library. -set(BUILD_SHARED_LIBS - ON - CACHE BOOL "Build Mujoco as shared library." -) - -option(MUJOCO_ENABLE_AVX "Build binaries that require AVX instructions, if possible." ON) -option(MUJOCO_ENABLE_AVX_INTRINSICS "Make use of hand-written AVX intrinsics, if possible." ON) -option(MUJOCO_ENABLE_RPATH "Enable RPath support when installing Mujoco." ON) -mark_as_advanced(MUJOCO_ENABLE_RPATH) - -if(MUJOCO_ENABLE_AVX) - include(CheckAvxSupport) - get_avx_compile_options(AVX_COMPILE_OPTIONS) -else() - set(AVX_COMPILE_OPTIONS) -endif() - -option(MUJOCO_BUILD_MACOS_FRAMEWORKS "Build libraries as macOS Frameworks" OFF) - -# Get some extra link options. -include(MujocoLinkOptions) -get_mujoco_extra_link_options(EXTRA_LINK_OPTIONS) - -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT MSVC)) - set(EXTRA_COMPILE_OPTIONS - -Werror - -Wall - -Wpedantic - -Wimplicit-fallthrough - -Wunused - -Wvla - -Wno-int-in-bool-context - -Wno-sign-compare - -Wno-unknown-pragmas - ) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # Set -Wimplicit-fallthrough=5 to only allow fallthrough annotation via __attribute__. - set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wimplicit-fallthrough=5 - -Wno-maybe-uninitialized - ) - endif() -endif() - -# Provide a user-facing option to control Link-Time Optimization (LTO/IPO). -# When ON (the default), LTO is enabled for non-Debug builds unless the caller -# has already set CMAKE_INTERPROCEDURAL_OPTIMIZATION explicitly. -# Users can disable LTO entirely with -DMUJOCO_ENABLE_LTO=OFF. -option(MUJOCO_ENABLE_LTO "Enable Link-Time Optimization (LTO) for non-Debug builds." ON) - -if(MUJOCO_ENABLE_LTO) - if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION AND (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) - endif() -endif() - -include(MujocoHarden) -set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} ${MUJOCO_HARDEN_COMPILE_OPTIONS}) -set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} ${MUJOCO_HARDEN_LINK_OPTIONS}) - -if(WIN32) - add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE) -endif() diff --git a/cmake/ShellTests.cmake b/cmake/ShellTests.cmake deleted file mode 100644 index b26b1658..00000000 --- a/cmake/ShellTests.cmake +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -function(add_mujoco_shell_test TEST_NAME TARGET_BINARY) - find_program(BASH_PROGRAM bash) - if(BASH_PROGRAM) - # Set up the test directory - set(TEST_TMPDIR "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}") - add_test(NAME ${TEST_NAME}_setup - COMMAND ${BASH_PROGRAM} "${PROJECT_SOURCE_DIR}/cmake/setup_test_dir.sh" ${TEST_TMPDIR} - ) - set_tests_properties(${TEST_NAME}_setup PROPERTIES FIXTURES_SETUP ${TEST_NAME}_fixture) - add_test(NAME ${TEST_NAME}_cleanup - COMMAND ${BASH_PROGRAM} "${PROJECT_SOURCE_DIR}/cmake/cleanup_test_dir.sh" - ${TEST_TMPDIR} - ) - set_tests_properties(${TEST_NAME}_cleanup PROPERTIES FIXTURES_CLEANUP ${TEST_NAME}_fixture) - add_test( - NAME ${TEST_NAME} - COMMAND ${BASH_PROGRAM} "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}.sh" - WORKING_DIRECTORY $ - ) - set_tests_properties(${TEST_NAME} PROPERTIES FIXTURES_REQUIRED ${TEST_NAME}_fixture) - set_property( - TEST "${TEST_NAME}" - PROPERTY ENVIRONMENT - "CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}" - "TARGET_BINARY=$" - "TEST_TMPDIR=${TEST_TMPDIR}" - ) - if(WIN32) - # Define the directory containing the mujoco DLL library so that it can be added to the PATH. - # We modify the PATH in the script as it is more reliable. - set_property( - TEST "${TEST_NAME}" - APPEND - PROPERTY ENVIRONMENT "MUJOCO_DLL_DIR=$" - ) - endif() - endif() -endfunction() diff --git a/cmake/TargetAddRpath.cmake b/cmake/TargetAddRpath.cmake deleted file mode 100644 index 5fabdc36..00000000 --- a/cmake/TargetAddRpath.cmake +++ /dev/null @@ -1,194 +0,0 @@ -# Copyright 2022 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -#[=======================================================================[.rst: -TargetAddRpath ----------------------- - -Add support to RPATH for the specified targets - -.. command:: target_add_rpath - - Add support to RPATH for the specified targets:: - -.. code-block:: cmake - target_add_rpath(target1 target2 ... - INSTALL_DIRECTORY install_directory - LIB_DIRS dir1 dir2 ... - [INSTALL_NAME_DIR [dir]] - [DEPENDS condition [condition]] - [USE_LINK_PATH]) - - This function setups the RPATH paths for the specified targets. The use of - RPATH allows to avoid using the (dangerous) environment variable - ``LD_LIBRARY_PATH`` (or equivalent on macOS) when installing without absolute - paths. - By using RPATH the installation can be relocated as the linker will look for - (some of) the dependencies at run time. - - The function has the following parameters: - - Options: - - ``USE_LINK_PATH``: if defined, the function will set - ``INSTALL_RPATH_USE_LINK_PATH`` on all the specified targets, i.e. CMake - will automatically adds to the RPATH the path to all the dependent - libraries defined outside this project. - - Arguments: - - ``INSTALL_DIRECTORY`` The directory where the specified targets will be - installed. - - ``LIB_DIRS`` list of directories to be added a search path to the RPATH. - Note that the relative path between ``INSTALL_DIRECTORY`` and these - directories will be added to the RPATH. - - ``INSTALL_NAME_DIR`` directory where the libraries will be installed. - This variable will be used only if ``CMAKE_SKIP_RPATH`` or - ``CMAKE_SKIP_INSTALL_RPATH`` is set to ``TRUE`` as it will set the - ``INSTALL_NAME_DIR`` on all targets. - - ``DEPENDS`` list of conditions that should be ``TRUE`` to enable - RPATH, for example ``FOO; NOT BAR``. - - Note: see https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - and https://gitlab.kitware.com/cmake/cmake/issues/16589 for further details. - -#]=======================================================================] - -if(COMMAND target_add_rpath) - return() -endif() - -function(_get_system_dirs _output_var) - set(${_output_var} - ${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES} - PARENT_SCOPE - ) -endfunction() - -function( - _get_rpath_relative_path - _output_var - _bin_dir - _lib_dir -) - get_filename_component(_bin_dir_abs "${_bin_dir}" ABSOLUTE BASE_DIR "${CMAKE_BINARY_DIR}") - get_filename_component(_lib_dir_abs "${_lib_dir}" ABSOLUTE BASE_DIR "${CMAKE_BINARY_DIR}") - file( - RELATIVE_PATH - _rel_path - ${_bin_dir_abs} - ${_lib_dir_abs} - ) - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(${_output_var} - "@loader_path/${_rel_path}" - PARENT_SCOPE - ) - else() - set(${_output_var} - "\$ORIGIN/${_rel_path}" - PARENT_SCOPE - ) - endif() -endfunction() - -function(target_add_rpath) - if(WIN32) - return() - endif() - set(_options USE_LINK_PATH) - set(_oneValueArgs INSTALL_NAME_DIR INSTALL_DIRECTORY) - set(_multiValueArgs TARGETS LIB_DIRS DEPENDS) - - cmake_parse_arguments( - _ARGS - "${_options}" - "${_oneValueArgs}" - "${_multiValueArgs}" - "${ARGN}" - ) - - # Handle Apple-specific installation directory. Note that this disable proper RPATH. - if(CMAKE_SKIP_RPATH OR CMAKE_SKIP_INSTALL_RPATH) - if(DEFINED _ARGS_INSTALL_NAME_DIR) - set_target_properties(${_ARGS_TARGETS} PROPERTIES INSTALL_NAME_DIR ${_ARGS_INSTALL_NAME_DIR}) - endif() - endif() - - # If RPATH is disabled, do nothing and return. - if(CMAKE_SKIP_RPATH OR (CMAKE_SKIP_INSTALL_RPATH AND CMAKE_SKIP_BUILD_RPATH)) - return() - endif() - - # Check if the user requested RPATH for the specified targets. - set(_enable_rpath ON) - if(DEFINED _ARGS_DEPENDS) - foreach(_cond ${_ARGS_DEPENDS}) - string( - REGEX - REPLACE " +" - ";" - _cond - "${_cond}" - ) - if(NOT (${_cond})) - set(_enable_rpath OFF) - endif() - endforeach() - endif() - - if(NOT _enable_rpath) - return() - endif() - - # Now enable RPATH for the specified targets. - _get_system_dirs(_system_dirs) - - # We do this per target to preserve the original rpath setting. - foreach(_target ${_ARGS_TARGETS}) - get_target_property(_install_rpath ${_target} INSTALL_RPATH) - - foreach(_lib_dir ${_ARGS_LIB_DIRS}) - # Check if the specified library path is a system directory. These are always searched so we do - # not need to include them in the RPATH. - list( - FIND - _system_dirs - "${_lib_dir}" - is_system_dir - ) - if("${is_system_dir}" STREQUAL "-1") - - _get_rpath_relative_path(_bin_lib_rel_path ${_ARGS_INSTALL_DIRECTORY} ${_lib_dir}) - list(APPEND _install_rpath ${_bin_lib_rel_path}) - - endif() - endforeach() - - if(NOT - "${_install_rpath}" - STREQUAL - "" - ) - list(REMOVE_DUPLICATES _install_rpath) - endif() - - set_target_properties( - ${_target} - PROPERTIES INSTALL_RPATH "${_install_rpath}" - INSTALL_RPATH_USE_LINK_PATH ${_ARGS_USE_LINK_PATH} - BUILD_WITH_INSTALL_RPATH TRUE - MACOSX_RPATH ON # This is ON by default. - ) - endforeach() - -endfunction() diff --git a/cmake/abseil-cpp-source_location.patch b/cmake/abseil-cpp-source_location.patch deleted file mode 100644 index 821a6539..00000000 --- a/cmake/abseil-cpp-source_location.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/absl/base/options.h b/absl/base/options.h ---- a/absl/base/options.h -+++ b/absl/base/options.h -@@ -99,6 +99,6 @@ - // the source location type is an alias of std::source_location type, use the - // feature macro ABSL_USES_STD_SOURCE_LOCATION. - // --#define ABSL_OPTION_USE_STD_SOURCE_LOCATION 2 -+#define ABSL_OPTION_USE_STD_SOURCE_LOCATION 0 - - // ABSL_OPTION_USE_STD_ORDERING -diff --git a/absl/base/config.h b/absl/base/config.h ---- a/absl/base/config.h -+++ b/absl/base/config.h -@@ -543,5 +543,7 @@ - #ifdef __has_include - #if __has_include() --#define ABSL_HAVE_STD_SOURCE_LOCATION 1 -+#if !defined(__clang__) || ABSL_HAVE_BUILTIN(__builtin_source_location) -+#define ABSL_HAVE_STD_SOURCE_LOCATION 1 -+#endif - #endif - #else diff --git a/cmake/ccd-support-emscripten.patch b/cmake/ccd-support-emscripten.patch deleted file mode 100644 index 11568264..00000000 --- a/cmake/ccd-support-emscripten.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 1407080..b4dea44 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -49,9 +49,14 @@ target_include_directories(ccd PUBLIC - $) - - if(NOT WIN32) -- find_library(LIBM_LIBRARY NAMES m) -- if(NOT LIBM_LIBRARY) -- message(FATAL_ERROR "Could NOT find required library LibM") -+ if (EMSCRIPTEN) -+ set(LIBM_LIBRARY "-lm") -+ message("Subtitute LibM with emscripten -lm") -+ else() -+ find_library(LIBM_LIBRARY NAMES m) -+ if(NOT LIBM_LIBRARY) -+ message(FATAL_ERROR "Could NOT find required library LibM") -+ endif() - endif() - target_link_libraries(ccd "${LIBM_LIBRARY}") - if(BUILD_SHARED_LIBS) diff --git a/cmake/cleanup_test_dir.sh b/cmake/cleanup_test_dir.sh deleted file mode 100755 index ed333b31..00000000 --- a/cmake/cleanup_test_dir.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if [ -z "$1" ]; then - echo "Expecting an output directory. Got none." 1>&2 - exit 1 -fi - -rm -rf "$1" diff --git a/cmake/filament-allow-clang-windows.patch b/cmake/filament-allow-clang-windows.patch deleted file mode 100644 index fda7a48c..00000000 --- a/cmake/filament-allow-clang-windows.patch +++ /dev/null @@ -1,543 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 016e5ec5d..d2a6aae37 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -11,12 +11,7 @@ cmake_minimum_required(VERSION 3.22.1) - # Unsupported environment - # ================================================================================================== - --# Filament does not support MSYS2-based environment on Windows. See issue #9968. --if(DEFINED ENV{MSYSTEM}) -- message(FATAL_ERROR -- "MSYS2 Subsystem detected($ENV{MSYSTEM}). " -- "Filament does not support MSYS2-based environment on Windows.") --endif() -+ - - # ================================================================================================== - # Toolchain configuration -@@ -264,57 +259,59 @@ if (WIN32) - # __declspec(dllexport) in front of each functions). - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - -- # The CMAKE_CXX_FLAGS vars can be overriden by some Visual Studio generators, so we use an alternative -- # global method here: -- if (${USE_STATIC_CRT}) -- add_compile_options( -- $<$:/MT> -- $<$:/MTd> -- $<$:/MT> -- ) -- else() -- add_compile_options( -- $<$:/MD> -- $<$:/MDd> -- $<$:/MD> -- ) -- endif() -- -- # TODO: Figure out why pdb generation messes with incremental compilaton. -- # IN RELEASE_WITH_DEBUG_INFO, generate debug info in .obj, no in pdb. -- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Z7") -- set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Z7") -- -- # In RELEASE, also generate PDBs. -- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") -- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi") -- -- # In DEBUG, avoid generating a PDB file which seems to mess with incremental compilation. -- # Instead generate debug info directly inside obj files. -- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7") -- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7") -- -- # Special settings when building on CI. -- if (${FILAMENT_WINDOWS_CI_BUILD}) -- set(LinkerFlags -- CMAKE_SHARED_LINKER_FLAGS_DEBUG -- CMAKE_EXE_LINKER_FLAGS_DEBUG -- CMAKE_MODULE_LINKER_FLAGS_DEBUG -+ if (MSVC) -+ # The CMAKE_CXX_FLAGS vars can be overriden by some Visual Studio generators, so we use an alternative -+ # global method here: -+ if (${USE_STATIC_CRT}) -+ add_compile_options( -+ $<$:/MT> -+ $<$:/MTd> -+ $<$:/MT> - ) -- foreach(LinkerFlag ${LinkerFlags}) -- # The /debug flag outputs .pdb files, which we don't need on CI. -- string(REPLACE "/debug" "" ${LinkerFlag} ${${LinkerFlag}}) -- -- # The /INCREMENTAL flag outputs .ilk files for incremental linking. These are huge, and -- # we don't need them on CI. -- string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" ${LinkerFlag} ${${LinkerFlag}}) -- endforeach() -- -- # We turn off compile-time optimizations for CI, as options that speed up the compile-time -- # (e.g. /MP) might increase memory usage, leading to instabilities on limited CI machines. -- option(FILAMENT_SHORTEN_MSVC_COMPILATION "Shorten compile-time in Visual Studio" OFF) -- else() -- option(FILAMENT_SHORTEN_MSVC_COMPILATION "Shorten compile-time in Visual Studio" ON) -+ else() -+ add_compile_options( -+ $<$:/MD> -+ $<$:/MDd> -+ $<$:/MD> -+ ) -+ endif() -+ -+ # TODO: Figure out why pdb generation messes with incremental compilaton. -+ # IN RELEASE_WITH_DEBUG_INFO, generate debug info in .obj, no in pdb. -+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Z7") -+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Z7") -+ -+ # In RELEASE, also generate PDBs. -+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") -+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi") -+ -+ # In DEBUG, avoid generating a PDB file which seems to mess with incremental compilation. -+ # Instead generate debug info directly inside obj files. -+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7") -+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7") -+ -+ # Special settings when building on CI. -+ if (${FILAMENT_WINDOWS_CI_BUILD}) -+ set(LinkerFlags -+ CMAKE_SHARED_LINKER_FLAGS_DEBUG -+ CMAKE_EXE_LINKER_FLAGS_DEBUG -+ CMAKE_MODULE_LINKER_FLAGS_DEBUG -+ ) -+ foreach(LinkerFlag ${LinkerFlags}) -+ # The /debug flag outputs .pdb files, which we don't need on CI. -+ string(REPLACE "/debug" "" ${LinkerFlag} ${${LinkerFlag}}) -+ -+ # The /INCREMENTAL flag outputs .ilk files for incremental linking. These are huge, and -+ # we don't need them on CI. -+ string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" ${LinkerFlag} ${${LinkerFlag}}) -+ endforeach() -+ -+ # We turn off compile-time optimizations for CI, as options that speed up the compile-time -+ # (e.g. /MP) might increase memory usage, leading to instabilities on limited CI machines. -+ option(FILAMENT_SHORTEN_MSVC_COMPILATION "Shorten compile-time in Visual Studio" OFF) -+ else() -+ option(FILAMENT_SHORTEN_MSVC_COMPILATION "Shorten compile-time in Visual Studio" ON) -+ endif() - endif() - - if (MSVC) -@@ -361,7 +358,7 @@ endif() - # Detect use of the clang-cl.exe frontend, which does not support all of clangs normal options - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if ("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") -- message(FATAL_ERROR "Building with Clang on Windows is no longer supported. Use MSVC 2019 instead.") -+ message(WARNING "Building with Clang on Windows is experimental (re-enabled by patch).") - endif() - endif() - -@@ -393,7 +390,7 @@ if (APPLE AND NOT IOS) - endif() - - set(CXX_STANDARD "-std=c++20") --if (WIN32) -+if (MSVC) - set(CXX_STANDARD "/std:c++20") - endif() - -@@ -787,9 +784,14 @@ function(combine_static_libs TARGET OUTPUT DEPS) - endforeach() - - if (WIN32) -+ if (MSVC) -+ set(AR_COMMAND "${CMAKE_AR}" /nologo /out:temp.lib ${DEPS_FILES}) -+ else() -+ set(AR_COMMAND "${CMAKE_AR}" rcs temp.lib ${DEPS_FILES}) -+ endif() - add_custom_command( - TARGET ${TARGET} POST_BUILD -- COMMAND lib.exe /nologo /out:temp.lib ${DEPS_FILES} -+ COMMAND ${AR_COMMAND} - COMMAND "${CMAKE_COMMAND}" -E rename temp.lib ${OUTPUT} - COMMENT "Combining ${target} dependencies into single shared library" - VERBATIM -diff --git a/filament/CMakeLists.txt b/filament/CMakeLists.txt -index c334d0a9f..9f8004e3d 100644 ---- a/filament/CMakeLists.txt -+++ b/filament/CMakeLists.txt -@@ -808,6 +808,9 @@ else() - -Wover-aligned - -Werror - ) -+ if (WIN32) -+ list(APPEND FILAMENT_WARNINGS -Wno-error=cast-function-type-mismatch -Wno-error=unused-variable -Wno-error=microsoft-unqualified-friend) -+ endif() - endif() - - target_compile_options(${TARGET} PRIVATE -diff --git a/filament/backend/CMakeLists.txt b/filament/backend/CMakeLists.txt -index 78c05dd22..4f8c0bf3d 100644 ---- a/filament/backend/CMakeLists.txt -+++ b/filament/backend/CMakeLists.txt -@@ -525,6 +525,10 @@ else() - ) - endif() - -+if (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") -+ list(APPEND FILAMENT_WARNINGS -Wno-error=cast-function-type-mismatch -Wno-error=unused-variable -Wno-error=microsoft-unqualified-friend) -+endif() -+ - if (APPLE) - # Turn on Automatic Reference Counting. - target_compile_options(${TARGET} PRIVATE "-fobjc-arc") -diff --git a/filament/backend/src/CommandStream.cpp b/filament/backend/src/CommandStream.cpp -index 7146800f6..d7973ffd4 100644 ---- a/filament/backend/src/CommandStream.cpp -+++ b/filament/backend/src/CommandStream.cpp -@@ -57,7 +57,7 @@ static void printParameterPack(io::ostream& out, const FIRST& first, const REMAI - printParameterPack(out, rest...); - } - --static UTILS_NOINLINE UTILS_UNUSED std::string_view extractMethodName(std::string_view command) noexcept { // NOLINT(*-exception-escape) -+UTILS_UNUSED static UTILS_NOINLINE std::string_view extractMethodName(std::string_view command) noexcept { // NOLINT(*-exception-escape) - constexpr char startPattern[] = "::Command<&filament::backend::Driver::"; - auto pos = command.rfind(startPattern); - auto end = command.rfind('('); -diff --git a/filament/backend/src/opengl/platforms/PlatformWGL.cpp b/filament/backend/src/opengl/platforms/PlatformWGL.cpp -index 318430289..8664ea3cf 100644 ---- a/filament/backend/src/opengl/platforms/PlatformWGL.cpp -+++ b/filament/backend/src/opengl/platforms/PlatformWGL.cpp -@@ -251,7 +251,7 @@ Platform::SwapChain* PlatformWGL::createSwapChain(uint32_t width, uint32_t heigh - // WS_POPUP was chosen for the window style here after some experimentation. - // For some reason, using other window styles resulted in corrupted pixel buffers when using - // readPixels. -- RECT rect = {0, 0, width, height}; -+ RECT rect = {0, 0, static_cast(width), static_cast(height)}; - AdjustWindowRect(&rect, WS_POPUP, FALSE); - width = rect.right - rect.left; - height = rect.bottom - rect.top; -diff --git a/libs/ibl/src/CubemapIBL.cpp b/libs/ibl/src/CubemapIBL.cpp -index 60f83174d..1deb01857 100644 ---- a/libs/ibl/src/CubemapIBL.cpp -+++ b/libs/ibl/src/CubemapIBL.cpp -@@ -56,7 +56,7 @@ static float3 hemisphereImportanceSampleDggx(float2 u, float a) { // pdf = D(a) - return { sinTheta * std::cos(phi), sinTheta * std::sin(phi), cosTheta }; - } - --static float3 UTILS_UNUSED hemisphereCosSample(float2 u) { // pdf = cosTheta / F_PI; -+UTILS_UNUSED static float3 hemisphereCosSample(float2 u) { // pdf = cosTheta / F_PI; - const float phi = 2.0f * (float) F_PI * u.x; - const float cosTheta2 = 1 - u.y; - const float cosTheta = std::sqrt(cosTheta2); -@@ -64,7 +64,7 @@ static float3 UTILS_UNUSED hemisphereCosSample(float2 u) { // pdf = cosTheta / - return { sinTheta * std::cos(phi), sinTheta * std::sin(phi), cosTheta }; - } - --static float3 UTILS_UNUSED hemisphereUniformSample(float2 u) { // pdf = 1.0 / (2.0 * F_PI); -+UTILS_UNUSED static float3 hemisphereUniformSample(float2 u) { // pdf = 1.0 / (2.0 * F_PI); - const float phi = 2.0f * (float) F_PI * u.x; - const float cosTheta = 1 - u.y; - const float sinTheta = std::sqrt(1 - cosTheta * cosTheta); -@@ -128,7 +128,7 @@ static float3 UTILS_UNUSED hemisphereUniformSample(float2 u) { // pdf = 1.0 / (2 - * | | - * +--------------------------------------------+ - */ --static float3 UTILS_UNUSED hemisphereImportanceSampleDCharlie(float2 u, float a) { // pdf = DistributionCharlie() * cosTheta -+UTILS_UNUSED static float3 hemisphereImportanceSampleDCharlie(float2 u, float a) { // pdf = DistributionCharlie() * cosTheta - const float phi = 2.0f * (float) F_PI * u.x; - - const float sinTheta = std::pow(u.y, a / (2 * a + 1)); -@@ -144,7 +144,7 @@ static float DistributionGGX(float NoH, float linearRoughness) { - return (a * a) / ((float) F_PI * f * f); - } - --static float UTILS_UNUSED DistributionAshikhmin(float NoH, float linearRoughness) { -+UTILS_UNUSED static float DistributionAshikhmin(float NoH, float linearRoughness) { - float a = linearRoughness; - float a2 = a * a; - float cos2h = NoH * NoH; -@@ -153,7 +153,7 @@ static float UTILS_UNUSED DistributionAshikhmin(float NoH, float linearRoughness - return 1.0f / ((float) F_PI * (1 + 4 * a2)) * (sin4h + 4 * std::exp(-cos2h / (a2 * sin2h))); - } - --static float UTILS_UNUSED DistributionCharlie(float NoH, float linearRoughness) { -+UTILS_UNUSED static float DistributionCharlie(float NoH, float linearRoughness) { - // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF" - float a = linearRoughness; - float invAlpha = 1 / a; -@@ -176,7 +176,7 @@ static float Visibility(float NoV, float NoL, float a) { - return 0.5f / (GGXV + GGXL); - } - --static float UTILS_UNUSED VisibilityAshikhmin(float NoV, float NoL, float /*a*/) { -+UTILS_UNUSED static float VisibilityAshikhmin(float NoV, float NoL, float /*a*/) { - // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" - return 1 / (4 * (NoL + NoV - NoL * NoV)); - } -@@ -634,7 +634,7 @@ void CubemapIBL::diffuseIrradiance(JobSystem& js, Cubemap& dst, const std::vecto - } - - // Not importance-sampled --static float2 UTILS_UNUSED DFV_NoIS(float NoV, float roughness, size_t numSamples) { -+UTILS_UNUSED static float2 DFV_NoIS(float NoV, float roughness, size_t numSamples) { - float2 r = 0; - const float linearRoughness = roughness * roughness; - const float3 V(std::sqrt(1 - NoV * NoV), 0, NoV); -@@ -832,7 +832,7 @@ static float2 DFV_Multiscatter(float NoV, float linearRoughness, size_t numSampl - return r * (4.0f / numSamples); - } - --static float UTILS_UNUSED DFV_LazanyiTerm(float NoV, float linearRoughness, size_t numSamples) { -+UTILS_UNUSED static float DFV_LazanyiTerm(float NoV, float linearRoughness, size_t numSamples) { - float r = 0; - const float cosThetaMax = (float) std::cos(81.7 * F_PI / 180.0); - const float q = 1.0f / (cosThetaMax * pow6(1.0f - cosThetaMax)); -@@ -958,7 +958,7 @@ static float DFV_Charlie_Uniform(float NoV, float linearRoughness, size_t numSam - * +---------------------------------------+ - * - */ --static float UTILS_UNUSED DFV_Charlie_IS(float NoV, float linearRoughness, size_t numSamples) { -+UTILS_UNUSED static float DFV_Charlie_IS(float NoV, float linearRoughness, size_t numSamples) { - float r = 0.0; - const float3 V(std::sqrt(1 - NoV * NoV), 0, NoV); - for (size_t i = 0; i < numSamples; i++) { -diff --git a/libs/ibl/src/CubemapSH.cpp b/libs/ibl/src/CubemapSH.cpp -index 5d22cb804..f8adccc71 100644 ---- a/libs/ibl/src/CubemapSH.cpp -+++ b/libs/ibl/src/CubemapSH.cpp -@@ -685,7 +685,7 @@ void CubemapSH::renderPreScaledSH3Bands(JobSystem& js, - // Only used for debugging - // ----------------------------------------------------------------------------------------------- - --float UTILS_UNUSED CubemapSH::Legendre(ssize_t l, ssize_t m, float x) { -+UTILS_UNUSED float CubemapSH::Legendre(ssize_t l, ssize_t m, float x) { - // evaluate an Associated Legendre Polynomial P(l,m,x) at x - float pmm = 1.0; - if (m > 0) { -@@ -711,7 +711,7 @@ float UTILS_UNUSED CubemapSH::Legendre(ssize_t l, ssize_t m, float x) { - } - - // Only used for debugging --float UTILS_UNUSED CubemapSH::TSH(int l, int m, const float3& d) { -+UTILS_UNUSED float CubemapSH::TSH(int l, int m, const float3& d) { - if (l==0 && m==0) { - return 1 / (2*sqrt(F_PI)); - } else if (l==1 && m==-1) { -@@ -734,7 +734,7 @@ float UTILS_UNUSED CubemapSH::TSH(int l, int m, const float3& d) { - return 0; - } - --void UTILS_UNUSED CubemapSH::printShBase(std::ostream& out, int l, int m) { -+UTILS_UNUSED void CubemapSH::printShBase(std::ostream& out, int l, int m) { - if (l<3 && std::abs(m) <= l) { - const char* d = nullptr; - float c = 0; -diff --git a/libs/imageio/src/ImageEncoder.cpp b/libs/imageio/src/ImageEncoder.cpp -index 9f83c6c62..6593581e3 100644 ---- a/libs/imageio/src/ImageEncoder.cpp -+++ b/libs/imageio/src/ImageEncoder.cpp -@@ -867,39 +867,39 @@ const uint32_t DDS_FOURCC_DX10 = 0x30315844; // "DX10" - - #pragma pack(push, 1) - struct DDS_PIXELFORMAT { -- uint32_t UTILS_UNUSED dwSize; -+ UTILS_UNUSED uint32_t dwSize; - uint32_t dwFlags; -- uint32_t UTILS_UNUSED dwFourCC; -- uint32_t UTILS_UNUSED dwRGBBitCount; -- uint32_t UTILS_UNUSED dwRBitMask; -- uint32_t UTILS_UNUSED dwGBitMask; -- uint32_t UTILS_UNUSED dwBBitMask; -- uint32_t UTILS_UNUSED dwABitMask; -+ UTILS_UNUSED uint32_t dwFourCC; -+ UTILS_UNUSED uint32_t dwRGBBitCount; -+ UTILS_UNUSED uint32_t dwRBitMask; -+ UTILS_UNUSED uint32_t dwGBitMask; -+ UTILS_UNUSED uint32_t dwBBitMask; -+ UTILS_UNUSED uint32_t dwABitMask; - }; - - struct DDS_HEADER { -- uint32_t UTILS_UNUSED dwSize; -+ UTILS_UNUSED uint32_t dwSize; - uint32_t dwFlags; -- uint32_t UTILS_UNUSED dwHeight; -- uint32_t UTILS_UNUSED dwWidth; -- uint32_t UTILS_UNUSED dwPitchOrLinearSize; -- uint32_t UTILS_UNUSED dwDepth; -- uint32_t UTILS_UNUSED dwMipMapCount; -- uint32_t UTILS_UNUSED dwReserved1[11]; -- DDS_PIXELFORMAT UTILS_UNUSED ddspf; -- uint32_t UTILS_UNUSED dwCaps; -- uint32_t UTILS_UNUSED dwCaps2; -- uint32_t UTILS_UNUSED dwCaps3; -- uint32_t UTILS_UNUSED dwCaps4; -- uint32_t UTILS_UNUSED dwReserved2; -+ UTILS_UNUSED uint32_t dwHeight; -+ UTILS_UNUSED uint32_t dwWidth; -+ UTILS_UNUSED uint32_t dwPitchOrLinearSize; -+ UTILS_UNUSED uint32_t dwDepth; -+ UTILS_UNUSED uint32_t dwMipMapCount; -+ UTILS_UNUSED uint32_t dwReserved1[11]; -+ UTILS_UNUSED DDS_PIXELFORMAT ddspf; -+ UTILS_UNUSED uint32_t dwCaps; -+ UTILS_UNUSED uint32_t dwCaps2; -+ UTILS_UNUSED uint32_t dwCaps3; -+ UTILS_UNUSED uint32_t dwCaps4; -+ UTILS_UNUSED uint32_t dwReserved2; - }; - - struct DDS_HEADER_DXT10 { - uint32_t dxgiFormat; -- uint32_t UTILS_UNUSED resourceDimension; -- uint32_t UTILS_UNUSED miscFlag; -- uint32_t UTILS_UNUSED arraySize; -- uint32_t UTILS_UNUSED miscFlags2; -+ UTILS_UNUSED uint32_t resourceDimension; -+ UTILS_UNUSED uint32_t miscFlag; -+ UTILS_UNUSED uint32_t arraySize; -+ UTILS_UNUSED uint32_t miscFlags2; - }; - #pragma pack(pop) - -diff --git a/libs/utils/include/utils/StructureOfArrays.h b/libs/utils/include/utils/StructureOfArrays.h -index 7ee9da70b..956aa8ec0 100644 ---- a/libs/utils/include/utils/StructureOfArrays.h -+++ b/libs/utils/include/utils/StructureOfArrays.h -@@ -742,7 +742,7 @@ typename StructureOfArraysBase::IteratorValueRef& - StructureOfArraysBase::IteratorValueRef::assign( - IteratorValue const& rhs, std::index_sequence) { - // implements IteratorValueRef& IteratorValueRef::operator=(IteratorValue const& rhs) -- auto UTILS_UNUSED l = { (soa->elementAt(index) = std::get(rhs.elements), 0)... }; -+ UTILS_UNUSED auto l = { (soa->elementAt(index) = std::get(rhs.elements), 0)... }; - return *this; - } - -@@ -751,7 +751,7 @@ template - typename StructureOfArraysBase::IteratorValueRef& - StructureOfArraysBase::IteratorValueRef::assign( - Structure const& rhs, std::index_sequence) { -- auto UTILS_UNUSED l = {(soa->template elementAt(index) = std::get(rhs), 0)...}; -+ UTILS_UNUSED auto l = {(soa->template elementAt(index) = std::get(rhs), 0)...}; - return *this; - } - -@@ -760,7 +760,7 @@ template - typename StructureOfArraysBase::IteratorValueRef& - StructureOfArraysBase::IteratorValueRef::assign( - Structure&& rhs, std::index_sequence) noexcept { -- auto UTILS_UNUSED l = {(soa->template elementAt(index) = std::move(std::get(rhs)), 0)...}; -+ UTILS_UNUSED auto l = {(soa->template elementAt(index) = std::move(std::get(rhs)), 0)...}; - return *this; - } - -@@ -770,7 +770,7 @@ typename StructureOfArraysBase::IteratorValueRef& - StructureOfArraysBase::IteratorValueRef::assign( - IteratorValue&& rhs, std::index_sequence) noexcept { - // implements IteratorValueRef& IteratorValueRef::operator=(IteratorValue&& rhs) noexcept -- auto UTILS_UNUSED l = { -+ UTILS_UNUSED auto l = { - (soa->elementAt(index) = std::move(std::get(rhs.elements)), 0)... }; - return *this; - } -diff --git a/libs/utils/include/utils/compiler.h b/libs/utils/include/utils/compiler.h -index f678e36e7..3f1b94cf3 100644 ---- a/libs/utils/include/utils/compiler.h -+++ b/libs/utils/include/utils/compiler.h -@@ -228,7 +228,7 @@ - // AND multi-threading is enabled (UTILS_HAS_THREADING is not 0). - // This prevents compile failures on single-threaded targets or builds where standard - // annotations are disabled by default in the platform's standard library headers. --#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && UTILS_HAS_THREADING -+#if defined(_LIBCPP_VERSION) && defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && UTILS_HAS_THREADING && !defined(_WIN32) - #define UTILS_THREAD_ANNOTATION_ATTRIBUTE(x) __attribute__((x)) - #else - #define UTILS_THREAD_ANNOTATION_ATTRIBUTE(x) -diff --git a/libs/utils/src/CallStack.cpp b/libs/utils/src/CallStack.cpp -index 644df0c97..dda872816 100644 ---- a/libs/utils/src/CallStack.cpp -+++ b/libs/utils/src/CallStack.cpp -@@ -92,7 +92,7 @@ void CallStack::update(size_t ignore) noexcept { - update_gcc(ignore); - } - --void CallStack::update_gcc(size_t UTILS_UNUSED ignore) noexcept { -+void CallStack::update_gcc(UTILS_UNUSED size_t ignore) noexcept { - // reset the object - ssize_t size = 0; - -@@ -141,7 +141,7 @@ CString CallStack::demangleTypeName(const char* mangled) { - // ------------------------------------------------------------------------------------------------ - - template --Stream& printCallStack(Stream& stream, CallStack const& UTILS_UNUSED callstack) { -+Stream& printCallStack(Stream& stream, UTILS_UNUSED CallStack const& callstack) { - #if HAS_EXECINFO - size_t const size = callstack.getFrameCount(); - char buf[1024]; -diff --git a/third_party/getopt/src/getopt.c b/third_party/getopt/src/getopt.c -index cf2984af0..1dacef630 100644 ---- a/third_party/getopt/src/getopt.c -+++ b/third_party/getopt/src/getopt.c -@@ -1,5 +1,6 @@ - #ifdef _WIN32 - #include -+#include - #else - #include - #endif -diff --git a/third_party/spirv-cross/CMakeLists.txt b/third_party/spirv-cross/CMakeLists.txt -index 8e5129c8b..761911083 100644 ---- a/third_party/spirv-cross/CMakeLists.txt -+++ b/third_party/spirv-cross/CMakeLists.txt -@@ -20,7 +20,11 @@ - # - - cmake_minimum_required(VERSION 3.10) --set(CMAKE_CXX_STANDARD 11) -+if (WIN32) -+ set(CMAKE_CXX_STANDARD 17) -+else() -+ set(CMAKE_CXX_STANDARD 11) -+endif() - set(CMAKE_CXX_EXTENSIONS OFF) - - # Avoid a warning if parent project sets VERSION in project(). -diff --git a/third_party/spirv-cross/tnt/CMakeLists.txt b/third_party/spirv-cross/tnt/CMakeLists.txt -index 4cb9bdccb..086bec67a 100644 ---- a/third_party/spirv-cross/tnt/CMakeLists.txt -+++ b/third_party/spirv-cross/tnt/CMakeLists.txt -@@ -37,7 +37,11 @@ endif() - # -DCMAKE_CXX_COMPILE_FLAGS - # However, we require the C++11 dialect. - if (NOT "${MSVC}") -- set(spirv-compiler-options ${spirv-compiler-options} -std=c++11 -Wall -Wextra -Werror -Wshadow) -+ if (WIN32) -+ set(spirv-compiler-options ${spirv-compiler-options} -std=c++17 -Wall -Wextra -Werror -Wshadow) -+ else() -+ set(spirv-compiler-options ${spirv-compiler-options} -std=c++11 -Wall -Wextra -Werror -Wshadow) -+ endif() - set(spirv-compiler-defines ${spirv-compiler-defines} __STDC_LIMIT_MACROS) - - if(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) -diff --git a/tools/cmgen/src/cmgen.cpp b/tools/cmgen/src/cmgen.cpp -index 722e5737c..288be3ce9 100644 ---- a/tools/cmgen/src/cmgen.cpp -+++ b/tools/cmgen/src/cmgen.cpp -@@ -131,7 +131,7 @@ static void outputSh(std::ostream& out, const std::unique_ptr& sh, - size_t numBands); --static void UTILS_UNUSED outputSpectrum(std::ostream& out, -+UTILS_UNUSED static void outputSpectrum(std::ostream& out, - const std::unique_ptr& sh, size_t numBands); - static void saveImage(const std::string& path, ImageEncoder::Format format, const Image& image, - const std::string& compression); -@@ -846,7 +846,7 @@ void outputBinarySh(std::ostream& out, - } - - --void UTILS_UNUSED outputSpectrum(std::ostream& out, -+UTILS_UNUSED void outputSpectrum(std::ostream& out, - const std::unique_ptr& sh, size_t numBands) { - // We assume a symetrical function (i.e. m!=0 terms are zero) - for (ssize_t l = 0; l < numBands; l++) { diff --git a/cmake/libwebp-apple-float16.patch b/cmake/libwebp-apple-float16.patch deleted file mode 100644 index a2af3e5f..00000000 --- a/cmake/libwebp-apple-float16.patch +++ /dev/null @@ -1,8 +0,0 @@ -diff --git a/cmake/cpu.cmake b/cmake/cpu.cmake ---- a/cmake/cpu.cmake -+++ b/cmake/cpu.cmake -@@ -121,3 +121,3 @@ - # Explicitly disable SIMD. -- if(SIMD_DISABLE_FLAGS) -+ if(SIMD_DISABLE_FLAGS AND NOT APPLE) - list(GET SIMD_DISABLE_FLAGS ${I_SIMD} SIMD_COMPILE_FLAG) diff --git a/cmake/mujocoConfig.cmake.in b/cmake/mujocoConfig.cmake.in deleted file mode 100644 index d00d1cc4..00000000 --- a/cmake/mujocoConfig.cmake.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) -find_dependency(OpenGL) - -if(NOT TARGET mujoco AND NOT @PROJECT_NAME@_BINARY_DIR) - include("${CMAKE_CURRENT_LIST_DIR}/mujocoTargets.cmake") -endif() - -check_required_components(mujoco) diff --git a/cmake/qhull-support-emscripten.patch b/cmake/qhull-support-emscripten.patch deleted file mode 100644 index ee82aeb6..00000000 --- a/cmake/qhull-support-emscripten.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 0423820..c5295c1 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -360,6 +360,7 @@ if (NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH) - set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - endif () - -+if (NOT EMSCRIPTEN) - add_library(${qhull_SHAREDR} SHARED - ${libqhullr_SOURCES} - src/libqhull_r/qhull_r-exports.def) -@@ -420,7 +421,7 @@ set_target_properties(${qhull_SHAREDP} PROPERTIES - if(UNIX) - target_link_libraries(${qhull_SHAREDP} m) - endif(UNIX) -- -+endif (NOT EMSCRIPTEN) - # --------------------------------------- - # Define static libraries qhullstatic (non-reentrant) and qhullstatic_r (reentrant) - # --------------------------------------- -@@ -475,7 +476,7 @@ if(NOT ${BUILD_STATIC_LIBS}) - set_target_properties(${qhull_STATICR} PROPERTIES EXCLUDE_FROM_ALL TRUE) - set_target_properties(${qhull_CPP} PROPERTIES EXCLUDE_FROM_ALL TRUE) - endif() --if(NOT ${BUILD_SHARED_LIBS}) -+if(NOT ${BUILD_SHARED_LIBS} AND NOT EMSCRIPTEN) - set_target_properties(${qhull_SHARED} PROPERTIES EXCLUDE_FROM_ALL TRUE) - set_target_properties(${qhull_SHAREDR} PROPERTIES EXCLUDE_FROM_ALL TRUE) - set_target_properties(${qhull_SHAREDP} PROPERTIES EXCLUDE_FROM_ALL TRUE) diff --git a/cmake/setup_test_dir.sh b/cmake/setup_test_dir.sh deleted file mode 100755 index 46ec06db..00000000 --- a/cmake/setup_test_dir.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 2021 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if [ -z "$1" ]; then - echo "Expecting an output directory. Got none." 1>&2 - exit 1 -fi - -mkdir -p "$1" -rm -rf "$1/*" diff --git a/cmake/third_party_deps/atkinson_hyperlegible_mono.cmake b/cmake/third_party_deps/atkinson_hyperlegible_mono.cmake deleted file mode 100644 index bc0fd532..00000000 --- a/cmake/third_party_deps/atkinson_hyperlegible_mono.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2026 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MUJOCO_DEP_VERSION_atkinson_hyperlegible_mono - 154d50362016cc3e873eb21d242cd0772384c8f9 - CACHE STRING "Tag/version of `atkinson_hyperlegible_mono` to be fetched." -) -mark_as_advanced(MUJOCO_DEP_VERSION_atkinson_hyperlegible_mono) - -include(FindOrFetch) - -fetchpackage( - PACKAGE_NAME atkinson_hyperlegible_mono - GIT_REPO https://github.com/googlefonts/atkinson-hyperlegible-next-mono.git - GIT_TAG ${MUJOCO_DEP_VERSION_atkinson_hyperlegible_mono} - CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/atkinson_hyperlegible_mono/CMakeLists.txt" -) diff --git a/cmake/third_party_deps/atkinson_hyperlegible_mono/CMakeLists.txt b/cmake/third_party_deps/atkinson_hyperlegible_mono/CMakeLists.txt deleted file mode 100644 index 6a1e13eb..00000000 --- a/cmake/third_party_deps/atkinson_hyperlegible_mono/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2026 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Data-only package. diff --git a/cmake/third_party_deps/atkinson_hyperlegible_next.cmake b/cmake/third_party_deps/atkinson_hyperlegible_next.cmake deleted file mode 100644 index f6cd377e..00000000 --- a/cmake/third_party_deps/atkinson_hyperlegible_next.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2026 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MUJOCO_DEP_VERSION_atkinson_hyperlegible_next - 5d633f80fc654ef5fffa7cfc257528685158dcef - CACHE STRING "Tag/version of `atkinson_hyperlegible_next` to be fetched." -) -mark_as_advanced(MUJOCO_DEP_VERSION_atkinson_hyperlegible_next) - -include(FindOrFetch) - -fetchpackage( - PACKAGE_NAME atkinson_hyperlegible_next - GIT_REPO https://github.com/googlefonts/atkinson-hyperlegible-next.git - GIT_TAG ${MUJOCO_DEP_VERSION_atkinson_hyperlegible_next} - CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/atkinson_hyperlegible_next/CMakeLists.txt" -) diff --git a/cmake/third_party_deps/atkinson_hyperlegible_next/CMakeLists.txt b/cmake/third_party_deps/atkinson_hyperlegible_next/CMakeLists.txt deleted file mode 100644 index 6a1e13eb..00000000 --- a/cmake/third_party_deps/atkinson_hyperlegible_next/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2026 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Data-only package. diff --git a/cmake/third_party_deps/dear_imgui.cmake b/cmake/third_party_deps/dear_imgui.cmake deleted file mode 100644 index 45046f3a..00000000 --- a/cmake/third_party_deps/dear_imgui.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MUJOCO_DEP_VERSION_dear_imgui - 913a3c60561bb07e8fd410ec7d4a8f6f485defd6 - CACHE STRING "Tag/version of `dear_imgui` to be fetched." -) -mark_as_advanced(MUJOCO_DEP_VERSION_dear_imgui) - -include(FindOrFetch) - -fetchpackage( - PACKAGE_NAME dear_imgui - GIT_REPO https://github.com/ocornut/imgui.git - GIT_TAG ${MUJOCO_DEP_VERSION_dear_imgui} - CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/dear_imgui/CMakeLists.txt" -) diff --git a/cmake/third_party_deps/dear_imgui/CMakeLists.txt b/cmake/third_party_deps/dear_imgui/CMakeLists.txt deleted file mode 100644 index cac77645..00000000 --- a/cmake/third_party_deps/dear_imgui/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_library(dear_imgui STATIC) -set(MUJOCO_DEAR_IMGUI_SOURCE_DIR "${dear_imgui_SOURCE_DIR}" CACHE INTERNAL "") -target_include_directories(dear_imgui - PUBLIC - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR} -) -target_sources(dear_imgui - PUBLIC - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui.h - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui.cpp - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_internal.h - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_draw.cpp - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_tables.cpp - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_widgets.cpp - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_demo.cpp -) - -function(mujoco_add_dear_imgui_sdl2_backend) - if(TARGET dear_imgui_SDL2 OR NOT TARGET SDL2::SDL2-static) - return() - endif() - - add_library(dear_imgui_SDL2 STATIC) - target_include_directories(dear_imgui_SDL2 - PUBLIC - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR} - ) - target_sources(dear_imgui_SDL2 - PUBLIC - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp - ) - target_link_libraries(dear_imgui_SDL2 - SDL2::SDL2-static - ) -endfunction() - -# SDL2 backend. Filament uses base dear_imgui without SDL2; platform calls this -# helper again after SDL2 is pulled in. -mujoco_add_dear_imgui_sdl2_backend() - -# OpenGL3 backend -add_library(dear_imgui_OpenGL3 STATIC) -target_include_directories(dear_imgui_OpenGL3 - PUBLIC - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR} -) -target_sources(dear_imgui_OpenGL3 - PUBLIC - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/backends/imgui_impl_opengl3.h - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp -) - -# stdlib -add_library(dear_imgui_stdlib STATIC) -target_include_directories(dear_imgui_stdlib - PUBLIC - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR} -) -target_sources(dear_imgui_stdlib - PUBLIC - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/misc/cpp/imgui_stdlib.h - ${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp -) diff --git a/cmake/third_party_deps/filament.cmake b/cmake/third_party_deps/filament.cmake deleted file mode 100644 index ab024ca3..00000000 --- a/cmake/third_party_deps/filament.cmake +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MUJOCO_DEP_VERSION_filament - 3bcc2a252bfefc31353f6097bb9bc238032571e0 - CACHE STRING "Tag/version of `filament` to be fetched." -) -mark_as_advanced(MUJOCO_DEP_VERSION_filament) - -include(FindOrFetch) - -set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) -set(BUILD_SHARED_LIBS OFF) - -# Filament's ShaderMinifier.cpp uses strlen without including , and -# PostProcessManager.h uses std::optional without including . -set(CMAKE_CXX_FLAGS_OLD "${CMAKE_CXX_FLAGS}") -if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FI cstring /FI optional") -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include cstring -include optional") -endif() - -# Filament generates deprecated warnings on MacOS. -if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations") -endif() - -set(FILAMENT_ENABLE_EXPERIMENTAL_GCC_SUPPORT ON) -set(FILAMENT_SKIP_SDL2 ON) -set(FILAMENT_SKIP_SAMPLES ON) -set(FILAMENT_USE_EXTERNAL_ABSL ON) -set(FILAMENT_USE_EXTERNAL_BENCHMARK ON) -set(FILAMENT_USE_EXTERNAL_GTEST ON) -if(WIN32) - set(USE_STATIC_CRT OFF) - add_compile_definitions(WIN32) -endif() - -set(FILAMENT_PATCH_COMMAND - git --git-dir=. -c core.autocrlf=false -c core.whitespace=cr-at-eol apply --verbose --whitespace=fix --ignore-space-change ${mujoco_SOURCE_DIR}/cmake/filament-allow-clang-windows.patch -) - -# MuJoCo fetches Abseil before Filament is configured. Filament's -# FILAMENT_USE_EXTERNAL_ABSL path calls find_package(absl), which can otherwise -# discover an unrelated package-manager Abseil config and collide with the -# targets already created by MuJoCo's fetched Abseil. -if(DEFINED CMAKE_DISABLE_FIND_PACKAGE_absl) - set(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED TRUE) - set(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_OLD "${CMAKE_DISABLE_FIND_PACKAGE_absl}") -else() - set(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED FALSE) -endif() -set(CMAKE_DISABLE_FIND_PACKAGE_absl TRUE) - -fetchpackage( - PACKAGE_NAME filament - GIT_REPO https://github.com/google/filament.git - GIT_TAG ${MUJOCO_DEP_VERSION_filament} - PATCH_COMMAND ${FILAMENT_PATCH_COMMAND} -) - -if(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED) - set(CMAKE_DISABLE_FIND_PACKAGE_absl "${MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_OLD}") -else() - unset(CMAKE_DISABLE_FIND_PACKAGE_absl) -endif() -unset(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED) -unset(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_OLD) - -set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD}) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_OLD}") diff --git a/cmake/third_party_deps/font_awesome.cmake b/cmake/third_party_deps/font_awesome.cmake deleted file mode 100644 index 9a02aa3d..00000000 --- a/cmake/third_party_deps/font_awesome.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MUJOCO_DEP_VERSION_font_awesome - a8386aae19e200ddb0f6845b5feeee5eb7013687 - CACHE STRING "Tag/version of `font_awesome` to be fetched." -) -mark_as_advanced(MUJOCO_DEP_VERSION_font_awesome) - -include(FindOrFetch) - -fetchpackage( - PACKAGE_NAME font_awesome - GIT_REPO https://github.com/FortAwesome/Font-Awesome.git - GIT_TAG ${MUJOCO_DEP_VERSION_font_awesome} - CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/font_awesome/CMakeLists.txt" -) diff --git a/cmake/third_party_deps/font_awesome/CMakeLists.txt b/cmake/third_party_deps/font_awesome/CMakeLists.txt deleted file mode 100644 index 430de44d..00000000 --- a/cmake/third_party_deps/font_awesome/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Data-only package. diff --git a/cmake/third_party_deps/implot.cmake b/cmake/third_party_deps/implot.cmake deleted file mode 100644 index d14cae6c..00000000 --- a/cmake/third_party_deps/implot.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MUJOCO_DEP_VERSION_implot - ec7306ceb99d19ff193eb30dc74fa3598f5e7dc6 - CACHE STRING "Tag/version of `implot` to be fetched." -) -mark_as_advanced(MUJOCO_DEP_VERSION_implot) - -include(FindOrFetch) - -fetchpackage( - PACKAGE_NAME implot - GIT_REPO https://github.com/epezent/implot.git - GIT_TAG ${MUJOCO_DEP_VERSION_implot} - CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/implot/CMakeLists.txt" -) diff --git a/cmake/third_party_deps/implot/CMakeLists.txt b/cmake/third_party_deps/implot/CMakeLists.txt deleted file mode 100644 index 72ff88e6..00000000 --- a/cmake/third_party_deps/implot/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_library(implot STATIC) - -target_include_directories(implot - PUBLIC - ${implot_SOURCE_DIR} -) - -target_sources(implot - PUBLIC - ${implot_SOURCE_DIR}/implot.h - ${implot_SOURCE_DIR}/implot_internal.h - ${implot_SOURCE_DIR}/implot.cpp - ${implot_SOURCE_DIR}/implot_items.cpp - ${implot_SOURCE_DIR}/implot_demo.cpp -) - -target_link_libraries(implot - dear_imgui -) diff --git a/cmake/third_party_deps/libwebp.cmake b/cmake/third_party_deps/libwebp.cmake deleted file mode 100644 index 2fa28f0b..00000000 --- a/cmake/third_party_deps/libwebp.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MUJOCO_DEP_VERSION_libwebp - v1.6.0 - CACHE STRING "Tag/version of `libwebp` to be fetched." -) -mark_as_advanced(MUJOCO_DEP_VERSION_libwebp) - -include(FindOrFetch) - -set(LIBWEBP_PATCH_COMMAND - git --git-dir=. -c core.autocrlf=false -c core.whitespace=cr-at-eol apply --verbose --whitespace=fix --ignore-space-change ${mujoco_SOURCE_DIR}/cmake/libwebp-apple-float16.patch -) - -set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) -set(BUILD_SHARED_LIBS OFF) - -fetchpackage( - PACKAGE_NAME libwebp - GIT_REPO https://github.com/webmproject/libwebp.git - GIT_TAG ${MUJOCO_DEP_VERSION_libwebp} - TARGETS webp - PATCH_COMMAND ${LIBWEBP_PATCH_COMMAND} -) - -set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD}) diff --git a/cmake/third_party_deps/openusd.cmake b/cmake/third_party_deps/openusd.cmake deleted file mode 100644 index 861ea365..00000000 --- a/cmake/third_party_deps/openusd.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Find OpenUSD package. The user can either provide pxr_DIR to use their own -# OpenUSD installation or they can build external_dependencies. -# -# We use QUIET here to provide a better error message when pxr is not found. -find_package(pxr - QUIET - HINTS "${CMAKE_BINARY_DIR}/_deps/openusd-build" -) - -if(NOT pxr_FOUND) - message(FATAL_ERROR - "-----------------------------------------------------------\n" - "USD Configuration Error:\n${pxr_NOT_FOUND_MESSAGE}\n" - "If you have built USD yourself, provide -Dpxr_DIR=your_pxr_install_dir' \n" - "Otherwise you can build cmake/third_party_deps/openusd:\n" - "cd ~/mujoco\n" - "cmake -Bcmake/third_party_deps/openusd/build cmake/third_party_deps/openusd -DBUILD_USD=True\n" - "cmake --build cmake/third_party_deps/openusd/build\n" - "cmake -Bbuild -S. -DMUJOCO_WITH_USD=True\n" - "cmake --build build\n" - "cmake --install build" - "-----------------------------------------------------------" - ) -endif() diff --git a/cmake/third_party_deps/openusd/CMakeLists.txt b/cmake/third_party_deps/openusd/CMakeLists.txt deleted file mode 100644 index 4eb02281..00000000 --- a/cmake/third_party_deps/openusd/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -cmake_minimum_required(VERSION "3.16") - -project(openusd-dependency) - -include(ExternalProject) - -set(DEPS_DIR ${CMAKE_BINARY_DIR}/../../../../build/_deps) - -ExternalProject_Add(openusd - GIT_REPOSITORY https://github.com/PixarAnimationStudios/USD.git - GIT_TAG v25.11 - PREFIX openusd - BUILD_IN_SOURCE 0 - UPDATE_COMMAND "" - CONFIGURE_COMMAND "" - INSTALL_COMMAND "" - SOURCE_DIR ${DEPS_DIR}/openusd-src - BINARY_DIR ${DEPS_DIR}/openusd-build - INSTALL_DIR ${DEPS_DIR}/openusd-build - BUILD_COMMAND python3 ${DEPS_DIR}/openusd-src/build_scripts/build_usd.py - --build-shared - --no-examples - --no-tools - --no-ptex - --no-prman - --no-openimageio - --no-opencolorio - --no-alembic - --no-draco - --no-materialx - --no-tutorials - --no-tests - --no-docs - --no-imaging - --no-python - --no-usdValidation - -) diff --git a/cmake/third_party_deps/sdl2.cmake b/cmake/third_party_deps/sdl2.cmake deleted file mode 100644 index f310eee4..00000000 --- a/cmake/third_party_deps/sdl2.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2025 DeepMind Technologies Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(MUJOCO_DEP_VERSION_sdl2 - 98d1f3a45aae568ccd6ed5fec179330f47d4d356 - CACHE STRING "Version of `SDL2` to be fetched." -) -mark_as_advanced(MUJOCO_DEP_VERSION_sdl2) - -include(FindOrFetch) - -set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) -fetchpackage( - PACKAGE_NAME sdl2 - GIT_REPO https://github.com/libsdl-org/SDL.git - GIT_TAG ${MUJOCO_DEP_VERSION_sdl2} -) diff --git a/wasm/src/README.md b/controllers/README.md similarity index 100% rename from wasm/src/README.md rename to controllers/README.md diff --git a/wasm/src/go2_w_balance.py b/controllers/go2_w_balance.py similarity index 100% rename from wasm/src/go2_w_balance.py rename to controllers/go2_w_balance.py diff --git a/dist/Info.plist.framework.in b/dist/Info.plist.framework.in deleted file mode 100644 index 67937dea..00000000 --- a/dist/Info.plist.framework.in +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleName - MuJoCo - CFBundleIdentifier - org.mujoco.framework - CFBundleVersion - ${PROJECT_VERSION} - CFBundleGetInfoString - ${PROJECT_VERSION} - CFBundleExecutable - libmujoco.dylib - CFBundlePackageType - FMWK - NSHumanReadableCopyright - Copyright 2021 DeepMind Technologies Limited. - MDItemKeywords - MuJoCo, physics engine, physics simulator, physics, MJ - CFBundleInfoDictionaryVersion - 6.0 - CFBundleDevelopmentRegion - en - CFBundleSupportedPlatforms - - MacOSX - - - diff --git a/dist/Info.plist.simulate.in b/dist/Info.plist.simulate.in deleted file mode 100644 index 2397bf8c..00000000 --- a/dist/Info.plist.simulate.in +++ /dev/null @@ -1,36 +0,0 @@ - - - - - CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} - CFBundleIdentifier - ${MACOSX_BUNDLE_GUI_IDENTIFIER} - CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} - CFBundleGetInfoString - ${MACOSX_BUNDLE_INFO_STRING} - CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} - CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} - CFBundleExecutable - simulate - CFBundleIconFile - ${MACOSX_BUNDLE_ICON_FILE} - CFBundlePackageType - APPL - NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} - MDItemKeywords - MuJoCo, physics engine, physics simulator, physics, simulate, MJ, mujoco simulate, mj simulate - CFBundleInfoDictionaryVersion - 6.0 - CFBundleDevelopmentRegion - en - CFBundleSupportedPlatforms - - MacOSX - - - diff --git a/dist/module.modulemap b/dist/module.modulemap deleted file mode 100644 index 8fac4abc..00000000 --- a/dist/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module mujoco { - umbrella header "mujoco.h" - - export * - module * { export * } -} diff --git a/dist/mujoco.icns b/dist/mujoco.icns deleted file mode 100644 index dda1f449..00000000 Binary files a/dist/mujoco.icns and /dev/null differ diff --git a/dist/mujoco.ico b/dist/mujoco.ico deleted file mode 100644 index 80136209..00000000 Binary files a/dist/mujoco.ico and /dev/null differ diff --git a/dist/mujoco.rc b/dist/mujoco.rc deleted file mode 100644 index f3d730b9..00000000 --- a/dist/mujoco.rc +++ /dev/null @@ -1,25 +0,0 @@ -1 VERSIONINFO -FILEVERSION 3,12,0,0 -PRODUCTVERSION 3,12,0,0 -FILEOS 0x4 -FILETYPE 0x1 -{ - BLOCK "StringFileInfo" - { - BLOCK "040904b0" - { - VALUE "ProductName", "MuJoCo" - VALUE "ProductVersion", "3.12.0" - VALUE "FileDescription", "MuJoCo" - VALUE "FileVersion", "3.12.0" - VALUE "InternalName", "mujoco.dll" - VALUE "OriginalFilename", "mujoco.dll" - VALUE "CompanyName", "Google DeepMind" - VALUE "LegalCopyright", "Copyright 2021 DeepMind Technologies Limited." - } - } - BLOCK "VarFileInfo" - { - VALUE "Translation", 0x0409, 0x04B0 - } -} diff --git a/dist/mujoco_studio.icns b/dist/mujoco_studio.icns deleted file mode 100644 index 7cf2f90e..00000000 Binary files a/dist/mujoco_studio.icns and /dev/null differ diff --git a/dist/mujoco_studio.ico b/dist/mujoco_studio.ico deleted file mode 100644 index 112a9731..00000000 Binary files a/dist/mujoco_studio.ico and /dev/null differ diff --git a/dist/mujoco_studio.rc b/dist/mujoco_studio.rc deleted file mode 100644 index d731692e..00000000 --- a/dist/mujoco_studio.rc +++ /dev/null @@ -1,27 +0,0 @@ -MUJOCO ICON "mujoco_studio.ico" - -1 VERSIONINFO -FILEVERSION 3,12,0,0 -PRODUCTVERSION 3,12,0,0 -FILEOS 0x4 -FILETYPE 0x1 -{ - BLOCK "StringFileInfo" - { - BLOCK "040904b0" - { - VALUE "ProductName", "MuJoCo Studio" - VALUE "ProductVersion", "3.12.0" - VALUE "FileDescription", "MuJoCo Studio" - VALUE "FileVersion", "3.12.0" - VALUE "InternalName", "mujoco_studio.exe" - VALUE "OriginalFilename", "mujoco_studio.exe" - VALUE "CompanyName", "Google DeepMind" - VALUE "LegalCopyright", "Copyright 2026 DeepMind Technologies Limited." - } - } - BLOCK "VarFileInfo" - { - VALUE "Translation", 0x0409, 0x04B0 - } -} diff --git a/dist/simulate.rc b/dist/simulate.rc deleted file mode 100644 index b25c48dc..00000000 --- a/dist/simulate.rc +++ /dev/null @@ -1,27 +0,0 @@ -MUJOCO ICON "mujoco.ico" - -1 VERSIONINFO -FILEVERSION 3,12,0,0 -PRODUCTVERSION 3,12,0,0 -FILEOS 0x4 -FILETYPE 0x1 -{ - BLOCK "StringFileInfo" - { - BLOCK "040904b0" - { - VALUE "ProductName", "MuJoCo" - VALUE "ProductVersion", "3.12.0" - VALUE "FileDescription", "MuJoCo" - VALUE "FileVersion", "3.12.0" - VALUE "InternalName", "simulate.exe" - VALUE "OriginalFilename", "simulate.exe" - VALUE "CompanyName", "Google DeepMind" - VALUE "LegalCopyright", "Copyright 2021 DeepMind Technologies Limited." - } - } - BLOCK "VarFileInfo" - { - VALUE "Translation", 0x0409, 0x04B0 - } -} diff --git a/doc/APIreference/APIfunctions.rst b/doc/APIreference/APIfunctions.rst deleted file mode 100644 index a1ec8da6..00000000 --- a/doc/APIreference/APIfunctions.rst +++ /dev/null @@ -1,71 +0,0 @@ -.. raw:: html - -
- - -.. _API: - -========= -Functions -========= - -.. tip:: - Clicking on a function name below will take you to the source implementation in the GitHub repository. - -The main header `mujoco.h `_ exposes a -large number of functions. However the functions that most users are likely to need are a small fraction. - -API function can be classified as: - -- **Main entry points** - - :ref:`Parse and compile` an :ref:`mjModel` from XML files and assets. - - :ref:`Main simulation` entry points, including :ref:`mj_step`. - -- **Support functions** - - :ref:`Support` functions requiring :ref:`mjModel` and :ref:`mjData`. - - Pipeline :ref:`components`, called from :ref:`mj_step`, :ref:`mj_forward` and :ref:`mj_inverse`. - - :ref:`Sub components` of the simulation pipeline. - - :ref:`Ray casting`. - - :ref:`Printing` of various quantities. - - :ref:`Virtual file system`, used to load assets from memory. - - :ref:`Asset cache`, used to speed up model compilation. - - :ref:`Resources`, interfacing with resource providers to load assets. - - :ref:`Initialization` of data structures. - - :ref:`Error and memory`. - - :ref:`Miscellaneous` functions. - -- **Visualization, Rendering, UI** - - :ref:`Abstract interaction`: mouse control of cameras and perturbations. - - :ref:`Abstract Visualization`. - - :ref:`OpenGL rendering`. - - :ref:`Filament rendering`. - - :ref:`UI framework`. - -- **Threads, Plugins, Derivatives** - - :ref:`Derivatives`. - - :ref:`Signed Distance Functions`. - - :ref:`Thread` |-| -related functions. - - :ref:`Plugin` |-| -related functions. - -- **Math** - - Aliases for C :ref:`standard math` functions. - - :ref:`Vector math`. - - :ref:`Sparse math`. - - :ref:`Quaternions`. - - :ref:`Pose transformations`. - - :ref:`Matrix decompositions and solvers`. - -- **Model editing** - - :ref:`Attachment`. - - :ref:`Tree elements`. - - :ref:`Non-tree elements`. - - :ref:`Set actuator parameters`. - - :ref:`Assets`. - - :ref:`Find and get utilities`. - - :ref:`Attribute setters`. - - :ref:`Attribute getters`. - - :ref:`Spec utilities`. - - :ref:`Element initialization`. - - :ref:`Element casting`. - -.. include:: functions.rst diff --git a/doc/APIreference/APIglobals.rst b/doc/APIreference/APIglobals.rst deleted file mode 100644 index 7aef601a..00000000 --- a/doc/APIreference/APIglobals.rst +++ /dev/null @@ -1,716 +0,0 @@ -======= -Globals -======= - -Global variable and constant definitions can be classified as: - -- Callbacks: - - - :ref:`glError`. - - :ref:`glMemory`. - - :ref:`glPhysics`. - -- The :ref:`collision table` containing narrow-phase collision functions. -- :ref:`String constants`. -- :ref:`Numeric constants`. -- :ref:`Macros`. -- :ref:`X Macros`. - -.. _glError: - -Error callbacks -^^^^^^^^^^^^^^^ - -All user callbacks (i.e., global function pointers whose name starts with 'mjcb') are initially set to NULL, which -disables them and allows the default processing to take place. To install a callback, simply set the corresponding -global pointer to a user function of the correct type. Keep in mind that these are global and not model-specific. So if -you are simulating multiple models in parallel, they use the same set of callbacks. - - -.. _mju_user_error: - -mju_user_error -~~~~~~~~~~~~~~ - -.. deprecated:: - Use :ref:`mju_setLogHandler` instead. See :ref:`siLogHandler`. - -Called by the default log handler when a fatal error occurs. If installed, this function overrides the default error -processing. It may ``longjmp`` out or return. MuJoCo is written with the assumption that error handlers will not -return; if they do, the behavior of the software is undefined. - -If a custom log handler is installed via :ref:`mju_setLogHandler`, this callback is not consulted. - -.. code-block:: C - - extern void (*mju_user_error)(const char*); - - -.. _mju_user_warning: - -mju_user_warning -~~~~~~~~~~~~~~~~ - -.. deprecated:: - Use :ref:`mju_setLogHandler` instead. See :ref:`siLogHandler`. - -Called by the default log handler when a warning occurs. If a custom log handler is installed via -:ref:`mju_setLogHandler`, this callback is not consulted. - -.. code-block:: C - - extern void (*mju_user_warning)(const char*); - - -.. _glMemory: - -Memory callbacks -^^^^^^^^^^^^^^^^ - -The purpose of the memory callbacks is to allow the user to install custom memory allocation and deallocation -mechanisms. One example where we have found this to be useful is a MATLAB wrapper for MuJoCo, where mex files are -expected to use MATLAB's memory mechanism for permanent memory allocation. - - -.. _mju_user_malloc: - -mju_user_malloc -~~~~~~~~~~~~~~~ - -If this is installed, the MuJoCo runtime will use it to allocate all heap memory it needs (instead of using aligned -malloc). The user allocator must allocate memory aligned on 8-byte boundaries. Note that the parser and compiler are -written in C++ and sometimes allocate memory with the "new" operator which bypasses this mechanism. - -.. code-block:: C - - extern void* (*mju_user_malloc)(size_t); - - -.. _mju_user_free: - -mju_user_free -~~~~~~~~~~~~~ - -If this is installed, MuJoCo will free any heap memory it allocated by calling this function (instead of using aligned -free). - -.. code-block:: C - - extern void (*mju_user_free)(void*); - - -.. _glPhysics: - -Physics callbacks -^^^^^^^^^^^^^^^^^ - -The physics callbacks are the main mechanism for modifying the behavior of the simulator, beyond setting various -options. The options control the operation of the default pipeline, while callbacks extend the pipeline at -well-defined places. This enables advanced users to implement many interesting functions which we have not thought of, -while still taking advantage of the default pipeline. As with all other callbacks, there is no automated error -checking - instead we assume that the authors of callback functions know what they are doing. - -Custom physics callbacks will often need parameters that are not standard in MJCF. This is largely why we have -provided custom fields as well as user data arrays in MJCF. The idea is to "instrument" the MJCF model by entering the -necessary user parameters, and then write callbacks that look for those parameters and perform the corresponding -computations. We strongly encourage users to write callbacks that check the model for the presence of user parameters -before accessing them - so that when a regular model is loaded, the callback disables itself automatically instead of -causing the software to crash. - -.. _mjcb_passive: - -mjcb_passive -~~~~~~~~~~~~ - -This is used to implement a custom passive force in joint space; if the force is more naturally defined in Cartesian -space, use the end-effector Jacobian to map it to joint space. By "passive" we do not mean a force that does no positive -work (as in physics), but simply a force that depends only on position and velocity but not on control. There are -standard passive forces in MuJoCo arising from springs, dampers, viscosity and density of the medium. They are computed -in ``mjData.qfrc_passive`` before mjcb_passive is called. The user callback should add to this vector instead of -overwriting it (otherwise the standard passive forces will be lost). - -.. code-block:: C - - extern mjfGeneric mjcb_passive; - - -.. _mjcb_control: - -mjcb_control -~~~~~~~~~~~~ - -This is the most commonly used callback. It implements a control law, by writing in the vector of controls -``mjData.ctrl``. It can also write in ``mjData.qfrc_applied`` and ``mjData.xfrc_applied``. The values written in these -vectors can depend on position, velocity and all other quantities derived from them, but cannot depend on contact forces -and other quantities that are computed after the control is specified. If the callback accesses the latter fields, their -values do not correspond to the current time step. - -The control callback is called from within :ref:`mj_forward` and :ref:`mj_step`, just before the controls and applied -forces are needed. When using the RK integrator, it will be called 4 times per step. The alternative way of specifying -controls and applied forces is to set them before ``mj_step``, or use ``mj_step1`` and ``mj_step2``. The latter approach -allows setting the controls after the position and velocity computations have been performed by ``mj_step1``, allowing -these results to be utilized in computing the control (similar to using mjcb_control). However, the only way to change -the controls between sub-steps of the RK integrator is to define the control callback. - -.. code-block:: C - - extern mjfGeneric mjcb_control; - -.. _mjcb_contactfilter: - -mjcb_contactfilter -~~~~~~~~~~~~~~~~~~ - -This callback can be used to replace MuJoCo's default collision filtering. When installed, this function is called for -each pair of geoms that have passed the broad-phase test (or are predefined geom pairs in the MJCF) and are candidates -for near-phase collision. The default processing uses the contype and conaffinity masks, the parent-child filter and -some other considerations related to welded bodies to decide if collision should be allowed. This callback replaces the -default processing, but keep in mind that the entire mechanism is being replaced. So for example if you still want to -take advantage of contype/conaffinity, you have to re-implement it in the callback. - -.. code-block:: C - - extern mjfConFilt mjcb_contactfilter; - -.. _mjcb_sensor: - -mjcb_sensor -~~~~~~~~~~~ - -This callback populates fields of ``mjData.sensordata`` corresponding to user-defined sensors. It is called if it is -installed and the model contains user-defined sensors. It is called once per compute stage (mjSTAGE_POS, mjSTAGE_VEL, -mjSTAGE_ACC) and must fill in all user sensor values for that stage. The user-defined sensors have dimensionality and -data types defined in the MJCF model which must be respected by the callback. - -.. code-block:: C - - extern mjfSensor mjcb_sensor; - -.. _mjcb_time: - -mjcb_time -~~~~~~~~~ - -Installing this callback enables the built-in profiler, and keeps timing statistics in ``mjData.timer``. The return type -is mjtNum, while the time units are up to the user. Both :ref:`simulate.cc ` and the ``mjTOPIC_TIME_STP`` -informational :ref:`topic ` assume the unit is 1 millisecond. In order to be useful, the callback should -use high-resolution timers with at least microsecond precision. - -.. code-block:: C - - extern mjfTime mjcb_time; - - -.. _mjcb_act_dyn: - -mjcb_act_dyn -~~~~~~~~~~~~ - -This callback implements custom activation dynamics: it must return the value of ``mjData.act_dot`` for the specified -actuator. This is the time-derivative of the activation state vector ``mjData.act``. It is called for model actuators -with user dynamics (mjDYN_USER). If such actuators exist in the model but the callback is not installed, their -time-derivative is set to 0. - -.. code-block:: C - - extern mjfAct mjcb_act_dyn; - - -.. _mjcb_act_gain: - -mjcb_act_gain -~~~~~~~~~~~~~ - -This callback implements custom actuator gains: it must return the gain for the specified actuator with -``mjModel.actuator_gaintype`` set to mjGAIN_USER. If such actuators exist in the model and this callback is not -installed, their gains are set to 1. - -.. code-block:: C - - extern mjfAct mjcb_act_gain; - - -.. _mjcb_act_bias: - -mjcb_act_bias -~~~~~~~~~~~~~ - -This callback implements custom actuator biases: it must return the bias for the specified actuator with -``mjModel.actuator_biastype`` set to mjBIAS_USER. If such actuators exist in the model and this callback is not -installed, their biases are set to 0. - -.. code-block:: C - - extern mjfAct mjcb_act_bias; - - -.. _glCollision: - -Collision table -^^^^^^^^^^^^^^^ - -.. _mjCOLLISIONFUNC: - -mjCOLLISIONFUNC -~~~~~~~~~~~~~~~ - -Table of pairwise collision functions indexed by geom types. Only the upper-right triangle is used. The user can replace -these function pointers with custom routines, replacing MuJoCo's collision mechanism. If a given entry is NULL, the -corresponding pair of geom types cannot be collided. Note that these functions apply only to near-phase collisions. The -broadphase mechanism is built-in and cannot be modified. - -.. code-block:: C - - extern mjfCollision mjCOLLISIONFUNC[mjNGEOMTYPES][mjNGEOMTYPES]; - - -.. _glString: - -String constants -^^^^^^^^^^^^^^^^ - -The string constants described here are provided for user convenience. They correspond to the English names of lists of -options, and can be displayed in menus or dialogs in a GUI. The code sample :ref:`simulate.cc ` illustrates -how they can be used. - - -.. _mjDISABLESTRING: - -mjDISABLESTRING -~~~~~~~~~~~~~~~ - -Names of the disable bits defined by :ref:`mjtDisableBit`. - -.. code-block:: C - - extern const char* mjDISABLESTRING[mjNDISABLE]; - - -.. _mjENABLESTRING: - -mjENABLESTRING -~~~~~~~~~~~~~~ - -Names of the enable bits defined by :ref:`mjtEnableBit`. - -.. code-block:: C - - extern const char* mjENABLESTRING[mjNENABLE]; - - -.. _mjTIMERSTRING: - -mjTIMERSTRING -~~~~~~~~~~~~~ - -Names of the mjData timers defined by :ref:`mjtTimer`. - -.. code-block:: C - - extern const char* mjTIMERSTRING[mjNTIMER]; - - -.. _mjLABELSTRING: - -mjLABELSTRING -~~~~~~~~~~~~~ - -Names of the visual labeling modes defined by :ref:`mjtLabel`. - -.. code-block:: C - - extern const char* mjLABELSTRING[mjNLABEL]; - - -.. _mjFRAMESTRING: - -mjFRAMESTRING -~~~~~~~~~~~~~ - -Names of the frame visualization modes defined by :ref:`mjtFrame`. - -.. code-block:: C - - extern const char* mjFRAMESTRING[mjNFRAME]; - - -.. _mjVISSTRING: - -mjVISSTRING -~~~~~~~~~~~ - -Descriptions of the abstract visualization flags defined by :ref:`mjtVisFlag`. For each flag there are three strings, - -with the following meaning: - -[0]: flag name; - -[1]: the string "0" or "1" indicating if the flag is on or off by default, as set by -:ref:`mjv_defaultOption`; - -[2]: one-character string with a suggested keyboard shortcut, used in :ref:`simulate.cc `. - -.. code-block:: C - - extern const char* mjVISSTRING[mjNVISFLAG][3]; - - -.. _mjRNDSTRING: - -mjRNDSTRING -~~~~~~~~~~~ - -Descriptions of the OpenGL rendering flags defined by :ref:`mjtRndFlag`. The three strings for each flag have the same -format as above, except the defaults here are set by :ref:`mjv_makeScene`. - -.. code-block:: C - - extern const char* mjRNDSTRING[mjNRNDFLAG][3]; - - - -.. _glNumeric: - -Numeric constants -^^^^^^^^^^^^^^^^^ - -Many integer constants were already documented in the primitive types above. In addition, the header files define -several other constants documented here. Note that some extended key codes are defined in -`mjui.h `_ which are not shown below. Their -names are in the format ``mjKEY_XXX``. They correspond to GLFW key codes. - - -.. _glNumericVersion: - -Version -~~~~~~~ - -Defined in `mujoco.h `_. - -.. list-table:: - :widths: 2 1 8 - :header-rows: 1 - - * - symbol - - value - - description - * - ``mjVERSION_HEADER`` - - 3012000 - - The version of the MuJoCo headers. This is an integer calculated from the version string "S.M.P" - using the formula ``(S * 1e6) + (M * 1e3) + P``. For example, version 4.2.1 is represented as 4002001. - The API function :ref:`mj_version` returns a number with the same meaning - but for the compiled library. See - `VERSIONING.md `__ for details. - - -.. _glNumericEngine: - -Engine constants -~~~~~~~~~~~~~~~~ - -Defined in `mjmodel.h `_ unless -indicated otherwise. - -.. list-table:: - :widths: 2 1 8 - :header-rows: 1 - - * - symbol - - value - - description - * - ``mjMINVAL`` - - 1E-15 - - The minimal value allowed in any denominator, and in general any mathematical operation where 0 is not allowed. - In almost all cases, MuJoCo silently clamps smaller values to mjMINVAL. - Defined in `mjtype.h `_. - * - ``mjPI`` - - :math:`\pi` - - The value of :math:`\pi`. This is used in various trigonometric functions, and also for conversion from degrees - to radians in the compiler. - * - ``mjMAXVAL`` - - 1E+10 - - The maximal absolute value allowed in mjData.qpos, mjData.qvel, mjData.qacc. The API functions - :ref:`mj_checkPos`, :ref:`mj_checkVel`, :ref:`mj_checkAcc` use this constant to detect instability. - * - ``mjMINMU`` - - 1E-5 - - The minimal value allowed in any friction coefficient. Recall that MuJoCo's contact model allows different number - of friction dimensions to be included, as specified by the :at:`condim` attribute. If however a given friction - dimension is included, its friction is not allowed to be smaller than this constant. Smaller values are - automatically clamped to this constant. - * - ``mjMINIMP`` - - 0.0001 - - The minimal value allowed in any constraint impedance. Smaller values are automatically clamped to this constant. - * - ``mjMAXIMP`` - - 0.9999 - - The maximal value allowed in any constraint impedance. Larger values are automatically clamped to this constant. - * - ``mjMAXCONPAIR`` - - 50 - - The maximal number of contacts points that can be generated per geom pair. MuJoCo's built-in collision functions - respect this limit, and user-defined functions should also respect it. Such functions are called with a return - buffer of size ``mjMAXCONPAIR``; attempting to write more contacts in the buffer can cause unpredictable - behavior. - * - ``mjMAXTREEDEPTH`` - - 50 - - The maximum depth of each body and mesh bounding volume hierarchy. If this large limit is exceeded, a warning - is raised and ray casting may not be possible. For a balanced hierarchy, this implies 1E15 bounding volumes. - * - ``mjMAXFLEXNODES`` - - 27 - - The maximum number of nodes in a trilinear flex element. - * - ``mjMINAWAKE`` - - 10 - - The minimum number of timesteps that must pass after a tree is awoken, before it is allowed to go back to sleep. - - -.. _glNumericSizes: - -Array sizes -~~~~~~~~~~~ - -Defined in `mjmodel.h `_. These constants -correspond to array sizes which we have not fully settled. There may be reasons to increase them in the future, so as to -accommodate extra parameters needed for more elaborate computations. This is why we maintain them as symbolic constants -that can be easily changed, as opposed to the array size for representing quaternions for example -- which has no reason -to change. - -.. list-table:: - :widths: 2 1 8 - :header-rows: 1 - - * - symbol - - value - - description - * - ``mjNEQDATA`` - - 11 - - The maximal number of real-valued parameters used to define each equality constraint. Determines the size of - ``mjModel.eq_data``. - * - ``mjNDYN`` - - 10 - - The maximal number of real-valued parameters used to define the activation dynamics of each actuator. - Determines the size of ``mjModel.actuator_dynprm``. - * - ``mjNGAIN`` - - 10 - - The maximal number of real-valued parameters used to define the gain of each actuator. - Determines the size of ``mjModel.actuator_gainprm``. - * - ``mjNBIAS`` - - 10 - - The maximal number of real-valued parameters used to define the bias of each actuator. - Determines the size of ``mjModel.actuator_biasprm``. - * - ``mjNPOLY`` - - 2 - - The number of nonlinear polynomial coefficients for joint and tendon stiffness and damping. - Determines the size of ``mjModel.{jnt,tendon}_{stiffness,damping}poly``. See - :ref:`polynomial forces`. - * - ``mjNFLUID`` - - 12 - - The number of per-geom fluid interaction parameters required by the ellipsoidal model. - * - ``mjNREF`` - - 2 - - The maximal number of real-valued parameters used to define the reference acceleration of each scalar constraint. - Determines the size of all ``mjModel.XXX_solref`` fields. - * - ``mjNIMP`` - - 5 - - The maximal number of real-valued parameters used to define the impedance of each scalar constraint. - Determines the size of all ``mjModel.XXX_solimp`` fields. - * - ``mjNSENS`` - - 3 - - The number of sensor parameters. - Determines the size of ``mjModel.sensor_intprm``. - * - ``mjNSOLVER`` - - 200 - - The number of iterations where solver statistics can be stored in ``mjData.solver``. This array is used - to store diagnostic information about each iteration of the constraint solver. - The actual number of iterations is given by ``mjData.solver_niter``. - * - ``mjNISLAND`` - - 20 - - The number of islands for which solver statistics can be stored in ``mjData.solver``. This array is - used to store diagnostic information about each iteration of the constraint solver. - The actual number of islands for which the solver was run is given by ``mjData.nsolver_island``. - - -.. _glNumericVisualization: - -Visualization -~~~~~~~~~~~~~ - -Defined in `mjvisualize.h `_. - -.. list-table:: - :widths: 2 1 8 - :header-rows: 1 - - * - symbol - - value - - description - * - ``mjNGROUP`` - - 6 - - The number of geom, site, joint, tendon and actuator groups whose rendering can be enabled and disabled via - :ref:`mjvOption`. - * - ``mjMAXLIGHT`` - - 100 - - The maximum number of lights in a scene. - * - ``mjMAXOVERLAY`` - - 500 - - The maximal number of characters in overlay text for rendering. - * - ``mjMAXLINE`` - - 100 - - The maximal number of lines per 2D figure (:ref:`mjvFigure`). - * - ``mjMAXLINEPNT`` - - 1001 - - The maximal number of points in each line in a 2D figure. Note that the buffer ``mjvFigure.linepnt`` has length - ``2*mjMAXLINEPNT`` because each point has X and Y coordinates. - * - ``mjMAXPLANEGRID`` - - 200 - - The maximal number of grid lines in each dimension for rendering planes. - - -.. _glNumericRendering: - -Rendering -~~~~~~~~~ - -Defined in `mjrender.h `_. - -.. list-table:: - :widths: 2 1 8 - :header-rows: 1 - - * - symbol - - value - - description - * - ``mjNAUX`` - - 10 - - Number of auxiliary buffers that can be allocated in mjrContext. - * - ``mjMAXTEXTURE`` - - 1000 - - Maximum number of textures allowed. - * - ``mjMAXMATERIAL`` - - 1000 - - Maximum number of materials with textures. - - -.. _glNumericUI: - -UI constants -~~~~~~~~~~~~ - -Defined in `mjui.h `_. - -.. list-table:: - :widths: 2 1 8 - :header-rows: 1 - - * - symbol - - value - - description - * - ``mjMAXUISECT`` - - 10 - - Maximum number of UI sections. - * - ``mjMAXUIITEM`` - - 200 - - Maximum number of items per UI section. - * - ``mjMAXUITEXT`` - - 300 - - Maximum number of characters in UI fields 'edittext' and 'other'. - * - ``mjMAXUINAME`` - - 40 - - Maximum number of characters in any UI name. - * - ``mjMAXUIMULTI`` - - 35 - - Maximum number of radio and select items in UI group. - * - ``mjMAXUIEDIT`` - - 7 - - Maximum number of elements in UI edit list. - * - ``mjMAXUIRECT`` - - 25 - - Maximum number of UI rectangles. - -.. _Macros: - -Macros -^^^^^^ - - -.. _mjUSESINGLE: - -mjUSESINGLE -~~~~~~~~~~~ - -Compile-time flag, see :ref:`mjtNum`. - -.. _mjDISABLED: - -mjDISABLED -~~~~~~~~~~ - -.. code-block:: C - - #define mjDISABLED(x) (m->opt.disableflags & (x)) - -Check if a given standard feature has been disabled via the physics options, assuming mjModel\* m is defined. x is of -type :ref:`mjtDisableBit`. - - -.. _mjENABLED: - -mjENABLED -~~~~~~~~~ - -.. code-block:: C - - #define mjENABLED(x) (m->opt.enableflags & (x)) - -Check if a given optional feature has been enabled via the physics options, assuming mjModel\* m is defined. x is of -type :ref:`mjtEnableBit`. - - -.. _mjMAX: - -mjMAX -~~~~~ - -.. code-block:: C - - #define mjMAX(a,b) (((a) > (b)) ? (a) : (b)) - -Return maximum value. To avoid repeated evaluation with mjtNum types, use the function :ref:`mju_max`. - - -.. _mjMIN: - -mjMIN -~~~~~ - -.. code-block:: C - - #define mjMIN(a,b) (((a) < (b)) ? (a) : (b)) - -Return minimum value. To avoid repeated evaluation with mjtNum types, use the function :ref:`mju_min`. - - -.. _mjPLUGIN_LIB_INIT: - -mjPLUGIN_LIB_INIT -~~~~~~~~~~~~~~~~~ - -.. code-block:: C - - #define mjPLUGIN_LIB_INIT(n) \ - static void _mj_init_##n(void) __attribute__((constructor)); \ - static void _mj_init_##n(void) - -Register a plugin before `main()` is called. This macro takes a unique identifier `n` as an argument that is used to avoid -name collisions between different plugin initialization functions. See :ref:`plugin registration` for -more details. - - -.. _tyXMacro: - -X Macros -^^^^^^^^ - -The X Macros are not needed in most user projects. They are used internally to allocate the model, and are also -available for users who know how to use this programming technique. See the header files `mjxmacro.h -`_ and `mjspecmacro.h -`_ for the actual definitions. They are -particularly useful in writing MuJoCo wrappers for scripting languages, where dynamic structures matching the MuJoCo -data structures need to be constructed programmatically. diff --git a/doc/APIreference/APItypes.rst b/doc/APIreference/APItypes.rst deleted file mode 100644 index 3b03ac64..00000000 --- a/doc/APIreference/APItypes.rst +++ /dev/null @@ -1,2478 +0,0 @@ -===== -Types -===== - -MuJoCo defines a large number of types: - -- Four :ref:`primitive types`: :ref:`mjtNum`, :ref:`mjtByte`, :ref:`mjtBool`, and - :ref:`mjtSize`. - -- :ref:`C enum types` used to define categorical values. These can be classified as: - - - Enums used in :ref:`mjModel`. - - Enums used in :ref:`mjData`. - - Enums for abstract :ref:`visualization`. - - Enums used by the :ref:`classic renderer`. - - Enums used by the :ref:`filament renderer`. - - Enums used by the :ref:`mjUI` user interface package. - - Enums used by :ref:`engine plugins`. - - Enums used for :ref:`procedural model manipulation`. - - Note that the API does not use these enum types directly. Instead it uses ints, and the documentation/comments state - that certain ints correspond to certain enum types. This is because we want the API to be compiler-independent, and - the C standard does not dictate how many bytes must be used to represent an enum type. Nevertheless, for improved - readability, we recommend using these types when calling API functions which take them as arguments. - -- :ref:`C struct types`. These can be classified as: - - - Main structs: - - - :ref:`mjModel`. - - :ref:`mjOption` (embedded in :ref:`mjModel`). - - :ref:`mjData`. - - - :ref:`Auxiliary struct types`, also used by the engine. - - Structs for collecting :ref:`simulation statistics`. - - Structs for :ref:`abstract visualization`. - - Structs used by the :ref:`classic renderer`. - - Structs used by the :ref:`filament renderer`. - - Structs used by the :ref:`UI framework`. - - Structs used for :ref:`procedural model manipulation`. - - Structs used by :ref:`engine plugins`. - -- Several :ref:`function types` for user-defined callbacks. -- :ref:`tyNotes` regarding specific data structures that require detailed description. - - - -.. _tyPrimitive: - -Primitive types ---------------- - -The three types below are defined in `mjtype.h `__. - - -.. _mjtNum: - -mjtNum -^^^^^^ - -This is the floating-point type used throughout the simulator. When using the default build configuration, ``mjtNum`` is -defined as ``double``. If the symbol ``mjUSESINGLE`` is defined, ``mjtNum`` is defined as ``float``. - -Currently only the double-precision version of MuJoCo is distributed, although the entire code base works with -single-precision as well. We may release the single-precision version in the future, but the -double-precision version will always be available. Thus it is safe to write user code assuming double precision. -However, our preference is to write code that works with either single or double precision. To this end we provide math -utility functions that are always defined with the correct floating-point type. - -Note that changing ``mjUSESINGLE`` in ``mjtype.h`` will not change how the library was compiled, and instead will -result in numerous link errors. In general, the header files distributed with precompiled MuJoCo should never be -changed by the user. - -.. code-block:: C - - // floating point data type and minval - #ifndef mjUSESINGLE - typedef double mjtNum; - #define mjMINVAL 1E-15 // minimum value in any denominator - #else - typedef float mjtNum; - #define mjMINVAL 1E-15f - #endif - - -.. _mjtByte: - -mjtByte -^^^^^^^ - -Byte type used to represent small integers and binary data. - -.. code-block:: C - - typedef unsigned char mjtByte; - - -.. _mjtBool: - -mjtBool -^^^^^^^ - -Boolean type used to represent true/false values. - -.. code-block:: C - - #ifndef __cplusplus - typedef _Bool mjtBool; - #else - typedef bool mjtBool; - #endif - - -.. _mjtSize: - -mjtSize -^^^^^^^ - -Size type used to represent buffer sizes. - -.. code-block:: C - - typedef int64_t mjtSize; - - -.. _tyEnums: - -Enum types ----------- - -All enum types use the ``mjt`` prefix. - -.. _tyModelEnums: - -Model -^^^^^ - -The enums below are defined in `mjtype.h `__. - - -.. _mjtDisableBit: - -mjtDisableBit -~~~~~~~~~~~~~ - -Constants which are powers of 2. They are used as bitmasks for the field ``disableflags`` of :ref:`mjOption`. -At runtime this field is ``m->opt.disableflags``. The number of these constants is given by ``mjNDISABLE`` which is -also the length of the global string array :ref:`mjDISABLESTRING` with text descriptions of these flags. - -.. mujoco-include:: mjtDisableBit - - -.. _mjtEnableBit: - -mjtEnableBit -~~~~~~~~~~~~ - -Constants which are powers of 2. They are used as bitmasks for the field ``enableflags`` of :ref:`mjOption`. -At runtime this field is ``m->opt.enableflags``. The number of these constants is given by ``mjNENABLE`` which is also -the length of the global string array :ref:`mjENABLESTRING` with text descriptions of these flags. - -.. mujoco-include:: mjtEnableBit - - -.. _mjtJoint: - -mjtJoint -~~~~~~~~ - -Primitive joint types. These values are used in ``m->jnt_type``. The numbers in the comments indicate how many -positional coordinates each joint type has. Note that ball joints and rotational components of free joints are -represented as unit quaternions - which have 4 positional coordinates but 3 degrees of freedom each. - -.. mujoco-include:: mjtJoint - - -.. _mjtGeom: - -mjtGeom -~~~~~~~ - -Geometric types supported by MuJoCo. The first group are "official" geom types that can be used in the model. The -second group are geom types that cannot be used in the model but are used by the visualizer to add decorative -elements. These values are used in ``m->geom_type`` and ``m->site_type``. - -.. mujoco-include:: mjtGeom - - -.. _mjtProjection: - -mjtProjection -~~~~~~~~~~~~~ - -Type of camera projection. Used in ``m->cam_projection``. - -.. mujoco-include:: mjtProjection - - -.. _mjtCamLight: - -mjtCamLight -~~~~~~~~~~~ - -Dynamic modes for cameras and lights, specifying how the camera/light position and orientation are computed. These -values are used in ``m->cam_mode`` and ``m->light_mode``. - -.. mujoco-include:: mjtCamLight - - -.. _mjtLightType: - -mjtLightType -~~~~~~~~~~~~ - -The type of a light source describing how its position, orientation and other properties will interact with the -objects in the scene. These values are used in ``m->light_type``. - -.. mujoco-include:: mjtLightType - - -.. _mjtTexture: - -mjtTexture -~~~~~~~~~~ - -Texture types, specifying how the texture will be mapped. These values are used in ``m->tex_type``. - -.. mujoco-include:: mjtTexture - - -.. _mjtTextureRole: - -mjtTextureRole -~~~~~~~~~~~~~~ - -Texture roles, specifying how the renderer should interpret the texture. Note that the MuJoCo built-in renderer only -uses RGB textures. These values are used to store the texture index in the material's array ``m->mat_texid``. - -.. mujoco-include:: mjtTextureRole - - -.. _mjtColorSpace: - -mjtColorSpace -~~~~~~~~~~~~~ - -Type of color space encoding for textures. - -.. mujoco-include:: mjtColorSpace - - -.. _mjtIntegrator: - -mjtIntegrator -~~~~~~~~~~~~~ - -Numerical integrator types. These values are used in ``m->opt.integrator``. - -.. mujoco-include:: mjtIntegrator - -.. _mjtCone: - -mjtCone -~~~~~~~ - -Available friction cone types. These values are used in ``m->opt.cone``. - -.. mujoco-include:: mjtCone - -.. _mjtJacobian: - -mjtJacobian -~~~~~~~~~~~ - -Available Jacobian types. These values are used in ``m->opt.jacobian``. - -.. mujoco-include:: mjtJacobian - - -.. _mjtSolver: - -mjtSolver -~~~~~~~~~ - -Available constraint solver algorithms. These values are used in ``m->opt.solver``. - -.. mujoco-include:: mjtSolver - - -.. _mjtEq: - -mjtEq -~~~~~ - -Equality constraint types. These values are used in ``m->eq_type``. - -.. mujoco-include:: mjtEq - - -.. _mjtWrap: - -mjtWrap -~~~~~~~ - -Tendon wrapping object types. These values are used in ``m->wrap_type``. - -.. mujoco-include:: mjtWrap - - -.. _mjtTrn: - -mjtTrn -~~~~~~ - -Actuator transmission types. These values are used in ``m->actuator_trntype``. - -.. mujoco-include:: mjtTrn - - -.. _mjtDyn: - -mjtDyn -~~~~~~ - -Actuator dynamics types. These values are used in ``m->actuator_dyntype``. - -.. mujoco-include:: mjtDyn - - -.. _mjtGain: - -mjtGain -~~~~~~~ - -Actuator gain types. These values are used in ``m->actuator_gaintype``. - -.. mujoco-include:: mjtGain - - -.. _mjtBias: - -mjtBias -~~~~~~~ - -Actuator bias types. These values are used in ``m->actuator_biastype``. - -.. mujoco-include:: mjtBias - - -.. _mjtCtrlChart: - -mjtCtrlChart -~~~~~~~~~~~~ - -Orientation input charts of so3 actuators. These values are used in ``m->actuator_ctrlspec``. - -.. mujoco-include:: mjtCtrlChart - - -.. _mjtCtrlInput: - -mjtCtrlInput -~~~~~~~~~~~~ - -Input bitflags of servo-family (pd, dcmotor) actuators. These values are used in ``m->actuator_ctrlspec``. - -.. mujoco-include:: mjtCtrlInput - - -.. _mjtObj: - -mjtObj -~~~~~~ - -MuJoCo object types. These are used, for example, in the support functions :ref:`mj_name2id` and -:ref:`mj_id2name` to convert between object names and integer ids. - -.. mujoco-include:: mjtObj - - -.. _mjtSensor: - -mjtSensor -~~~~~~~~~ - -Sensor types. These values are used in ``m->sensor_type``. - -.. mujoco-include:: mjtSensor - - -.. _mjtStage: - -mjtStage -~~~~~~~~ - -These are the compute stages for the skipstage parameters of :ref:`mj_forwardSkip` and -:ref:`mj_inverseSkip`. - -.. mujoco-include:: mjtStage - - -.. _mjtDataType: - -mjtDataType -~~~~~~~~~~~ - -These are the possible sensor data types, used in ``mjData.sensor_datatype``. - -.. mujoco-include:: mjtDataType - - -.. _mjtConDataField: - -mjtConDataField -~~~~~~~~~~~~~~~ - -Types of data fields returned by contact sensors. - -.. mujoco-include:: mjtConDataField - - -.. _mjtRayDataField: - -mjtRayDataField -~~~~~~~~~~~~~~~ - -Data fields returned by rangefinder sensors. - -.. mujoco-include:: mjtRayDataField - - -.. _mjtCamOutBit: - -mjtCamOutBit -~~~~~~~~~~~~ - -Camera output type bitflags. These are used in ``m->cam_output``. - -.. mujoco-include:: mjtCamOutBit - - -.. _mjtSameFrame: - -mjtSameFrame -~~~~~~~~~~~~ - -Types of frame alignment of elements with their parent bodies. Used as shortcuts during :ref:`mj_kinematics` in the -last argument to :ref:`mj_local2global`. - -.. mujoco-include:: mjtSameFrame - - -.. _mjtSleepPolicy: - -mjtSleepPolicy -~~~~~~~~~~~~~~ - -Sleep policy associated with a tree. The compiler automatically chooses between ``NEVER`` and ``ALLOWED``, but the user -can override this choice. Only the user can set the ``INIT`` policy (initialized as asleep). - -.. mujoco-include:: mjtSleepPolicy - - -.. _mjtLRMode: - -mjtLRMode -~~~~~~~~~ - -Mode for actuator length range computation. Used in ``mjLROpt.mode``. - -.. mujoco-include:: mjtLRMode - - -.. _mjtFlexSelf: - -mjtFlexSelf -~~~~~~~~~~~~ - -Types of flex self-collisions midphase. - -.. mujoco-include:: mjtFlexSelf - - -.. _mjtSDFType: - -mjtSDFType -~~~~~~~~~~~ - -Formulas used to combine SDFs when calling mjc_distance and mjc_gradient. - -.. mujoco-include:: mjtSDFType - - -.. _tyDataEnums: - -Data -^^^^ - -The enums below are defined in `mjtype.h `__. - - - -.. _mjtState: - -mjtState -~~~~~~~~ - -State component elements as integer bitflags and several convenient combinations of these flags. Used by -:ref:`mj_getState`, :ref:`mj_setState` and :ref:`mj_stateSize`. - -.. mujoco-include:: mjtState - - -.. _mjtConstraint: - -mjtConstraint -~~~~~~~~~~~~~ - -Constraint types. These values are not used in mjModel, but are used in the mjData field ``d->efc_type`` when the list -of active constraints is constructed at each simulation time step. - -.. mujoco-include:: mjtConstraint - - -.. _mjtConstraintState: - -mjtConstraintState -~~~~~~~~~~~~~~~~~~ - -These values are used by the solver internally to keep track of the constraint states. - -.. mujoco-include:: mjtConstraintState - - -.. _mjtWarning: - -mjtWarning -~~~~~~~~~~ - -Warning types. The number of warning types is given by ``mjNWARNING`` which is also the length of the array -``mjData.warning``. - -.. mujoco-include:: mjtWarning - - -.. _mjtTimer: - -mjtTimer -~~~~~~~~ - -Timer types. The number of timer types is given by ``mjNTIMER`` which is also the length of the array -``mjData.timer``, as well as the length of the string array :ref:`mjTIMERSTRING` with timer names. - -.. mujoco-include:: mjtTimer - - -.. _mjtSleepState: - -mjtSleepState -~~~~~~~~~~~~~ - -Sleep state of an object. - -.. mujoco-include:: mjtSleepState - - -.. _tyLogEnums: - -Logging -~~~~~~~ - -.. _mjtLogLevel: - -mjtLogLevel -""""""""""" - -Log message severity level. - -.. mujoco-include:: mjtLogLevel - - -.. _mjtLogTopic: - -mjtLogTopic -""""""""""" - -Topic identifiers for informational messages. Used with :ref:`mju_info` for topic-based filtering. -Topic 0 (``mjTOPIC_NONE``) always passes through the default handler's filter. Other topics must be enabled in -the :ref:`mjLogConfig` bitmask. Since topics are 1-indexed, the bitmask for topic ``t`` is ``(1 << (t - 1))``. - -.. mujoco-include:: mjtLogTopic - - -.. _tyVisEnums: - -Visualization -^^^^^^^^^^^^^ - -The enums below are defined in `mjvisualize.h `__. - - -.. _mjtCatBit: - -mjtCatBit -~~~~~~~~~ - -These are the available categories of geoms in the abstract visualizer. The bitmask can be used in the function -:ref:`mjr_render` to specify which categories should be rendered. - -.. mujoco-include:: mjtCatBit - - -.. _mjtMouse: - -mjtMouse -~~~~~~~~ - -These are the mouse actions that the abstract visualizer recognizes. It is up to the user to intercept mouse events -and translate them into these actions, as illustrated in :ref:`simulate.cc `. - -.. mujoco-include:: mjtMouse - - -.. _mjtPertBit: - -mjtPertBit -~~~~~~~~~~ - -These bitmasks enable the translational and rotational components of the mouse perturbation. For the regular mouse, -only one can be enabled at a time. For the 3D mouse (SpaceNavigator) both can be enabled simultaneously. They are used -in ``mjvPerturb.active``. - -.. mujoco-include:: mjtPertBit - - -.. _mjtCamera: - -mjtCamera -~~~~~~~~~ - -These are the possible camera types, used in ``mjvCamera.type``. - -.. mujoco-include:: mjtCamera - - -.. _mjtLabel: - -mjtLabel -~~~~~~~~ - -These are the abstract visualization elements that can have text labels. Used in ``mjvOption.label``. - -.. mujoco-include:: mjtLabel - - -.. _mjtFrame: - -mjtFrame -~~~~~~~~ - -These are the MuJoCo objects whose spatial frames can be rendered. Used in ``mjvOption.frame``. - -.. mujoco-include:: mjtFrame - - -.. _mjtVisFlag: - -mjtVisFlag -~~~~~~~~~~ - -These are indices in the array ``mjvOption.flags``, whose elements enable/disable the visualization of the -corresponding model or decoration element. - -.. mujoco-include:: mjtVisFlag - - -.. _mjtRndFlag: - -mjtRndFlag -~~~~~~~~~~ - -These are indices in the array ``mjvScene.flags``, whose elements enable/disable OpenGL rendering effects. - -.. mujoco-include:: mjtRndFlag - - -.. _mjtStereo: - -mjtStereo -~~~~~~~~~ - -These are the possible stereo rendering types. They are used in ``mjvScene.stereo``. - -.. mujoco-include:: mjtStereo - - - -.. _tyRenderEnums: - -Rendering -^^^^^^^^^ - -The enums below are defined in `mjrender.h `__. - - -.. _mjtGridPos: - -mjtGridPos -~~~~~~~~~~ - -These are the possible grid positions for text overlays. They are used as an argument to the function -:ref:`mjr_overlay`. - -.. mujoco-include:: mjtGridPos - - -.. _mjtFramebuffer: - -mjtFramebuffer -~~~~~~~~~~~~~~ - -These are the possible framebuffers. They are used as an argument to the function :ref:`mjr_setBuffer`. - -.. mujoco-include:: mjtFramebuffer - - -.. _mjtDepthMap: - -mjtDepthMap -~~~~~~~~~~~ - -These are the depth mapping options. They are used as a value for the ``readPixelDepth`` attribute of the -:ref:`mjrContext` struct, to control how the depth returned by :ref:`mjr_readPixels` is mapped from -``znear`` to ``zfar``. - -.. mujoco-include:: mjtDepthMap - - -.. _mjtFontScale: - -mjtFontScale -~~~~~~~~~~~~ - -These are the possible font sizes. The fonts are predefined bitmaps stored in the dynamic library at three different -sizes. - -.. mujoco-include:: mjtFontScale - - -.. _mjtFont: - -mjtFont -~~~~~~~ - -These are the possible font types. - -.. mujoco-include:: mjtFont - -.. _mjrPixelFormat: - -mjrPixelFormat -~~~~~~~~~~~~~~ - -These are the possible values: - -.. mujoco-include:: mjrPixelFormat - -.. _mjrVertexAttributeUsage: - -mjrVertexAttributeUsage -~~~~~~~~~~~~~~~~~~~~~~~ - -These are the possible values: - -.. mujoco-include:: mjrVertexAttributeUsage - -.. _mjrVertexAttributeType: - -mjrVertexAttributeType -~~~~~~~~~~~~~~~~~~~~~~ - -These are the possible values: - -.. mujoco-include:: mjrVertexAttributeType - -.. _mjrIndexType: - -mjrIndexType -~~~~~~~~~~~~ - -These are the possible values: - -.. mujoco-include:: mjrIndexType - -.. _mjrMeshPrimitiveType: - -mjrMeshPrimitiveType -~~~~~~~~~~~~~~~~~~~~ - -There are the possible values: - -.. mujoco-include:: mjrMeshPrimitiveType - - -.. _tyFilamentRenderEnums: - -Filament Rendering -^^^^^^^^^^^^^^^^^^ - -The enums below are defined in `mjrfilament.h `__. - - -.. _mjrGraphicsApi: - -mjrGraphicsApi -~~~~~~~~~~~~~~ - -The underlying graphics API to use for Filament rendering. - -.. mujoco-include:: mjrGraphicsApi - - -.. _mjrDrawMode: - -mjrDrawMode -~~~~~~~~~~~ - -High-level control for how to draw objects in the scene for Filament rendering. - -.. mujoco-include:: mjrDrawMode - - -.. _tyUIEnums: - -User Interface -^^^^^^^^^^^^^^ - -The enums below are defined in `mjui.h `__. - - -.. _mjtButton: - -mjtButton -~~~~~~~~~ - -Mouse button IDs used in the UI framework. - -.. mujoco-include:: mjtButton - - -.. _mjtEvent: - -mjtEvent -~~~~~~~~ - -Event types used in the UI framework. - -.. mujoco-include:: mjtEvent - - -.. _mjtItem: - -mjtItem -~~~~~~~ - -Item types used in the UI framework. - -.. mujoco-include:: mjtItem - - -.. _mjtSection: - -mjtSection -~~~~~~~~~~ - -State of a UI section. - -.. mujoco-include:: mjtSection - - - -.. _tySpecEnums: - -Spec -^^^^ - -The enums below are defined in `mjspec.h `__. - -.. _mjtGeomInertia: - -mjtGeomInertia -~~~~~~~~~~~~~~ - -Type of inertia inference. - -.. mujoco-include:: mjtGeomInertia - -.. _mjtBuiltin: - -mjtBuiltin -~~~~~~~~~~ - -Type of built-in procedural texture. - -.. mujoco-include:: mjtBuiltin - -.. _mjtMark: - -mjtMark -~~~~~~~ - -Mark type for procedural textures. - -.. mujoco-include:: mjtMark - -.. _mjtLimited: - -mjtLimited -~~~~~~~~~~ - -Type of limit specification. - -.. mujoco-include:: mjtLimited - -.. _mjtAlignFree: - -mjtAlignFree -~~~~~~~~~~~~ - -Whether to align free joints with the inertial frame. - -.. mujoco-include:: mjtAlignFree - -.. _mjtInertiaFromGeom: - -mjtInertiaFromGeom -~~~~~~~~~~~~~~~~~~ - -Whether to infer body inertias from child geoms. - -.. mujoco-include:: mjtInertiaFromGeom - -.. _mjtOrientation: - -mjtOrientation -~~~~~~~~~~~~~~ - -Type of orientation specifier. - -.. mujoco-include:: mjtOrientation - -.. _mjtMeshInertia: - -mjtMeshInertia -~~~~~~~~~~~~~~ - -Type of mesh inertia computation. - -.. mujoco-include:: mjtMeshInertia - -.. _mjtMeshBuiltin: - -mjtMeshBuiltin -~~~~~~~~~~~~~~ - -Type of built-in procedural mesh. - -.. mujoco-include:: mjtMeshBuiltin - -.. _mjtConflict: - -mjtConflict -~~~~~~~~~~~ - -Conflict resolution mode for attach. - -.. mujoco-include:: mjtConflict - - -.. _mjtCTimer: - -mjtCTimer -~~~~~~~~~ - -Compiler timing categories, used in :ref:`mjs_getTimer`. Top-level timers (``TOTAL``, ``ASSETS``) measure wall-clock -time. Asset sub-timers measure CPU time summed across all assets; with multi-threaded compilation their sum can exceed -the ``ASSETS`` wall-clock time. - -.. mujoco-include:: mjtCTimer - - -.. _tyPluginEnums: - -Plugins -^^^^^^^ - -The enums below are defined in `mjplugin.h `__. -See :ref:`exPlugin` for details. - - -.. _mjtPluginCapabilityBit: - -mjtPluginCapabilityBit -~~~~~~~~~~~~~~~~~~~~~~ - -Capabilities declared by an engine plugin. - -.. mujoco-include:: mjtPluginCapabilityBit - - - -.. _tyStructure: - -Struct types ------------- - -The three central struct types for physics simulation are :ref:`mjModel`, :ref:`mjOption` (embedded in :ref:`mjModel`) -and :ref:`mjData`. An introductory discussion of these structures can be found in the :ref:`Overview`. - - -.. _mjModel: - -mjModel -^^^^^^^ - -This is the main data structure holding the MuJoCo model. It is treated as constant by the simulator. Some specific -details regarding datastructures in :ref:`mjModel` can be found below in :ref:`tyNotes`. - -.. mujoco-include:: mjModel - - - -.. _mjOption: - -mjOption -^^^^^^^^ - -This is the data structure with simulation options. It corresponds to the MJCF element -:ref:`option