Merge pull request 'Cen' (#4) from Cen into main
Reviewed-on: #4
@@ -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:
|
||||
<details>
|
||||
<summary>minimal XML</summary>
|
||||
|
||||
```XML
|
||||
|
||||
<mujoco>
|
||||
<worldbody>
|
||||
<light pos="0 0 1"/>
|
||||
<geom type="sphere" size="1" rgba="1 0 0 1"/>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
|
||||
```
|
||||
</details>
|
||||
|
||||
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
|
||||
|
||||
@@ -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).
|
||||
|
||||
<details>
|
||||
<summary>minimal XML</summary>
|
||||
|
||||
```XML
|
||||
|
||||
<mujoco>
|
||||
<worldbody>
|
||||
<light pos="0 0 1"/>
|
||||
<geom type="sphere" size="1" rgba="1 0 0 1"/>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
|
||||
```
|
||||
</details>
|
||||
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
|
||||
|
||||
@@ -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 🎉!
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -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 }}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/>
|
||||
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 $<TARGET_FILE_DIR:mujoco>/Headers
|
||||
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ${MUJOCO_HEADERS} $<TARGET_FILE_DIR:mujoco>/Headers
|
||||
COMMAND mkdir -p $<TARGET_FILE_DIR:mujoco>/Modules
|
||||
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/dist/module.modulemap $<TARGET_FILE_DIR:mujoco>/Modules
|
||||
COMMAND mkdir -p $<TARGET_FILE_DIR:mujoco>/Resources
|
||||
COMMAND mv ${CMAKE_CURRENT_SOURCE_DIR}/dist/Info.framework.plist
|
||||
$<TARGET_FILE_DIR:mujoco>/Resources/Info.plist
|
||||
COMMAND ${TAPI} stubify $<TARGET_FILE:mujoco> -o $<TARGET_FILE_DIR:mujoco>/mujoco.tbd
|
||||
COMMAND ln -fhs A $<TARGET_FILE_DIR:mujoco>/../Current
|
||||
COMMAND ln -fhs Versions/Current/mujoco.tbd $<TARGET_FILE_DIR:mujoco>/../../mujoco.tbd
|
||||
COMMAND ln -fhs Versions/Current/Headers $<TARGET_FILE_DIR:mujoco>/../../Headers
|
||||
COMMAND ln -fhs Versions/Current/Modules $<TARGET_FILE_DIR:mujoco>/../../Modules
|
||||
COMMAND ln -fhs Versions/Current/Resources $<TARGET_FILE_DIR:mujoco>/../../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()
|
||||
@@ -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
|
||||
<https://cla.developers.google.com/> 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/).
|
||||
@@ -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/<project-id>/...` 虚拟根目录,规范化路径后通过 `FS.mkdirTree/writeFile` 写入 MEMFS;二进制文件保持 `Uint8Array`,文本 XML 使用 UTF-8。
|
||||
- [x] 入口规则:单个 XML/URDF 自动选中;多候选优先根目录 `model.xml`/`scene.xml`/唯一 `.urdf`,否则弹窗选择且按根元素 `<mujoco>`/`<robot>`标识类型。
|
||||
- [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。
|
||||
@@ -1,155 +1,71 @@
|
||||
<h1>
|
||||
<a href="#"><img alt="MuJoCo" src="banner.png" width="100%"/></a>
|
||||
</h1>
|
||||
# MuJoCo Web 仿真平台
|
||||
|
||||
<p>
|
||||
<a href="https://github.com/google-deepmind/mujoco/actions/workflows/build.yml?query=branch%3Amain" alt="GitHub Actions">
|
||||
<img src="https://img.shields.io/github/actions/workflow/status/google-deepmind/mujoco/build.yml?branch=main">
|
||||
</a>
|
||||
<a href="https://mujoco.readthedocs.io/" alt="Documentation">
|
||||
<img src="https://readthedocs.org/projects/mujoco/badge/?version=latest">
|
||||
</a>
|
||||
<a href="https://github.com/google-deepmind/mujoco/blob/main/LICENSE" alt="License">
|
||||
<img src="https://img.shields.io/github/license/google-deepmind/mujoco">
|
||||
</a>
|
||||
</p>
|
||||
以 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 基础知识:
|
||||
[](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/tutorial.ipynb)
|
||||
- **模型编辑**教程演示如何通过代码程序化创建和编辑模型:
|
||||
[](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/mjspec.ipynb)
|
||||
- **rollout** 教程介绍如何使用多线程 `rollout` 模块:
|
||||
[](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/rollout.ipynb)
|
||||
- **LQR** 教程演示如何合成线性二次型控制器(LQR),实现人形机器人单腿平衡:
|
||||
[](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/LQR.ipynb)
|
||||
- **最小二乘法**教程解释如何使用基于 Python 的非线性最小二乘求解器:
|
||||
[](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 分支版本:
|
||||
[](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/mjx/tutorial.ipynb)
|
||||
- **可微物理**教程展示如何利用从 MuJoCo 物理计算步中自动推导出的解析梯度来训练运动控制策略:
|
||||
[](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 输出的地址,默认是 <http://localhost:5173/>。
|
||||
|
||||
## 版本规范
|
||||
## 常用命令
|
||||
|
||||
我们力求在每月的首周发布新版本 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 官方支持的产品。
|
||||
|
||||
@@ -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.
|
||||
@@ -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`.
|
||||
@@ -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`.
|
||||
|
Before Width: | Height: | Size: 101 KiB |
@@ -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 <immintrin.h>
|
||||
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()
|
||||
@@ -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()
|
||||
@@ -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 $<BUILD_INTERFACE:${lodepng_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)
|
||||
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 $<BUILD_INTERFACE:${qhull_SOURCE_DIR}/src/libqhull_r>
|
||||
)
|
||||
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
|
||||
)
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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 $<TARGET_FILE_DIR:${TARGET_BINARY}>
|
||||
)
|
||||
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=$<TARGET_FILE:${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=$<TARGET_FILE_DIR:mujoco>"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -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()
|
||||
@@ -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(<source_location>)
|
||||
-#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
|
||||
@@ -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
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
|
||||
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)
|
||||
@@ -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"
|
||||
@@ -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(
|
||||
- $<$<CONFIG:>:/MT>
|
||||
- $<$<CONFIG:Debug>:/MTd>
|
||||
- $<$<CONFIG:Release>:/MT>
|
||||
- )
|
||||
- else()
|
||||
- add_compile_options(
|
||||
- $<$<CONFIG:>:/MD>
|
||||
- $<$<CONFIG:Debug>:/MDd>
|
||||
- $<$<CONFIG:Release>:/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(
|
||||
+ $<$<CONFIG:>:/MT>
|
||||
+ $<$<CONFIG:Debug>:/MTd>
|
||||
+ $<$<CONFIG:Release>:/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(
|
||||
+ $<$<CONFIG:>:/MD>
|
||||
+ $<$<CONFIG:Debug>:/MDd>
|
||||
+ $<$<CONFIG:Release>:/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<LONG>(width), static_cast<LONG>(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<Allocator, Elements...>::IteratorValueRef&
|
||||
StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef::assign(
|
||||
IteratorValue const& rhs, std::index_sequence<Is...>) {
|
||||
// implements IteratorValueRef& IteratorValueRef::operator=(IteratorValue const& rhs)
|
||||
- auto UTILS_UNUSED l = { (soa->elementAt<Is>(index) = std::get<Is>(rhs.elements), 0)... };
|
||||
+ UTILS_UNUSED auto l = { (soa->elementAt<Is>(index) = std::get<Is>(rhs.elements), 0)... };
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -751,7 +751,7 @@ template<size_t... Is>
|
||||
typename StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef&
|
||||
StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef::assign(
|
||||
Structure const& rhs, std::index_sequence<Is...>) {
|
||||
- auto UTILS_UNUSED l = {(soa->template elementAt<Is>(index) = std::get<Is>(rhs), 0)...};
|
||||
+ UTILS_UNUSED auto l = {(soa->template elementAt<Is>(index) = std::get<Is>(rhs), 0)...};
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -760,7 +760,7 @@ template<size_t... Is>
|
||||
typename StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef&
|
||||
StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef::assign(
|
||||
Structure&& rhs, std::index_sequence<Is...>) noexcept {
|
||||
- auto UTILS_UNUSED l = {(soa->template elementAt<Is>(index) = std::move(std::get<Is>(rhs)), 0)...};
|
||||
+ UTILS_UNUSED auto l = {(soa->template elementAt<Is>(index) = std::move(std::get<Is>(rhs)), 0)...};
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -770,7 +770,7 @@ typename StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef&
|
||||
StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef::assign(
|
||||
IteratorValue&& rhs, std::index_sequence<Is...>) noexcept {
|
||||
// implements IteratorValueRef& IteratorValueRef::operator=(IteratorValue&& rhs) noexcept
|
||||
- auto UTILS_UNUSED l = {
|
||||
+ UTILS_UNUSED auto l = {
|
||||
(soa->elementAt<Is>(index) = std::move(std::get<Is>(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 <typename Stream>
|
||||
-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 <windows.h>
|
||||
+#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#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<filament::math::fl
|
||||
size_t numBands);
|
||||
static void outputBinarySh(std::ostream& out, const std::unique_ptr<filament::math::float3[]>& sh,
|
||||
size_t numBands);
|
||||
-static void UTILS_UNUSED outputSpectrum(std::ostream& out,
|
||||
+UTILS_UNUSED static void outputSpectrum(std::ostream& out,
|
||||
const std::unique_ptr<filament::math::float3[]>& 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<filament::math::float3[]>& sh, size_t numBands) {
|
||||
// We assume a symetrical function (i.e. m!=0 terms are zero)
|
||||
for (ssize_t l = 0; l < numBands; l++) {
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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/*"
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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.
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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.
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -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 <cstring>, and
|
||||
# PostProcessManager.h uses std::optional without including <optional>.
|
||||
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}")
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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.
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -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})
|
||||
@@ -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()
|
||||
@@ -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
|
||||
<INSTALL_DIR>
|
||||
)
|
||||
@@ -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}
|
||||
)
|
||||
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleName</key>
|
||||
<string>MuJoCo</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.mujoco.framework</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${PROJECT_VERSION}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>${PROJECT_VERSION}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>libmujoco.dylib</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright 2021 DeepMind Technologies Limited.</string>
|
||||
<key>MDItemKeywords</key>
|
||||
<string>MuJoCo, physics engine, physics simulator, physics, MJ</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleName</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>simulate</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||
<key>MDItemKeywords</key>
|
||||
<string>MuJoCo, physics engine, physics simulator, physics, simulate, MJ, mujoco simulate, mj simulate</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,6 +0,0 @@
|
||||
framework module mujoco {
|
||||
umbrella header "mujoco.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
|
Before Width: | Height: | Size: 272 KiB |
@@ -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
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 175 KiB |
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
.. raw:: html
|
||||
|
||||
<div id="fetchlines"/>
|
||||
|
||||
|
||||
.. _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 <https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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<Parseandcompile>` an :ref:`mjModel` from XML files and assets.
|
||||
- :ref:`Main simulation<Mainsimulation>` entry points, including :ref:`mj_step`.
|
||||
|
||||
- **Support functions**
|
||||
- :ref:`Support<Support>` functions requiring :ref:`mjModel` and :ref:`mjData`.
|
||||
- Pipeline :ref:`components<Components>`, called from :ref:`mj_step`, :ref:`mj_forward` and :ref:`mj_inverse`.
|
||||
- :ref:`Sub components<Subcomponents>` of the simulation pipeline.
|
||||
- :ref:`Ray casting<Raycollisions>`.
|
||||
- :ref:`Printing<Printing>` of various quantities.
|
||||
- :ref:`Virtual file system<Virtualfilesystem>`, used to load assets from memory.
|
||||
- :ref:`Asset cache<Assetcache>`, used to speed up model compilation.
|
||||
- :ref:`Resources<Resources>`, interfacing with resource providers to load assets.
|
||||
- :ref:`Initialization<Initialization>` of data structures.
|
||||
- :ref:`Error and memory<Errorandmemory>`.
|
||||
- :ref:`Miscellaneous<Miscellaneous>` functions.
|
||||
|
||||
- **Visualization, Rendering, UI**
|
||||
- :ref:`Abstract interaction<Interaction>`: mouse control of cameras and perturbations.
|
||||
- :ref:`Abstract Visualization<Visualization-api>`.
|
||||
- :ref:`OpenGL rendering<OpenGLrendering>`.
|
||||
- :ref:`Filament rendering<FilamentRenderingApi>`.
|
||||
- :ref:`UI framework<UIframework>`.
|
||||
|
||||
- **Threads, Plugins, Derivatives**
|
||||
- :ref:`Derivatives<Derivatives-api>`.
|
||||
- :ref:`Signed Distance Functions<Signeddistancefunction>`.
|
||||
- :ref:`Thread<Thread>` |-| -related functions.
|
||||
- :ref:`Plugin<Plugins-api>` |-| -related functions.
|
||||
|
||||
- **Math**
|
||||
- Aliases for C :ref:`standard math<Standardmath>` functions.
|
||||
- :ref:`Vector math<Vectormath>`.
|
||||
- :ref:`Sparse math<Sparsemath>`.
|
||||
- :ref:`Quaternions<Quaternions>`.
|
||||
- :ref:`Pose transformations<Poses>`.
|
||||
- :ref:`Matrix decompositions and solvers<Decompositions>`.
|
||||
|
||||
- **Model editing**
|
||||
- :ref:`Attachment<Attachment>`.
|
||||
- :ref:`Tree elements<AddTreeElements>`.
|
||||
- :ref:`Non-tree elements<AddNonTreeElements>`.
|
||||
- :ref:`Set actuator parameters<Setactuatorparameters>`.
|
||||
- :ref:`Assets<AddAssets>`.
|
||||
- :ref:`Find and get utilities<FindAndGetUtilities>`.
|
||||
- :ref:`Attribute setters<AttributeSetters>`.
|
||||
- :ref:`Attribute getters<AttributeGetters>`.
|
||||
- :ref:`Spec utilities<SpecUtilities>`.
|
||||
- :ref:`Element initialization<ElementInitialization>`.
|
||||
- :ref:`Element casting<ElementCasting>`.
|
||||
|
||||
.. include:: functions.rst
|
||||
@@ -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<glCollision>` containing narrow-phase collision functions.
|
||||
- :ref:`String constants<glString>`.
|
||||
- :ref:`Numeric constants<glNumeric>`.
|
||||
- :ref:`Macros<Macros>`.
|
||||
- :ref:`X Macros<tyXMacro>`.
|
||||
|
||||
.. _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 <saSimulate>` and the ``mjTOPIC_TIME_STP``
|
||||
informational :ref:`topic <mjtLogTopic>` 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 <saSimulate>` 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 <saSimulate>`.
|
||||
|
||||
.. 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 <https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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 <https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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 <https://github.com/google-deepmind/mujoco/blob/main/VERSIONING.md>`__ for details.
|
||||
|
||||
|
||||
.. _glNumericEngine:
|
||||
|
||||
Engine constants
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Defined in `mjmodel.h <https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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 <https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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 <https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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<gePolynomial>`.
|
||||
* - ``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 <https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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 <https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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 <https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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<exRegistration>` 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
|
||||
<https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/mjxmacro.h>`_ and `mjspecmacro.h
|
||||
<https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/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.
|
||||
@@ -1,928 +0,0 @@
|
||||
..
|
||||
This file contains each section text along with function doc overrides. By default the docs use the function doc
|
||||
pulled from the header files.
|
||||
|
||||
.. _Virtualfilesystem:
|
||||
|
||||
Virtual file system (VFS) enables the user to load all necessary files in memory, including MJB binary model files, XML
|
||||
files (MJCF, URDF and included files), STL meshes, PNGs for textures and height fields, and HF files in our custom
|
||||
height field format. Model and resource files in the VFS can also be constructed programmatically (say using a Python
|
||||
library that writes to memory). Once all desired files are in the VFS, the user can call :ref:`mj_loadModel` or
|
||||
:ref:`mj_loadXML` with a pointer to the VFS. When this pointer is not NULL, the loaders will first check the VFS for any
|
||||
files they are about to load, and only access the disk if the file is not found in the VFS.
|
||||
|
||||
The VFS must first be allocated using :ref:`mj_defaultVFS` and must be freed with :ref:`mj_deleteVFS`.
|
||||
|
||||
|
||||
.. _mj_defaultVFS:
|
||||
|
||||
Initialize an empty VFS, :ref:`mj_deleteVFS` must be called to deallocate the VFS.
|
||||
|
||||
.. _mj_addFileVFS:
|
||||
|
||||
Add file to VFS. The directory argument is optional and can be NULL or empty. Returns 0 on success,
|
||||
2 on name collision, or -1 when an internal error occurs.
|
||||
|
||||
*Nullable:* ``directory``
|
||||
|
||||
.. _Assetcache:
|
||||
|
||||
The asset cache is a mechanism for caching assets (e.g. textures, meshes, etc.) to avoid repeated slow recompilation.
|
||||
The following methods provide way to control the capacity of the cache or to disable it altogether.
|
||||
|
||||
.. _Parseandcompile:
|
||||
|
||||
The key function here is :ref:`mj_loadXML`. It invokes the built-in parser and compiler, and either returns a pointer to
|
||||
a valid mjModel, or NULL - in which case the user should check the error information in the user-provided string.
|
||||
The model and all files referenced in it can be loaded from disk or from a VFS when provided.
|
||||
|
||||
.. _mj_compile:
|
||||
|
||||
Compile :ref:`mjSpec` to :ref:`mjModel`. A spec can be edited and compiled multiple times, returning a new
|
||||
:ref:`mjModel` instance that takes the edits into account.
|
||||
If compilation fails, :ref:`mj_compile` returns ``NULL``; the error can be read with :ref:`mjs_getError`.
|
||||
|
||||
.. _mj_recompile:
|
||||
|
||||
Recompile spec to model, preserving the state. Like :ref:`mj_compile`, this function compiles an :ref:`mjSpec` to an
|
||||
:ref:`mjModel`, with two differences. First, rather than returning an entirely new model, it will
|
||||
reallocate existing :ref:`mjModel` and :ref:`mjData` instances in-place. Second, it will preserve the
|
||||
:ref:`integration state<siIntegrationState>`, as given in the provided :ref:`mjData` instance, while accounting for
|
||||
newly added or removed degrees of freedom. This allows the user to continue simulation with the same model and data
|
||||
struct pointers while editing the model programmatically.
|
||||
|
||||
:ref:`mj_recompile` returns 0 if compilation succeed. In the case of failure, the given :ref:`mjModel` and :ref:`mjData`
|
||||
instances will be deleted; as in :ref:`mj_compile`, the compilation error can be read with :ref:`mjs_getError`.
|
||||
|
||||
.. _mj_saveLastXML:
|
||||
|
||||
Update XML data structures with info from low-level model created with :ref:`mj_loadXML`, save as MJCF.
|
||||
If error is not NULL, it must have size error_sz.
|
||||
|
||||
Note that this function only saves models that have been loaded with :ref:`mj_loadXML`, the legacy loading mechanism.
|
||||
See the :ref:`model editing<meOverview>` chapter to understand the difference between the old and new model loading and
|
||||
saving mechanisms.
|
||||
|
||||
.. _mj_saveXMLString:
|
||||
|
||||
Save spec to XML string, return 0 on success, -1 on failure. If the length of the output buffer is too small, returns
|
||||
the required size. XML saving automatically compiles the spec before saving.
|
||||
|
||||
.. _mj_saveXML:
|
||||
|
||||
Save spec to XML file, return 0 on success, -1 otherwise. XML saving requires that the spec first be compiled.
|
||||
|
||||
.. _mj_encode:
|
||||
|
||||
Encode :ref:`mjSpec` or :ref:`mjModel` to a file. The output format is determined by the file extension
|
||||
(case insensitive) or ``content_type``. Returns the number of bytes written on success, -1 on failure.
|
||||
|
||||
For detailed documentation, supported output formats (``.xml``, ``.mjb``, ``.txt``, ``.mjz``), and custom encoder
|
||||
plugins, see :ref:`Model Encoding & Saving <meSaving>`.
|
||||
|
||||
*Nullable:* ``s``, ``m``, ``vfs``, ``error``
|
||||
|
||||
.. _Mainsimulation:
|
||||
|
||||
These are the main entry points to the simulator. Most users will only need to call :ref:`mj_step`, which computes
|
||||
everything and advanced the simulation state by one time step. Controls and applied forces must either be set in advance
|
||||
(in ``mjData.{ctrl, qfrc_applied, xfrc_applied}``), or a control callback :ref:`mjcb_control` must be installed which
|
||||
will be called just before the controls and applied forces are needed. Alternatively, one can use :ref:`mj_step1` and
|
||||
:ref:`mj_step2` which break down the simulation pipeline into computations that are executed before and after the
|
||||
controls are needed; in this way one can set controls that depend on the results from :ref:`mj_step1`. Keep in mind
|
||||
though that the RK4 solver does not work with mj_step1/2. See :ref:`Pipeline` for a more detailed description.
|
||||
|
||||
mj_forward performs the same computations as :ref:`mj_step` but without the integration. It is useful after loading or
|
||||
resetting a model (to put the entire mjData in a valid state), and also for out-of-order computations that involve
|
||||
sampling or finite-difference approximations.
|
||||
|
||||
:ref:`mj_inverse` runs the inverse dynamics, and writes its output in ``mjData.qfrc_inverse``. Note that ``mjData.qacc``
|
||||
must be set before calling this function. Given the state (qpos, qvel, act), mj_forward maps from force to acceleration,
|
||||
while mj_inverse maps from acceleration to force. Mathematically these functions are inverse of each other, but
|
||||
numerically this may not always be the case because the forward dynamics rely on a constraint optimization algorithm
|
||||
which is usually terminated early. The difference between the results of forward and inverse dynamics can be computed
|
||||
with the function :ref:`mj_compareFwdInv`, which can be thought of as another solver accuracy check (as well as a
|
||||
general sanity check).
|
||||
|
||||
The skip version of :ref:`mj_forward` and :ref:`mj_inverse` are useful for example when qpos was unchanged but qvel was
|
||||
changed (usually in the context of finite differencing). Then there is no point repeating the computations that only
|
||||
depend on qpos. Calling the dynamics with skipstage = :ref:`mjSTAGE_POS<mjtStage>` will achieve these savings.
|
||||
|
||||
.. _Initialization:
|
||||
|
||||
This section contains functions that load/initialize the model or other data structures. Their use is well illustrated
|
||||
in the code samples.
|
||||
|
||||
.. _Printing:
|
||||
|
||||
These functions can be used to print various quantities to the screen for debugging purposes.
|
||||
|
||||
.. _Components:
|
||||
|
||||
These are components of the simulation pipeline, called internally from :ref:`mj_step`, :ref:`mj_forward` and
|
||||
:ref:`mj_inverse`. It is unlikely that the user will need to call them.
|
||||
|
||||
.. _mj_implicit:
|
||||
|
||||
Integrates the simulation state using an implicit-in-velocity integrator (either "implicit" or "implicitfast", see
|
||||
:ref:`Numerical Integration<geIntegration>`), and advances simulation time. See `mjdata.h
|
||||
<https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/mjdata.h>`__ for fields computed by this function.
|
||||
|
||||
.. _Subcomponents:
|
||||
|
||||
These are sub-components of the simulation pipeline, called internally from the components above.
|
||||
|
||||
.. _mj_makeM:
|
||||
|
||||
Compute the composite rigid body inertia with :ref:`mj_crb`, add terms due
|
||||
to :ref:`tendon armature<tendon-spatial-armature>`. The joint-space inertia matrix is stored in both ``mjData.qM`` and
|
||||
``mjData.M``. These arrays represent the same quantity using different layouts (parent-based and compressed sparse row,
|
||||
respectively).
|
||||
|
||||
.. _mj_factorM:
|
||||
|
||||
Compute sparse :math:`L^T D L` factorizaton of inertia matrix.
|
||||
|
||||
.. _mj_solveM:
|
||||
|
||||
Solve linear system :math:`M x = y` using factorization: :math:`x = (L^T D L)^{-1} y`
|
||||
|
||||
.. _mj_solveM2:
|
||||
|
||||
Half of linear solve: :math:`x = \sqrt{D^{-1}} (L^T)^{-1} y`
|
||||
|
||||
.. _mj_subtreeVel:
|
||||
|
||||
Sub-tree linear velocity and angular momentum: compute ``subtree_linvel``, ``subtree_angmom``.
|
||||
This function is triggered automatically if the subtree :ref:`velocity<sensor-subtreelinvel>` or
|
||||
:ref:`momentum<sensor-subtreeangmom>` sensors are present in the model.
|
||||
It is also triggered for :ref:`user sensors<sensor-user>` of :ref:`stage<sensor-user-needstage>` "vel".
|
||||
|
||||
.. _mj_rne:
|
||||
|
||||
Recursive Newton Euler: compute :math:`M(q) \ddot q + C(q,\dot q)`. ``flg_acc=0`` removes the inertial term (i.e.
|
||||
assumes :math:`\ddot q = 0`).
|
||||
|
||||
.. _mj_rnePostConstraint:
|
||||
|
||||
Recursive Newton Euler with final computed forces and accelerations.
|
||||
Computes three body-level ``nv x 6`` arrays, all defined in the subtreecom-based
|
||||
:ref:`c-frame<tyNotesCom>` and arranged in ``[rotation(3), translation(3)]`` order.
|
||||
|
||||
- ``cacc``: Body acceleration, required for :ref:`mj_objectAcceleration`.
|
||||
- ``cfrc_int``: Interaction force with the parent body.
|
||||
- ``cfrc_ext``: External force acting on the body.
|
||||
|
||||
This function is triggered automatically if the following sensors are present in the model:
|
||||
:ref:`accelerometer<sensor-accelerometer>`, :ref:`force<sensor-force>`, :ref:`torque<sensor-torque>`,
|
||||
:ref:`framelinacc<sensor-framelinacc>`, :ref:`frameangacc<sensor-frameangacc>`.
|
||||
It is also triggered for :ref:`user sensors<sensor-user>` of :ref:`stage<sensor-user-needstage>` "acc".
|
||||
|
||||
The computed force arrays ``cfrc_int`` and ``cfrc_ext`` currently suffer from a know bug, they do not take into account
|
||||
the effect of spatial tendons, see :issue:`832`.
|
||||
|
||||
.. _mj_constraintUpdate:
|
||||
|
||||
Compute ``efc_state``, ``efc_force``, ``qfrc_constraint``, and (optionally) cone Hessians.
|
||||
If ``cost`` is not ``NULL``, set ``*cost = s(jar)`` where ``jar = Jac*qacc - aref``.
|
||||
|
||||
*Nullable:* ``cost``
|
||||
|
||||
.. _Support:
|
||||
|
||||
These are support functions that need access to :ref:`mjModel` and :ref:`mjData`, unlike the utility functions which do
|
||||
not need such access. Support functions are called within the simulator but some of them can also be useful for custom
|
||||
computations, and are documented in more detail below.
|
||||
|
||||
.. _mj_stateSize:
|
||||
|
||||
Returns the number of :ref:`mjtNum` |-| s required for a given state signature. The bits of the integer ``sig``
|
||||
correspond to element fields of :ref:`mjtState`.
|
||||
|
||||
.. _mj_getState:
|
||||
|
||||
Copy concatenated state components specified by ``sig`` from ``d`` into ``state``. The bits of the integer
|
||||
``sig`` correspond to element fields of :ref:`mjtState`. Fails with :ref:`mju_error` if ``sig`` is invalid.
|
||||
|
||||
.. _mj_extractState:
|
||||
|
||||
Extract into ``dst`` the subset of components specified by ``dstsig`` from a state ``src`` previously obtained via
|
||||
:ref:`mj_getState` with components specified by ``srcsig``. Fails with :ref:`mju_error` if the bits set in ``dstsig``
|
||||
is not a subset of the bits set in ``srcsig``.
|
||||
|
||||
.. _mj_setState:
|
||||
|
||||
Copy concatenated state components specified by ``sig`` from ``state`` into ``d``. The bits of the integer
|
||||
``sig`` correspond to element fields of :ref:`mjtState`. Fails with :ref:`mju_error` if ``sig`` is invalid.
|
||||
|
||||
.. _mj_readCtrl:
|
||||
|
||||
Read the control value for an actuator at a given time, taking delays into account. If no history buffer exists, return
|
||||
``mjData.ctrl[id]``. If a history buffer exists (:ref:`nsample<actuator-general-nsample>` > 0), read from the delay
|
||||
buffer at ``time - actuator_delay[id]`` using the requested interpolation order:
|
||||
|
||||
- ``interp = 0``: Zero-order hold (piecewise constant)
|
||||
- ``interp = 1``: Piecewise Linear
|
||||
- ``interp = 2``: Cubic Spline (Catmull-Rom)
|
||||
- ``interp = -1``: Use the actuator's :ref:`interp<actuator-general-interp>` value.
|
||||
|
||||
Constant extrapolation is used outside of buffer bounds.
|
||||
|
||||
Note that the subtraction of the delay changes the semantic of the ``time`` argument from "time at which values were
|
||||
pushed into the delay buffer" to "time at which values come out of the delay buffer". See :ref:`Delays<CDelay>` for
|
||||
details.
|
||||
|
||||
.. _mj_readSensor:
|
||||
|
||||
Read a sensor value at a given time, taking delays into account. If no history buffer exists, return a pointer to the
|
||||
sensor's slice of ``mjData.sensordata``. If a history buffer exists (:ref:`nsample<sensor-nsample>` > 0), read from the
|
||||
history buffer at ``time - sensor_delay[id]``. Note that the subtraction of the delay changes the semantic of the
|
||||
``time`` argument from "time at which values were pushed into the delay buffer" to "time at which values come out of the
|
||||
delay buffer". See :ref:`Delays<CDelay>` for details.
|
||||
|
||||
**Return value semantics:**
|
||||
|
||||
- If no history buffer exists (:ref:`nsample<sensor-nsample>` = 0), returns a pointer to the sensor's slice of
|
||||
``mjData.sensordata``.
|
||||
- If a history buffer exists (:ref:`nsample<sensor-nsample>` > 0) and the requested time matches a stored sample
|
||||
(always true for ``interp = 0``), returns a pointer to the data in the history buffer.
|
||||
- If interpolation is required (``interp = 1 or 2``), returns ``NULL`` and writes the interpolated result to
|
||||
``result`` (must be of size ``dim``).
|
||||
|
||||
**Interpolation:**
|
||||
|
||||
- ``interp = 0``: Zero-order hold (piecewise constant)
|
||||
- ``interp = 1``: Piecewise Linear
|
||||
- ``interp = 2``: Cubic Spline (Catmull-Rom)
|
||||
- ``interp = -1``: Use the value in :ref:`interp<sensor-interp>`
|
||||
|
||||
Constant extrapolation is used outside of buffer bounds.
|
||||
|
||||
|
||||
**Usage:**
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
// read sensor 0 of data size `dim` at time t
|
||||
mjtNum result[dim];
|
||||
const mjtNum* ptr = mj_readSensor(m, d, 0, t, result, /* interp = */ 1);
|
||||
const mjtNum* data = ptr ? ptr : result;
|
||||
|
||||
.. _mj_initCtrlHistory:
|
||||
|
||||
Initialize the history buffer for an actuator with custom values. The ``times`` array specifies the timestamps for each
|
||||
sample (must be length :ref:`nsample<actuator-general-nsample>`), and ``values`` specifies the control values. If
|
||||
``times`` is ``NULL``, the existing timestamps in the buffer are used, and only the values are updated.
|
||||
See :ref:`Delays<CDelay>` for details.
|
||||
|
||||
.. _mj_initSensorHistory:
|
||||
|
||||
Initialize the history buffer for a sensor with custom values. The ``times`` array specifies the timestamps for each
|
||||
sample (must be length :ref:`nsample<sensor-nsample>`), and ``values`` specifies the sensor values (must be of size
|
||||
``nsample * dim``). If ``times`` is ``NULL``, the existing timestamps in the buffer are used.
|
||||
The ``phase`` argument sets the user slot, which stores the last computation time for interval sensors.
|
||||
See :ref:`Delays<CDelay>` for details.
|
||||
|
||||
.. _mj_mulJacVec:
|
||||
|
||||
This function multiplies the constraint Jacobian mjData.efc_J by a vector. Note that the Jacobian can be either dense or
|
||||
sparse; the function is aware of this setting. Multiplication by J maps velocities from joint space to constraint space.
|
||||
|
||||
.. _mj_mulJacTVec:
|
||||
|
||||
Same as mj_mulJacVec but multiplies by the transpose of the Jacobian. This maps forces from constraint space to joint
|
||||
space.
|
||||
|
||||
.. _mj_jac:
|
||||
|
||||
This function computes an end-effector kinematic Jacobian, describing the local linear relationship between the
|
||||
degrees-of-freedom and a given point. Given a body specified by its integer id (``body``) and a 3D point in the world
|
||||
frame (``point``) treated as attached to the body, the Jacobian has both translational (``jacp``) and rotational
|
||||
(``jacr``) components. Passing ``NULL`` for either pointer will skip that part of the computation. Each component is a
|
||||
3-by-nv matrix. Each row of this matrix is the gradient of the corresponding coordinate of the specified point with
|
||||
respect to the degrees-of-freedom. The frame with respect to which the Jacobian is computed is centered at the body
|
||||
center-of-mass but aligned with the world frame. The minimal :ref:`pipeline stages<piForward>` required for Jacobian
|
||||
computations to be consistent with the current generalized positions ``mjData.qpos`` are :ref:`mj_kinematics` followed
|
||||
by :ref:`mj_comPos`.
|
||||
|
||||
*Nullable:* ``jacp``, ``jacr``
|
||||
|
||||
.. _mj_jacBody:
|
||||
|
||||
This and the remaining variants of the Jacobian function call mj_jac internally, with the center of the body, geom or
|
||||
site. They are just shortcuts; the same can be achieved by calling mj_jac directly.
|
||||
|
||||
*Nullable:* ``jacp``, ``jacr``
|
||||
|
||||
.. _mj_jacDot:
|
||||
|
||||
This function computes the time-derivative of an end-effector kinematic Jacobian computed by :ref:`mj_jac`.
|
||||
The minimal :ref:`pipeline stages<piStages>` required for computation to be
|
||||
consistent with the current generalized positions and velocities ``mjData.{qpos, qvel}`` are
|
||||
:ref:`mj_kinematics`, :ref:`mj_comPos`, :ref:`mj_comVel` (in that order).
|
||||
|
||||
*Nullable:* ``jacp``, ``jacr``
|
||||
|
||||
.. _mj_angmomMat:
|
||||
|
||||
This function computes the ``3 x nv`` angular momentum matrix :math:`H(q)`, providing the linear mapping from
|
||||
generalized velocities to subtree angular momentum. More precisely if :math:`h` is the subtree angular momentum of
|
||||
body index ``body`` in ``mjData.subtree_angmom`` (reported by the :ref:`subtreeangmom<sensor-subtreeangmom>` sensor)
|
||||
and :math:`\dot q` is the generalized velocity ``mjData.qvel``, then :math:`h = H \dot q`.
|
||||
|
||||
.. _mj_name2id:
|
||||
|
||||
Get id of object with the specified :ref:`mjtObj` type and name, returns -1 if id not found.
|
||||
|
||||
.. _mj_id2name:
|
||||
|
||||
Get name of object with the specified :ref:`mjtObj` type and id, returns ``NULL`` if name not found.
|
||||
|
||||
.. _mj_geomDistance:
|
||||
|
||||
Returns the smallest signed distance between two geoms and optionally the segment from ``geom1`` to ``geom2``.
|
||||
Returned distances are bounded from above by ``distmax``. |br| If no collision of distance smaller than ``distmax`` is
|
||||
found, the function will return ``distmax`` and ``fromto``, if given, will be set to (0, 0, 0, 0, 0, 0).
|
||||
|
||||
*Nullable:* ``fromto``
|
||||
|
||||
.. admonition:: different (correct) behavior under `nativeccd`
|
||||
:class: note
|
||||
|
||||
As explained in :ref:`Collision Detection<coDistance>`, distances are inaccurate when using the
|
||||
:ref:`legacy CCD pipeline<coCCD>`, and its use is discouraged.
|
||||
|
||||
.. _mj_mulM:
|
||||
|
||||
This function multiplies the joint-space inertia matrix stored in ``mjData.M`` by a vector.
|
||||
|
||||
.. _mj_applyFT:
|
||||
|
||||
This function can be used to apply a Cartesian force and torque to a point on a body, and add the result to the vector
|
||||
mjData.qfrc_applied of all applied forces. Note that the function requires a pointer to this vector, because sometimes
|
||||
we want to add the result to a different vector.
|
||||
|
||||
.. _mj_objectAcceleration:
|
||||
|
||||
Compute object 6D acceleration (rot:lin) in object-centered frame, world/local orientation. If acceleration or force
|
||||
sensors are not present in the model, :ref:`mj_rnePostConstraint` must be manually called in order to calculate
|
||||
mjData.cacc -- the total body acceleration, including contributions from the constraint solver.
|
||||
|
||||
.. _mj_differentiatePos:
|
||||
|
||||
This function subtracts two vectors in the format of qpos (and divides the result by dt), while respecting the
|
||||
properties of quaternions. Recall that unit quaternions represent spatial orientations. They are points on the unit
|
||||
sphere in 4D. The tangent to that sphere is a 3D plane of rotational velocities. Thus when we subtract two quaternions
|
||||
in the right way, the result is a 3D vector and not a 4D vector. Thus the output qvel has dimensionality nv while the
|
||||
inputs have dimensionality nq.
|
||||
|
||||
.. _mj_integratePos:
|
||||
|
||||
This is the opposite of mj_differentiatePos. It adds a vector in the format of qvel (scaled by dt) to a vector in the
|
||||
format of qpos.
|
||||
|
||||
.. _Raycollisions:
|
||||
|
||||
Ray collisions, also known as ray casting, find the distance ``x`` of a ray's intersection with a geom, where a ray is
|
||||
a line emanating from the 3D point ``p`` in the direction ``v`` i.e., ``(p + x*v, x >= 0)``. All functions in this
|
||||
family return the distance to the nearest geom surface, or -1 if there is no intersection. Note that if ``p`` is inside
|
||||
a geom, the ray will intersect the surface from the inside which still counts as an intersection.
|
||||
|
||||
All ray collision functions rely on quantities computed by :ref:`mj_kinematics` (see :ref:`mjData`), so must be called
|
||||
after :ref:`mj_kinematics`, or functions that call it (e.g. :ref:`mj_fwdPosition`). The top level functions, which
|
||||
intersect with all geoms types, are :ref:`mj_ray` which casts a single ray, and :ref:`mj_multiRay` which casts multiple
|
||||
rays from a single point.
|
||||
|
||||
.. _mj_ray:
|
||||
|
||||
Intersect ray ``pnt+x*vec, x >= 0`` with geoms.
|
||||
|
||||
- Return distance ``x`` to nearest surface, or -1 if no intersection.
|
||||
- If ``geomid`` is not NULL, write the id of the intersected geom or -1 if not intersection.
|
||||
- If ``normal`` is not NULL, write the surface normal at the intersection point. The normal always points **out of the
|
||||
geometry**, regardless of the ray's direction (i.e., including rays hitting the surface from the inside).
|
||||
- Exclude geoms in body with id ``bodyexclude``, use -1 to include all bodies.
|
||||
- ``geomgroup`` is an array of length :ref:`mjNGROUP<glNumericVisualization>`, where 1 means the group should be included. Pass
|
||||
NULL to skip geom group exclusion.
|
||||
- If ``flg_static`` is 0, static geoms will be excluded.
|
||||
|
||||
*Nullable:* ``geomgroup``, ``geomid``, ``normal``
|
||||
|
||||
.. _Interaction:
|
||||
|
||||
These functions implement abstract mouse interactions, allowing control over cameras and perturbations. Their use is well
|
||||
illustrated in :ref:`simulate<saSimulate>`.
|
||||
|
||||
.. _mjv_select:
|
||||
|
||||
This function is used for mouse selection, relying on ray intersections. aspectratio is the viewport width/height. relx
|
||||
and rely are the relative coordinates of the 2D point of interest in the viewport (usually mouse cursor). The function
|
||||
returns the id of the geom under the specified 2D point, or -1 if there is no geom (note that they skybox if present is
|
||||
not a model geom). The 3D coordinates of the clicked point are returned in selpnt. See :ref:`simulate<saSimulate>` for
|
||||
an illustration.
|
||||
|
||||
.. _Visualization-api:
|
||||
|
||||
The functions in this section implement abstract visualization. The results are used by the OpenGL renderer, and can
|
||||
also be used by users wishing to implement their own renderer, or hook up MuJoCo to advanced rendering tools such as
|
||||
Unity or Unreal Engine. See :ref:`simulate<saSimulate>` for illustration of how to use these functions.
|
||||
|
||||
.. _FilamentRenderingApi:
|
||||
|
||||
Rendering functions using the Filament rendering engine. These functions are prefixed with ``mjrf``. See
|
||||
:ref:`Filament Rendering<tyFilamentRenderStructure>` for an overview of the core types and their uses.
|
||||
|
||||
.. _OpenGLrendering:
|
||||
|
||||
These functions expose the OpenGL renderer. See :ref:`simulate<saSimulate>` for an illustration
|
||||
of how to use these functions.
|
||||
|
||||
.. _UIframework:
|
||||
|
||||
For a high-level description of the UI framework, see :ref:`UI`.
|
||||
|
||||
.. _mjui_add:
|
||||
|
||||
This is the helper function used to construct a UI. The second argument points to an array of :ref:`mjuiDef` structs,
|
||||
each corresponding to one item. The last (unused) item has its type set to -1, to mark termination. The items are added
|
||||
after the end of the last used section. There is also another version of this function
|
||||
(:ref:`mjui_addToSection<mjui_addToSection>`) which adds items to a specified section instead of adding them at the end
|
||||
of the UI. Keep in mind that there is a maximum preallocated number of sections and items per section, given by
|
||||
:ref:`mjMAXUISECT<glNumericUI>` and :ref:`mjMAXUIITEM<glNumericUI>`. Exceeding these maxima results in low-level errors.
|
||||
|
||||
.. _mjui_update:
|
||||
|
||||
This is the main UI update function. It needs to be called whenever the user data (pointed to by the item data pointers)
|
||||
changes, or when the UI state itself changes. It is normally called by a higher-level function implemented by the user
|
||||
(``UiModify`` in :ref:`simulate.cc <saSimulate>`) which also recomputes the layout of all rectangles and associated
|
||||
auxiliary buffers. The function updates the pixels in the offscreen OpenGL buffer. To perform minimal updates, the user
|
||||
specifies the section and the item that was modified. A value of -1 means all items and/or sections need to be updated
|
||||
(which is needed following major changes.)
|
||||
|
||||
.. _mjui_event:
|
||||
|
||||
This function is the low-level event handler. It makes the necessary changes in the UI and returns a pointer to the item
|
||||
that received the event (or ``NULL`` if no valid event was recorded). This is normally called within the event handler
|
||||
implemented by the user (``UiEvent`` in :ref:`simulate.cc <saSimulate>`), and then some action is taken by user code
|
||||
depending on which UI item was modified and what the state of that item is after the event is handled.
|
||||
|
||||
|
||||
.. _mjui_render:
|
||||
|
||||
This function is called in the screen refresh loop. It copies the offscreen OpenGL buffer to the window framebuffer. If
|
||||
there are multiple UIs in the application, it should be called once for each UI. Thus ``mjui_render`` is called all the
|
||||
time, while :ref:`mjui_update` is called only when changes in the UI take place. dsffsdg
|
||||
|
||||
|
||||
|
||||
|
||||
.. _Errorandmemory:
|
||||
|
||||
.. _mju_error:
|
||||
|
||||
Main error function. The error message is dispatched to the active log handler (see :ref:`mju_setLogHandler`).
|
||||
Errors are always fatal: if the handler returns, the process is terminated with ``exit(EXIT_FAILURE)``. Handlers
|
||||
wishing to recover must ``longjmp`` or otherwise transfer control before returning.
|
||||
|
||||
.. _mju_warning:
|
||||
|
||||
Main warning function; returns to caller. The warning message is dispatched to the active log handler.
|
||||
|
||||
.. _mju_clearHandlers:
|
||||
|
||||
Clear all user handlers and restore defaults. Resets the legacy error/warning/memory callbacks to ``NULL``, restores
|
||||
the default log handler, and resets the log configuration to its defaults (console and file output enabled, all info
|
||||
topics disabled).
|
||||
|
||||
.. _mju_setLogHandler:
|
||||
|
||||
Set the active global log handler. Returns the previous handler (which is never ``NULL``), intended for save/restore
|
||||
or callback chaining. If ``handler`` is ``NULL``, the default handler is restored. The handler receives all errors,
|
||||
warnings and informational messages as a structured :ref:`mjLogMessage`. See :ref:`siLogHandler` for usage examples.
|
||||
|
||||
.. _mju_getLogConfig:
|
||||
|
||||
Get the current default handler configuration. See :ref:`mjLogConfig`.
|
||||
|
||||
.. _mju_setLogConfig:
|
||||
|
||||
Set the default handler configuration. Controls console output, file output, and info topic filtering.
|
||||
See :ref:`mjLogConfig`.
|
||||
|
||||
Example usage (disabling file output):
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
mjLogConfig config = mju_getLogConfig();
|
||||
config.logto_file = false;
|
||||
mju_setLogConfig(config);
|
||||
|
||||
.. _mju_info:
|
||||
|
||||
Log an informational message with optional topic filtering. The ``topic`` argument is a :ref:`mjtLogTopic` value.
|
||||
Topic 0 (``mjTOPIC_NONE``) always passes through. Other topics must be enabled in the default handler configuration
|
||||
via :ref:`mju_setLogConfig`. Note that topic filtering is implemented in the default handler; custom handlers
|
||||
receive all info messages regardless.
|
||||
|
||||
.. _mju_message:
|
||||
|
||||
Dispatch a structured :ref:`mjLogMessage` to the active log handler. This is the primary entry point for emitting
|
||||
log messages with full control over all fields. The convenience functions :ref:`mju_error`, :ref:`mju_warning`, and
|
||||
:ref:`mju_info` are thin wrappers that populate an ``mjLogMessage`` and call this function.
|
||||
|
||||
The ``subject`` field is a one-line summary (up to 1024 bytes, inline in the struct). The ``body`` field is an
|
||||
optional ``const char*`` pointer to multi-line detail text, owned by the caller. When ``body`` is ``NULL``, only the
|
||||
subject line is printed.
|
||||
|
||||
The default handler formats the output as follows:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
LEVEL FUNC (FILE:LINE) TIME: SUBJECT
|
||||
BODY
|
||||
|
||||
where:
|
||||
|
||||
- ``LEVEL`` is ``ERROR``, ``WARNING``, ``INFO``, or ``DEBUG``.
|
||||
- ``FUNC`` is present when the ``func`` field is set.
|
||||
- ``(FILE:LINE)`` is present when the ``file`` and ``line`` fields are set.
|
||||
- ``TIME`` is present when the ``timestamp`` field is set or file logging is active.
|
||||
- ``SUBJECT`` is the contents of the ``subject`` field.
|
||||
- ``BODY`` follows on the next line(s), printed raw without indentation or separators, only if non-NULL.
|
||||
|
||||
The default handler appends a trailing blank line after ``ERROR``, ``WARNING``, and ``INFO`` messages for visual
|
||||
separation. ``DEBUG`` messages are printed compactly without a trailing blank line.
|
||||
|
||||
Example usage:
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
mjLogMessage msg = {
|
||||
.level = mjLOG_INFO,
|
||||
.timestamp = true,
|
||||
.body = " height: 0.001 m\n velocity: 0.000 m/s\n bounces: 47",
|
||||
};
|
||||
snprintf(msg.subject, sizeof(msg.subject), "The ball has come to rest");
|
||||
mju_message(&msg);
|
||||
|
||||
This produces:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
INFO Mon Jun 9 15:04:05 2026: The ball has come to rest
|
||||
height: 0.001 m
|
||||
velocity: 0.000 m/s
|
||||
bounces: 47
|
||||
|
||||
.. _Standardmath:
|
||||
|
||||
The "functions" in this section are preprocessor macros replaced with the corresponding C standard library math
|
||||
functions. When MuJoCo is compiled with single precision (which is not currently available to the public, but we
|
||||
sometimes use it internally) these macros are replaced with the corresponding single-precision functions (not shown
|
||||
here). So one can think of them as having inputs and outputs of type mjtNum, where mjtNum is defined as double or float
|
||||
depending on how MuJoCo is compiled. We will not document these functions here; see the C standard library
|
||||
specification.
|
||||
|
||||
mju_sqrt
|
||||
~~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_sqrt sqrt
|
||||
|
||||
mju_exp
|
||||
~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_exp exp
|
||||
|
||||
mju_sin
|
||||
~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_sin sin
|
||||
|
||||
mju_cos
|
||||
~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_cos cos
|
||||
|
||||
mju_tan
|
||||
~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_tan tan
|
||||
|
||||
mju_asin
|
||||
~~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_asin asin
|
||||
|
||||
mju_acos
|
||||
~~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_acos acos
|
||||
|
||||
mju_atan2
|
||||
~~~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_atan2 atan2
|
||||
|
||||
mju_tanh
|
||||
~~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_tanh tanh
|
||||
|
||||
mju_pow
|
||||
~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_pow pow
|
||||
|
||||
mju_abs
|
||||
~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_abs fabs
|
||||
|
||||
mju_log
|
||||
~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_log log
|
||||
|
||||
mju_log10
|
||||
~~~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_log10 log10
|
||||
|
||||
mju_floor
|
||||
~~~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_floor floor
|
||||
|
||||
mju_ceil
|
||||
~~~~~~~~
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
#define mju_ceil ceil
|
||||
|
||||
.. _Vectormath:
|
||||
|
||||
.. _Quaternions:
|
||||
|
||||
.. _Poses:
|
||||
|
||||
.. _Decompositions:
|
||||
|
||||
.. _mju_cholFactorBand:
|
||||
|
||||
Band-dense Cholesky decomposition.
|
||||
|br| Add ``diagadd + diagmul*mat_ii`` to diagonal before decomposition.
|
||||
|br| Returns the minimum value of the factorized diagonal or 0 if rank-deficient.
|
||||
|
||||
**Symmetric band-dense matrices**
|
||||
|
||||
:ref:`mju_cholFactorBand` and subsequent functions containing the substring "band" operate on matrices which are a
|
||||
generalization of symmetric `band matrices <https://en.wikipedia.org/wiki/Band_matrix>`_. *Symmetric band-dense* or
|
||||
"arrowhead" matrices have non-zeros along proximal diagonal bands and dense blocks on the bottom rows and right
|
||||
columns. These matrices have the property that Cholesky factorization creates no fill-in and can therefore be
|
||||
performed efficiently in-place. Matrix structure is defined by three integers:
|
||||
|
||||
- ``ntotal``: the number of rows (columns) of the symmetric matrix.
|
||||
- ``nband``: the number of bands under (over) the diagonal, inclusive of the diagonal.
|
||||
- ``ndense``: the number of dense rows (columns) at the bottom (right).
|
||||
|
||||
The non-zeros are stored in memory as two contiguous row-major blocks, colored green and blue in the illustration
|
||||
below. The first block has size ``nband x (ntotal-ndense)`` and contains the diagonal and the bands below it. The
|
||||
second block has size ``ndense x ntotal`` and contains the dense part. Total required memory is the sum of the block
|
||||
sizes.
|
||||
|
||||
.. figure:: /images/APIreference/arrowhead.svg
|
||||
:width: 750px
|
||||
:align: left
|
||||
|
||||
For example, consider an arrowhead matrix with ``nband = 3``, ``ndense = 2`` and ``ntotal = 8``. In this example, the
|
||||
total memory required is ``3*(8-2) + 2*8 = 34`` mjtNum's, laid out as follows:
|
||||
|
||||
.. code-block::
|
||||
|
||||
0 1 2
|
||||
3 4 5
|
||||
6 7 8
|
||||
9 10 11
|
||||
12 13 14
|
||||
15 16 17
|
||||
18 19 20 21 22 23 24 25
|
||||
26 27 28 29 30 31 32 33
|
||||
|
||||
|
||||
The diagonal elements are ``2, 5, 8, 11, 14, 17, 24, 33``.
|
||||
|br| Elements ``0, 1, 3, 25`` are present in memory but never touched.
|
||||
|
||||
.. _mju_boxQP:
|
||||
|
||||
Minimize :math:`\tfrac{1}{2} x^T H x + x^T g \quad \text{s.t.} \quad l \le x \le u`, return rank or -1 if failed.
|
||||
|
||||
inputs:
|
||||
``n`` - problem dimension
|
||||
|
||||
``H`` - SPD matrix ``n*n``
|
||||
|
||||
``g`` - bias vector ``n``
|
||||
|
||||
``lower`` - lower bounds ``n``
|
||||
|
||||
``upper`` - upper bounds ``n``
|
||||
|
||||
``res`` - solution warmstart ``n``
|
||||
|
||||
return value:
|
||||
``nfree <= n`` - rank of unconstrained subspace, -1 if failure
|
||||
|
||||
outputs (required):
|
||||
``res`` - solution ``n``
|
||||
|
||||
``R`` - subspace Cholesky factor ``nfree*nfree``, allocated: ``n*(n+7)``
|
||||
|
||||
outputs (optional):
|
||||
``index`` - set of free dimensions ``nfree``, allocated: ``n``
|
||||
|
||||
notes:
|
||||
The initial value of ``res`` is used to warmstart the solver.
|
||||
``R`` must have allocated size ``n*(n+7)``, but only ``nfree*nfree`` values are used as output.
|
||||
``index`` (if given) must have allocated size ``n``, but only ``nfree`` values are used as output.
|
||||
The convenience function :ref:`mju_boxQPmalloc` allocates the required data structures.
|
||||
Only the lower triangles of H and R are read from and written to, respectively.
|
||||
|
||||
.. _mju_boxQPmalloc:
|
||||
|
||||
Allocate heap memory for box-constrained Quadratic Program.
|
||||
As in :ref:`mju_boxQP`, ``index``, ``lower``, and ``upper`` are optional.
|
||||
Free all pointers with ``mju_free()``.
|
||||
|
||||
.. _mju_symmetrize:
|
||||
|
||||
Symmetrize square matrix :math:`R = \frac{1}{2}(M + M^T)`.
|
||||
|
||||
.. _Miscellaneous:
|
||||
|
||||
.. _mju_sigmoid:
|
||||
|
||||
Twice continuously differentiable sigmoid function using a quintic polynomial:
|
||||
|
||||
.. math::
|
||||
s(x) =
|
||||
\begin{cases}
|
||||
0, & & x \le 0 \\
|
||||
6x^5 - 15x^4 + 10x^3, & 0 \lt & x \lt 1 \\
|
||||
1, & 1 \le & x \qquad
|
||||
\end{cases}
|
||||
|
||||
.. _Derivatives-api:
|
||||
|
||||
The functions below provide useful derivatives of various functions, both analytic and
|
||||
finite-differenced. The latter have names with the suffix ``FD``. Note that unlike much of the API,
|
||||
outputs of derivative functions are the trailing rather than leading arguments.
|
||||
|
||||
.. _mjd_transitionFD:
|
||||
|
||||
Compute finite-differenced discrete-time transition matrices.
|
||||
|
||||
Letting :math:`x, u` denote the current :ref:`state<siPhysicsState>` and :ref:`control<siInput>`
|
||||
vector in an mjData instance, and letting :math:`y, s` denote the next state and sensor
|
||||
values, the top-level :ref:`mj_step` function computes :math:`(x,u) \rightarrow (y,s)`
|
||||
:ref:`mjd_transitionFD` computes the four associated Jacobians using finite-differencing.
|
||||
These matrices and their dimensions are:
|
||||
|
||||
.. csv-table::
|
||||
:header: "matrix", "Jacobian", "dimension"
|
||||
:widths: auto
|
||||
:align: left
|
||||
|
||||
``A``, :math:`\partial y / \partial x`, ``2*nv+na x 2*nv+na``
|
||||
``B``, :math:`\partial y / \partial u`, ``2*nv+na x nu``
|
||||
``C``, :math:`\partial s / \partial x`, ``nsensordata x 2*nv+na``
|
||||
``D``, :math:`\partial s / \partial u`, ``nsensordata x nu``
|
||||
|
||||
- All outputs are optional (can be NULL).
|
||||
- ``eps`` is the finite-differencing epsilon.
|
||||
- ``flg_centered`` denotes whether to use forward (0) or centered (1) differences.
|
||||
- The Runge-Kutta integrator (:ref:`mjINT_RK4<mjtIntegrator>`) is not supported.
|
||||
|
||||
.. admonition:: Improving speed and accuracy
|
||||
:class: tip
|
||||
|
||||
warmstart
|
||||
If warm-starts are not :ref:`disabled<option-flag-warmstart>`, the warm-start accelerations
|
||||
``mjData.qacc_warmstart`` which are present at call-time are loaded at the start of every relevant pipeline call,
|
||||
to preserve determinism. If solver computations are an expensive part of the simulation, the following trick can
|
||||
lead to significant speed-ups: First call :ref:`mj_forward` to let the solver converge, then reduce :ref:`solver
|
||||
iterations<option-iterations>` significantly, then call :ref:`mjd_transitionFD`, finally, restore the original
|
||||
value of :ref:`iterations<option-iterations>`. Because we are already near the solution, few iteration are required
|
||||
to find the new minimum. This is especially true for the :ref:`Newton<option-solver>` solver, where the required
|
||||
number of iteration for convergence near the minimum can be as low as 1.
|
||||
|
||||
tolerance
|
||||
Accuracy can be improved if solver :ref:`tolerance<option-tolerance>` is set to 0. This means that all calls to
|
||||
the solver will perform exactly the same number of iterations, preventing numerical errors due to early
|
||||
termination. Of course, this means that :ref:`solver iterations<option-iterations>` should be small, to not tread
|
||||
water at the minimum. This method and the one described above can and should be combined.
|
||||
|
||||
*Nullable:* ``A``, ``B``, ``D``, ``C``
|
||||
|
||||
.. _mjd_inverseFD:
|
||||
|
||||
Finite differenced continuous-time inverse-dynamics Jacobians.
|
||||
|
||||
Letting :math:`x, a` denote the current :ref:`state<siPhysicsState>` and acceleration vectors in an mjData instance, and
|
||||
letting :math:`f, s` denote the forces computed by the inverse dynamics (``qfrc_inverse``), the function
|
||||
:ref:`mj_inverse` computes :math:`(x,a) \rightarrow (f,s)`. :ref:`mjd_inverseFD` computes seven associated Jacobians
|
||||
using finite-differencing. These matrices and their dimensions are:
|
||||
|
||||
.. csv-table::
|
||||
:header: "matrix", "Jacobian", "dimension"
|
||||
:widths: auto
|
||||
:align: left
|
||||
|
||||
``DfDq``, :math:`\partial f / \partial q`, ``nv x nv``
|
||||
``DfDv``, :math:`\partial f / \partial v`, ``nv x nv``
|
||||
``DfDa``, :math:`\partial f / \partial a`, ``nv x nv``
|
||||
``DsDq``, :math:`\partial s / \partial q`, ``nv x nsensordata``
|
||||
``DsDv``, :math:`\partial s / \partial v`, ``nv x nsensordata``
|
||||
``DsDa``, :math:`\partial s / \partial a`, ``nv x nsensordata``
|
||||
``DmDq``, :math:`\partial M / \partial q`, ``nv x nC``
|
||||
|
||||
- All outputs are optional (can be NULL).
|
||||
- All outputs are transposed relative to Control Theory convention (i.e., column major).
|
||||
- ``DmDq``, which contains a sparse representation of the ``nv x nv x nv`` tensor :math:`\partial M / \partial q`, is
|
||||
not strictly an inverse dynamics Jacobian but is useful in related applications. It is provided as a convenience to
|
||||
the user, since the required values are already computed if either of the other two :math:`\partial / \partial q`
|
||||
Jacobians are requested.
|
||||
- ``eps`` is the (forward) finite-differencing epsilon.
|
||||
- ``flg_actuation`` denotes whether to subtract actuation forces (``qfrc_actuator``) from the output of the inverse
|
||||
dynamics. If this flag is positive, actuator forces are not considered as external.
|
||||
- The model option flag ``invdiscrete`` should correspond to the representation of ``mjData.qacc`` in order to compute
|
||||
the correct derivative information.
|
||||
|
||||
.. attention::
|
||||
- The Runge-Kutta 4th-order integrator (``mjINT_RK4``) is not supported.
|
||||
- The noslip solver is not supported.
|
||||
|
||||
*Nullable:* ``DfDq``, ``DfDv``, ``DfDa``, ``DsDq``, ``DsDv``, ``DsDa``, ``DmDq``
|
||||
|
||||
.. _mjd_subQuat:
|
||||
|
||||
Derivatives of :ref:`mju_subQuat` (quaternion difference).
|
||||
|
||||
*Nullable:* ``Da``, ``Db``
|
||||
|
||||
.. _mjd_quatIntegrate:
|
||||
|
||||
Derivatives of :ref:`mju_quatIntegrate`.
|
||||
|
||||
:math:`{\tt \small mju\_quatIntegrate}(q, v, h)` performs the in-place rotation :math:`q \leftarrow q + v h`,
|
||||
where :math:`q \in \mathbf{S}^3` is a unit quaternion, :math:`v \in \mathbf{R}^3` is a 3D angular velocity and
|
||||
:math:`h \in \mathbf{R^+}` is a timestep. This is equivalent to :math:`{\tt \small mju\_quatIntegrate}(q, s, 1.0)`,
|
||||
where :math:`s` is the scaled velocity :math:`s = h v`.
|
||||
|
||||
:math:`{\tt \small mjd\_quatIntegrate}(v, h, D_q, D_v, D_h)` computes the Jacobians of the output :math:`q` with respect
|
||||
to the inputs. Below, :math:`\bar q` denotes the pre-modified quaternion:
|
||||
|
||||
.. math::
|
||||
\begin{aligned}
|
||||
D_q &= \partial q / \partial \bar q \\
|
||||
D_v &= \partial q / \partial v \\
|
||||
D_h &= \partial q / \partial h
|
||||
\end{aligned}
|
||||
|
||||
Note that derivatives depend only on :math:`h` and :math:`v` (in fact, on :math:`s = h v`).
|
||||
All outputs are optional.
|
||||
|
||||
*Nullable:* ``Dquat``, ``Dvel``, ``Dscale``
|
||||
|
||||
.. _Resources:
|
||||
|
||||
Resources are the interface between :ref:`resource providers <exProvider>` and MuJoCo model compilation code.
|
||||
These functions provide the means to query the resource provider and obtain resources.
|
||||
@@ -1,20 +0,0 @@
|
||||
.. _APIreference:
|
||||
|
||||
=============
|
||||
API Reference
|
||||
=============
|
||||
|
||||
This chapter is the reference manual for the MuJoCo API. It is automatically kept in sync with MuJoCo's header files,
|
||||
but also contains additional information not available in the headers. The API is composed of 3 categories:
|
||||
|
||||
.. table::
|
||||
:class: aligntop
|
||||
|
||||
+--------------------+--------------------+--------------------+
|
||||
| | | |
|
||||
| .. toctree:: | .. toctree:: | .. toctree:: |
|
||||
| :maxdepth: 3 | :maxdepth: 2 | :maxdepth: 2 |
|
||||
| | | |
|
||||
| APItypes | APIfunctions | APIglobals |
|
||||
| | | |
|
||||
+--------------------+--------------------+--------------------+
|
||||
@@ -1,19 +0,0 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
.PHONY: Makefile
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
@@ -1,63 +0,0 @@
|
||||
Building
|
||||
========
|
||||
|
||||
.. WARNING:: OpenUSD support is currently experimental and subject to frequent change.
|
||||
|
||||
MuJoCo must be built against a pre-built USD library, we provide a utility to do so but you may also bring your own USD
|
||||
libraries.
|
||||
|
||||
The following instructions assume that you have cloned MuJoCo into ``~/mujoco`` and have a build directory at
|
||||
``~/mujoco/build``.
|
||||
|
||||
.. _usdBuildingUSD:
|
||||
|
||||
Building USD
|
||||
------------
|
||||
|
||||
If you have a pre-built USD library, you can skip this section.
|
||||
|
||||
MuJoCo provides a CMake project that simplifies the process of building USD. It will download and build USD with only
|
||||
the necessary features enabled.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd ~/mujoco
|
||||
cmake -Bcmake/third_party_deps/openusd/build cmake/third_party_deps/openusd
|
||||
cmake --build cmake/third_party_deps/openusd/build
|
||||
|
||||
If you want to customize the build process, you can use USD's ``build_usd.py`` script. It's recommended to use a
|
||||
separate installation directory that exists outside of the cloned repository directory.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://github.com/PixarAnimationStudios/OpenUSD
|
||||
python OpenUSD/build_scripts/build_usd.py /path/to/my_usd_install_dir
|
||||
|
||||
.. _usdEnablingUSD:
|
||||
|
||||
Enabling USD
|
||||
------------
|
||||
|
||||
If USD was built with the third_party_deps/openusd CMake project, you can enable USD support with the MUJOCO_WITH_USD
|
||||
flag.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd ~/mujoco
|
||||
cmake -Bbuild -S. -DMUJOCO_WITH_USD=True
|
||||
cmake --build build -j 64
|
||||
|
||||
Otherwise, if you have a pre-built USD library, you must also pass the pxr_DIR flag.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd ~/mujoco
|
||||
cmake -Bbuild -S. -DMUJOCO_WITH_USD=True -Dpxr_DIR=/path/to/my_usd_install_dir
|
||||
cmake --build build -j 64
|
||||
|
||||
|
||||
If we now run :ref:`simulate.cc <saSimulate>`, we will be able to drag and drop USD files.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
simulate
|
||||
@@ -1,26 +0,0 @@
|
||||
Exporting
|
||||
=========
|
||||
|
||||
.. WARNING:: OpenUSD support is currently experimental and subject to frequent change.
|
||||
|
||||
Currently, exporting MuJoCo scenes to OpenUSD format is an area of active development. The primary method for exporting
|
||||
is expected to be through the Python API.
|
||||
|
||||
USDExporter
|
||||
-----------
|
||||
|
||||
At the moment the only way to export USD from MuJoCo is to use the existing USDExporter in :doc:`../python`.
|
||||
|
||||
We are working on native support for writing simulations as animations to existing USD scenes, please check back here
|
||||
for updates.
|
||||
|
||||
mujoco-usd-converter
|
||||
--------------------
|
||||
|
||||
To convert existing MJCF assets to USD following strong authoring guidelines we recommend the `Newton
|
||||
mujoco-usd-converter <https://github.com/newton-physics/mujoco-usd-converter>`__. These assets will have no reference to
|
||||
the original MJCF assets but will use the :doc:`mjcPhysics <mjcPhysics>` schemas to enable faithful representation of
|
||||
the source assets.
|
||||
|
||||
When opened, these assets should be similar to the ones generated by the :doc:`MJCF file format plugin
|
||||
<mjcf_file_format_plugin>`, but there will not be any runtime overhead from converting MJCF to USD.
|
||||
@@ -1,29 +0,0 @@
|
||||
Importing
|
||||
=========
|
||||
|
||||
.. WARNING:: OpenUSD support is currently experimental and subject to frequent change.
|
||||
|
||||
MuJoCo can load assets from OpenUSD files (``.usd``, ``.usda``, ``.usdc``, ``.usdz``). This allows you to incorporate
|
||||
assets and scenes defined in USD into your MuJoCo simulations.
|
||||
|
||||
USD in MJCF
|
||||
-----------------------------
|
||||
|
||||
If you have built mujoco with USD enabled, you can reference USD assets from MJCF via the ``<model`` tag with content
|
||||
type ``text/usd``.
|
||||
|
||||
.. code-block:: xml
|
||||
:caption: example.xml
|
||||
|
||||
<mujoco>
|
||||
<asset>
|
||||
<model file="chair.usdz" name="chair" content_type="text/usd"/>
|
||||
</asset>
|
||||
|
||||
<worldbody>
|
||||
...
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
|
||||
In this example the ``<model file="chair.usdz"/>`` line in ``<asset>`` tells MuJoCo to load and process the USD file.
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
OpenUSD
|
||||
===========
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
building
|
||||
mjcPhysics
|
||||
mjcf_file_format_plugin
|
||||
importing
|
||||
exporting
|
||||
|
||||
.. WARNING:: OpenUSD support is currently experimental and subject to frequent change.
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
This chapter describes MuJoCo's support for `OpenUSD <https://openusd.org/release/intro.html>`__. USD (Universal Scene
|
||||
Description) is an open-source framework developed by Pixar for describing 3D scenes. MuJoCo's integration allows users
|
||||
to leverage USD's rich ecosystem and tooling.
|
||||
|
||||
What is OpenUSD?
|
||||
----------------
|
||||
|
||||
USD is a high-performance, extensible system for describing, composing, simulating, and collaborating on 3D data.
|
||||
Originally developed by Pixar Animation Studios, USD is now used across various industries, including visual effects,
|
||||
animation, gaming, and robotics, to streamline complex 3D workflows. It provides a common language for different
|
||||
software applications to exchange 3D scene information.
|
||||
|
||||
Why do we care about OpenUSD?
|
||||
-----------------------------
|
||||
|
||||
Integrating USD with MuJoCo offers several advantages:
|
||||
|
||||
* **Interoperability:** USD is supported by a wide range of 3D content creation tools (e.g., Houdini, Maya, Blender).
|
||||
This allows MuJoCo users to easily import scenes and assets created in these tools.
|
||||
* **Rich Scene Description:** USD provides a powerful and flexible way to represent complex scenes, including
|
||||
geometry, materials, lighting, and hierarchies.
|
||||
* **Collaboration:** USD's layering and composition features enable powerful and efficient
|
||||
non-destructive authoring pipelines.
|
||||
|
||||
USD support overview
|
||||
------------------------------------------------------
|
||||
|
||||
* **Import:** You can load USD assets (specifically ``.usd``, ``.usda``, ``.usdc``, ``.usdz`` files) into MuJoCo via
|
||||
MJCF or dragging and dropping into :ref:`simulate.cc <saSimulate>`.
|
||||
* **Schemas:** MuJoCo primarily uses the standard `UsdPhysics
|
||||
<https://openusd.org/dev/api/usd_physics_page_front.html>`__ schemas for representing physics properties.
|
||||
* **Extensions:** Custom :doc:`mjcPhysics` schemas are provided to cover MuJoCo-specific features not available in
|
||||
``UsdPhysics``.
|
||||
* **MJCF File Format Plugin:** A :doc:`mjcf_file_format_plugin` allows treating MJCF files as USD layers in any native USD
|
||||
application.
|
||||
* **Export:** MuJoCo scenes can be exported to USD.
|
||||
|
||||
Where do I learn more about USD?
|
||||
------------------------------------------
|
||||
|
||||
* `Remedy's Book of USD <https://remedy-entertainment.github.io/USDBook>`__: Friendly introduction to USD.
|
||||
* `Official OpenUSD Documentation <https://openusd.org/release/intro.html>`__: Official documentation for API and
|
||||
implementation details.
|
||||
* `Pixar's USD Introduction <https://graphics.pixar.com/usd/release/index.html>`__: Simple example usage of USD.
|
||||
* `NVIDIA's USD Resources <https://developer.nvidia.com/usd>`__: Set of USD resources primarily concerned with asset
|
||||
structure.
|
||||
@@ -1,107 +0,0 @@
|
||||
mjcPhysics
|
||||
==========
|
||||
|
||||
.. WARNING:: OpenUSD support is currently experimental and subject to frequent change.
|
||||
|
||||
The ``mjcPhysics`` `schema <https://openusd.org/release/api/_usd__page__generating_schemas.html>`__ allows for detailed
|
||||
specification of a MuJoCo simulation environment directly within a USD file. The aim is not to replace `UsdPhysics
|
||||
<https://openusd.org/release/api/usd_physics_page_front.html>`__, but to extend existing concepts and create new types
|
||||
only where is necessary.
|
||||
|
||||
The schema can be use `codeless <https://openusd.org/dev/api/_usd__page__generating_schemas.html#Codeless_Schemas>`__,
|
||||
or can be built with its C++ bindings. We've pre-generated `the code
|
||||
<https://github.com/google-deepmind/mujoco/tree/main/src/experimental/usd/mjcPhysics>`__ via `usdGenSchema
|
||||
<https://openusd.org/dev/api/_usd__page__generating_schemas.html>`_ for internal MuJoCo usage, but it should also work
|
||||
outside of MuJoCo.
|
||||
|
||||
API Schemas
|
||||
-----------
|
||||
|
||||
MjcSceneAPI
|
||||
^^^^^^^^^^^
|
||||
|
||||
This API schema provides global options for the MuJoCo simulation. It is an
|
||||
amalgamation of the ``<option>``, ``<option/flag>`` and ``<compiler>`` elements in
|
||||
MJCF. Users should apply this to an existing
|
||||
`UsdPhysicsScene <https://openusd.org/dev/api/class_usd_physics_scene.html>`__
|
||||
prim.
|
||||
|
||||
Key attributes include:
|
||||
|
||||
- **mjc:option**: Attributes in this namespace map to the ``<option>`` element.
|
||||
- **mjc:flag**: Attributes in this namespace map to the ``<option/flag>`` element.
|
||||
- **mjc:compiler**: Attributes in this namespace map to the ``<compiler>`` element.
|
||||
|
||||
MjcSiteAPI
|
||||
^^^^^^^^^^
|
||||
|
||||
This API class is used to define a MuJoCo site, it can be applied to
|
||||
`UsdGeomSphere <https://openusd.org/dev/api/class_usd_geom_sphere.html>`__,
|
||||
`UsdGeomCapsule <https://openusd.org/dev/api/class_usd_geom_capsule.html>`__,
|
||||
`UsdGeomCylinder <https://openusd.org/dev/api/class_usd_geom_cylinder.html>`__, and
|
||||
`UsdGeomCube <https://openusd.org/dev/api/class_usd_geom_cube.html>`__.
|
||||
|
||||
MjcImageableAPI
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
This API class provides attributes for strictly visual entities in MuJoCo, in
|
||||
MuJoCo terms we would quantify these has having ``contype = conaffinity = 0``.
|
||||
|
||||
MjcCollisionAPI
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
This API class is applied to prims that represent collision geometry and should
|
||||
be applied alongside
|
||||
`UsdPhysicsCollisionAPI <https://openusd.org/dev/api/class_usd_physics_collision_a_p_i.html>`__.
|
||||
|
||||
MjcMeshCollisionAPI
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This API class is applied to prims that represent mesh collision geometry and
|
||||
should be applied alongside
|
||||
`UsdPhysicsMeshCollisionAPI <https://openusd.org/dev/api/class_usd_physics_mesh_collision_a_p_i.html>`__.
|
||||
|
||||
MjcJointAPI
|
||||
^^^^^^^^^^^
|
||||
|
||||
This API class is applied to `UsdPhysicsJoint <https://openusd.org/dev/api/class_usd_physics_joint.html>`__ prims,
|
||||
adding extra attributes to fully describe MuJoCo joints.
|
||||
|
||||
MjcMaterialAPI
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
This API class provides attributes for physical materials and is an extension of `UsdPhysicsMaterialAPI
|
||||
<https://openusd.org/dev/api/class_usd_physics_material_a_p_i.html>`__
|
||||
|
||||
Type Schemas
|
||||
------------
|
||||
|
||||
MjcActuator
|
||||
^^^^^^^^^^^
|
||||
|
||||
This class represents a MuJoCo actuator, which is responsible for applying force to a transmission target joint, body,
|
||||
or site specific via a `relationship <https://openusd.org/dev/api/class_usd_relationship.html>`__.
|
||||
|
||||
We do not use the existing `UsdPhysicsDriveAPI <https://openusd.org/dev/api/class_usd_physics_drive_a_p_i.html>`__ as it
|
||||
is closer to a runtime construct and the concepts do not map very closely.
|
||||
|
||||
MjcKeyframe
|
||||
^^^^^^^^^^^
|
||||
|
||||
This type holds tensor values representing simulator state at specific time values.
|
||||
|
||||
In MJCF this is the ``<keyframe>`` element and has a ``time`` attribute. In USD we map the time attribute to
|
||||
`timeSamples <https://openusd.org/release/tut_xforms.html>`__ instead.
|
||||
|
||||
The order of the values in the keyframes should map to the depth first ordered traversal of rigidbodies in the composed
|
||||
stage.
|
||||
|
||||
MjcTendon
|
||||
^^^^^^^^^
|
||||
|
||||
This type represents both fixed and spatial tendons.
|
||||
|
||||
In MJCF this is the ``<tendon>`` element. The tendon path is represented by the ordered list of targets in the
|
||||
``mjc:path`` relationship attribute. In MJCF we can specify attributes such as ``sidesite`` and ``divisor`` on
|
||||
path targets; but in USD we cannot attach data to relationship attributes as elegantly, so these become indexed
|
||||
array attributes such as ``mjc:sideSites`` and ``mjs:path:divisors``.
|
||||
@@ -1,87 +0,0 @@
|
||||
File Format Plugin
|
||||
=========================
|
||||
|
||||
What is an SdfFileFormat plugin?
|
||||
--------------------------------
|
||||
|
||||
In the OpenUSD framework, ``Sdf`` stands for Scene Description Foundations. It's the underlying layer that handles the
|
||||
serialization and composition of scene data. A ``SdfFileFormat`` plugin is a component that teaches USD how to read and
|
||||
write a specific file format.
|
||||
|
||||
By default, USD comes with plugins for its own formats (``.usda``, ``.usdc``, ``.usdz``) and the community has created
|
||||
several plugin extension such as the `Adobe File Format Plugins
|
||||
<https://github.com/adobe/USD-Fileformat-plugins/tree/main>`__.
|
||||
|
||||
The MJCF ``SdfFileFormat`` plugin allows USD-aware applications to directly understand and interact with MuJoCo's native
|
||||
``.xml`` (MJCF) files as if they were native USD files.
|
||||
|
||||
What does it enable?
|
||||
------------------------
|
||||
|
||||
This plugin enables:
|
||||
|
||||
1. **Referencing MJCF files in USD:** Using standard USD composition arcs (like references, payloads) to include an
|
||||
MJCF file directly within a larger USD scene. For example, you can place a MuJoCo robot defined in an ``.xml`` file
|
||||
into a room scene modeled in USD.
|
||||
2. **Load MJCF files in USD tools:** Tools like ``usdview`` or other USD-based
|
||||
applications can open, inspect, and render MJCF files, translating the MJCF elements into USD prims and attributes
|
||||
on the fly.
|
||||
3. **Convert MJCF to USD:** The plugin can be used as a basis for converting MJCF files to persistent
|
||||
USD files (e.g., ``.usda`` or ``.usdc``).
|
||||
|
||||
Essentially, it makes MJCF a first-class citizen in the USD ecosystem.
|
||||
|
||||
Usage
|
||||
------------------
|
||||
|
||||
1. **Installation:** refer to :doc:`building`.
|
||||
|
||||
2. **Referencing in a USD file (e.g., ``.usda``):**
|
||||
|
||||
.. code-block:: usd
|
||||
:caption: example.usda
|
||||
|
||||
#usda 1.0
|
||||
(
|
||||
upAxis = "Z"
|
||||
)
|
||||
|
||||
def Xform "world"
|
||||
{
|
||||
def "robot" (
|
||||
prepend references = @./my_robot.xml@
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
In this example, ``my_robot.xml`` is an MJCF file in the same directory. USD will use the plugin to load and
|
||||
interpret its contents.
|
||||
|
||||
3. **Opening in usdview:**
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
usdview my_robot.xml
|
||||
|
||||
If the plugin is correctly set up, ``usdview`` will render the robot defined in the MJCF file.
|
||||
|
||||
4. **Using in Python (with USD API):**
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from pxr import Usd
|
||||
|
||||
# Load an MJCF file as a USD stage
|
||||
stage = Usd.Stage.Open('my_robot.xml')
|
||||
|
||||
if stage:
|
||||
print(f"Successfully opened {stage.GetRootLayer().identifier}")
|
||||
# You can now inspect the stage as any other USD stage
|
||||
for prim in stage.TraverseAll():
|
||||
print(prim.GetPath())
|
||||
else:
|
||||
print("Failed to open MJCF file")
|
||||
|
||||
This plugin significantly enhances the interoperability between MuJoCo and USD-based workflows, allowing
|
||||
seamless integration of physics assets defined in MJCF into broader 3D environments.
|
||||
@@ -1,145 +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
|
||||
%
|
||||
% 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.
|
||||
|
||||
|
||||
% Force-Length-Velocity function of MuJoCo muscle model
|
||||
% Defaults: FLV(0.5, 1.6, 1.5, 1.3, 1.2)
|
||||
|
||||
|
||||
function FLV(lmin, lmax, vmax, fpmax, fvmax)
|
||||
|
||||
% derived quantities
|
||||
a = 0.5*(lmin+1);
|
||||
b = 0.5*(1+lmax);
|
||||
c = fvmax-1;
|
||||
|
||||
% length and velocity ranges to plot
|
||||
LL = linspace(lmin, lmax, 51);
|
||||
VV = linspace(-vmax, vmax, 51);
|
||||
|
||||
% length-passive
|
||||
FP = zeros(size(LL));
|
||||
for i=1:length(LL)
|
||||
L = LL(i);
|
||||
|
||||
if L<=1
|
||||
FP(i) = 0;
|
||||
elseif L<=b
|
||||
x = (L-1)/(b-1);
|
||||
FP(i) = 0.25*fpmax*x*x*x;
|
||||
else
|
||||
x = (L-b)/(b-1);
|
||||
FP(i) = 0.25*fpmax*(1+3*x);
|
||||
end
|
||||
end
|
||||
|
||||
% length-active
|
||||
FL = zeros(size(LL));
|
||||
for i=1:length(LL)
|
||||
L = LL(i);
|
||||
|
||||
FL(i) = bump(L, lmin, 1, lmax) + 0.15*bump(L, lmin, 0.5*(lmin+0.95), 0.95);
|
||||
end
|
||||
|
||||
% velocity-active
|
||||
FV = zeros(size(VV));
|
||||
for i=1:length(VV)
|
||||
V = VV(i)/vmax;
|
||||
|
||||
if V<=-1
|
||||
FV(i) = 0;
|
||||
elseif V<=0
|
||||
FV(i) = (V+1)*(V+1);
|
||||
elseif V<=c
|
||||
FV(i) = fvmax - (c-V)*(c-V)/c;
|
||||
else
|
||||
FV(i) = fvmax;
|
||||
end
|
||||
end
|
||||
|
||||
% plot length
|
||||
figure(1);
|
||||
clf;
|
||||
subplot(2,2,1);
|
||||
plot(LL, FL, 'r', 'linewidth', 1);
|
||||
hold on;
|
||||
plot(LL, 0.5*FL, 'b', 'linewidth', 1);
|
||||
plot(LL, FP, 'k', 'linewidth', 1);
|
||||
axis tight;
|
||||
xlabel('length (L0)');
|
||||
ylabel('force (F0)');
|
||||
text(0.9, 0.85, 'act = 1.0');
|
||||
text(0.9, 0.4, 'act = 0.5');
|
||||
text(1.3, 1.2, 'passive');
|
||||
box off;
|
||||
grid on;
|
||||
set(gca, 'xtick', [lmin 1 lmax], 'xticklabel', {'lmin', '1', 'lmax'}, ...
|
||||
'ytick', [0 1 fpmax], 'yticklabel', {'0', '1', 'fpmax'});
|
||||
|
||||
% plot velocity
|
||||
subplot(2,2,2);
|
||||
set( plot(VV, FV, 'linewidth', 1), 'color', [.1 .5 .1]);
|
||||
axis tight;
|
||||
xlabel('velocity (L0/s)');
|
||||
ylabel('force (F0)');
|
||||
box off;
|
||||
grid on;
|
||||
set(gca, 'xtick', [-vmax 0 vmax], 'xticklabel', {'-vmax', '0', 'vmax'}, ...
|
||||
'ytick', [0 1 fvmax], 'yticklabel', {'0', '1', 'fvmax'});
|
||||
|
||||
% plot full activation
|
||||
subplot(2,2,3);
|
||||
surf(LL, VV, FV'*FL + ones(size(VV))'*FP);
|
||||
axis tight;
|
||||
xlabel('length');
|
||||
ylabel('velocity');
|
||||
zlabel('force');
|
||||
title('act = 1.0');
|
||||
box off;
|
||||
set(gca, 'xtick', [lmin, 1, lmax], 'ytick', [-vmax, 0, vmax], 'ztick', [0, 1]);
|
||||
|
||||
% plot half activation
|
||||
subplot(2,2,4);
|
||||
surf(LL, VV, 0.5*FV'*FL + ones(size(VV))'*FP);
|
||||
axis tight;
|
||||
xlabel('length');
|
||||
ylabel('velocity');
|
||||
zlabel('force');
|
||||
title('act = 0.5');
|
||||
box off;
|
||||
set(gca, 'xtick', [lmin, 1, lmax], 'ytick', [-vmax, 0, vmax], 'ztick', [0, 1]);
|
||||
end
|
||||
|
||||
|
||||
% skewed bump function: quadratic spline
|
||||
function y = bump(L, A, mid, B)
|
||||
left = 0.5*(A+mid);
|
||||
right = 0.5*(mid+B);
|
||||
|
||||
if (L<=A) || (L>=B)
|
||||
y = 0;
|
||||
elseif L<left
|
||||
x = (L-A)/(left-A);
|
||||
y = 0.5*x*x;
|
||||
elseif L<mid
|
||||
x = (mid-L)/(mid-left);
|
||||
y = 1-0.5*x*x;
|
||||
elseif L<right
|
||||
x = (L-mid)/(right-mid);
|
||||
y = 1-0.5*x*x;
|
||||
else
|
||||
x = (B-L)/(B-right);
|
||||
y = 0.5*x*x;
|
||||
end
|
||||
end
|
||||
|
Before Width: | Height: | Size: 1.8 MiB |
@@ -1,41 +0,0 @@
|
||||
<mujoco model="example">
|
||||
<default>
|
||||
<geom rgba=".8 .6 .4 1"/>
|
||||
</default>
|
||||
|
||||
<asset>
|
||||
<texture type="skybox" builtin="gradient" rgb1="1 1 1" rgb2=".6 .8 1" width="256" height="256"/>
|
||||
</asset>
|
||||
|
||||
<worldbody>
|
||||
<light pos="0 1 1" dir="0 -1 -1" diffuse="1 1 1"/>
|
||||
<body pos="0 0 1">
|
||||
<joint type="ball"/>
|
||||
<geom type="capsule" size="0.06" fromto="0 0 0 0 0 -.4"/>
|
||||
<body pos="0 0 -0.4">
|
||||
<joint axis="0 1 0"/>
|
||||
<joint axis="1 0 0"/>
|
||||
<geom type="capsule" size="0.04" fromto="0 0 0 .3 0 0"/>
|
||||
<body pos=".3 0 0">
|
||||
<joint axis="0 1 0"/>
|
||||
<joint axis="0 0 1"/>
|
||||
<geom pos=".1 0 0" size="0.1 0.08 0.02" type="ellipsoid"/>
|
||||
<site name="end1" pos="0.2 0 0" size="0.01"/>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
<body pos="0.3 0 0.1">
|
||||
<joint type="free"/>
|
||||
<geom size="0.07 0.1" type="cylinder"/>
|
||||
<site name="end2" pos="0 0 0.1" size="0.01"/>
|
||||
</body>
|
||||
</worldbody>
|
||||
|
||||
<tendon>
|
||||
<spatial limited="true" range="0 0.6" width="0.005">
|
||||
<site site="end1"/>
|
||||
<site site="end2"/>
|
||||
</spatial>
|
||||
</tendon>
|
||||
</mujoco>
|
||||
@@ -1,662 +0,0 @@
|
||||
MuJoCo version 2.3.3
|
||||
model name example
|
||||
|
||||
nq 15
|
||||
nv 13
|
||||
nbody 5
|
||||
nbvh 4
|
||||
njnt 6
|
||||
ngeom 4
|
||||
nsite 2
|
||||
nlight 1
|
||||
ntex 1
|
||||
ntexdata 1179648
|
||||
ntendon 1
|
||||
nwrap 2
|
||||
nnames 41
|
||||
nnames_map 40
|
||||
nM 49
|
||||
nD 85
|
||||
nB 40
|
||||
njmax -1
|
||||
nconmax -1
|
||||
nstack 1835008
|
||||
nbuffer 1191840
|
||||
|
||||
timestep 0.002
|
||||
apirate 1e+02
|
||||
impratio 1
|
||||
tolerance 1e-08
|
||||
noslip_tolerance 1e-06
|
||||
mpr_tolerance 1e-06
|
||||
density 0
|
||||
viscosity 0
|
||||
o_margin 0
|
||||
integrator 0
|
||||
collision 0
|
||||
cone 0
|
||||
jacobian 2
|
||||
solver 2
|
||||
iterations 100
|
||||
noslip_iterations 0
|
||||
mpr_iterations 50
|
||||
disableflags 0
|
||||
enableflags 0
|
||||
gravity 0 0 -9.8
|
||||
wind 0 0 0
|
||||
magnetic 0 -0.5 0
|
||||
o_solref 0.02 1
|
||||
o_solimp 0.9 0.95 0.001 0.5 2
|
||||
|
||||
totalmass 11
|
||||
|
||||
meaninertia 0.86
|
||||
meanmass 2.7
|
||||
meansize 0.17
|
||||
extent 1.1
|
||||
center 0.12 0 0.52
|
||||
|
||||
qpos0 1 0 0 0 0 0 0 0 0.3 0 0.1 1 0 0 0
|
||||
|
||||
qpos_spring 1 0 0 0 0 0 0 0 0.3 0 0.1 1 0 0 0
|
||||
|
||||
|
||||
BODY 0:
|
||||
name world
|
||||
body_parentid 0
|
||||
body_rootid 0
|
||||
body_weldid 0
|
||||
body_mocapid -1
|
||||
body_jntnum 0
|
||||
body_jntadr -1
|
||||
body_dofnum 0
|
||||
body_dofadr -1
|
||||
body_geomnum 0
|
||||
body_geomadr -1
|
||||
body_simple 1
|
||||
body_sameframe 1
|
||||
body_pos 0 0 0
|
||||
body_quat 1 0 0 0
|
||||
body_ipos 0 0 0
|
||||
body_iquat 1 0 0 0
|
||||
body_mass 0
|
||||
body_subtreemass 11
|
||||
body_inertia 0 0 0
|
||||
body_invweight0 0 0
|
||||
body_gravcomp 0
|
||||
body_plugin -1
|
||||
body_bvhadr -1
|
||||
body_bvhnum 0
|
||||
|
||||
BODY 1:
|
||||
name
|
||||
body_parentid 0
|
||||
body_rootid 1
|
||||
body_weldid 1
|
||||
body_mocapid -1
|
||||
body_jntnum 1
|
||||
body_jntadr 0
|
||||
body_dofnum 3
|
||||
body_dofadr 0
|
||||
body_geomnum 1
|
||||
body_geomadr 0
|
||||
body_simple 0
|
||||
body_sameframe 0
|
||||
body_pos 0 0 1
|
||||
body_quat 1 0 0 0
|
||||
body_ipos 0 0 -0.2
|
||||
body_iquat 1 0 0 0
|
||||
body_mass 5.4
|
||||
body_subtreemass 7.9
|
||||
body_inertia 0.11 0.11 0.0094
|
||||
body_invweight0 0.048 6.9
|
||||
body_gravcomp 0
|
||||
body_plugin -1
|
||||
body_bvhadr 0
|
||||
body_bvhnum 1
|
||||
|
||||
BODY 2:
|
||||
name
|
||||
body_parentid 1
|
||||
body_rootid 1
|
||||
body_weldid 2
|
||||
body_mocapid -1
|
||||
body_jntnum 2
|
||||
body_jntadr 1
|
||||
body_dofnum 2
|
||||
body_dofadr 3
|
||||
body_geomnum 1
|
||||
body_geomadr 1
|
||||
body_simple 0
|
||||
body_sameframe 0
|
||||
body_pos 0 0 -0.4
|
||||
body_quat 1 0 0 0
|
||||
body_ipos 0.15 0 0
|
||||
body_iquat 0.71 0 -0.71 0
|
||||
body_mass 1.8
|
||||
body_subtreemass 2.4
|
||||
body_inertia 0.019 0.019 0.0014
|
||||
body_invweight0 0.29 1.6e+02
|
||||
body_gravcomp 0
|
||||
body_plugin -1
|
||||
body_bvhadr 1
|
||||
body_bvhnum 1
|
||||
|
||||
BODY 3:
|
||||
name
|
||||
body_parentid 2
|
||||
body_rootid 1
|
||||
body_weldid 3
|
||||
body_mocapid -1
|
||||
body_jntnum 2
|
||||
body_jntadr 3
|
||||
body_dofnum 2
|
||||
body_dofadr 5
|
||||
body_geomnum 1
|
||||
body_geomadr 2
|
||||
body_simple 0
|
||||
body_sameframe 0
|
||||
body_pos 0.3 0 0
|
||||
body_quat 1 0 0 0
|
||||
body_ipos 0.1 0 0
|
||||
body_iquat 1 0 0 0
|
||||
body_mass 0.67
|
||||
body_subtreemass 0.67
|
||||
body_inertia 0.00091 0.0014 0.0022
|
||||
body_invweight0 0.9 2.7e+02
|
||||
body_gravcomp 0
|
||||
body_plugin -1
|
||||
body_bvhadr 2
|
||||
body_bvhnum 1
|
||||
|
||||
BODY 4:
|
||||
name
|
||||
body_parentid 0
|
||||
body_rootid 4
|
||||
body_weldid 4
|
||||
body_mocapid -1
|
||||
body_jntnum 1
|
||||
body_jntadr 5
|
||||
body_dofnum 6
|
||||
body_dofadr 7
|
||||
body_geomnum 1
|
||||
body_geomadr 3
|
||||
body_simple 1
|
||||
body_sameframe 1
|
||||
body_pos 0.3 0 0.1
|
||||
body_quat 1 0 0 0
|
||||
body_ipos 0 0 0
|
||||
body_iquat 1 0 0 0
|
||||
body_mass 3.1
|
||||
body_subtreemass 3.1
|
||||
body_inertia 0.014 0.014 0.0075
|
||||
body_invweight0 0.32 92
|
||||
body_gravcomp 0
|
||||
body_plugin -1
|
||||
body_bvhadr 3
|
||||
body_bvhnum 1
|
||||
|
||||
|
||||
JOINT 0:
|
||||
name
|
||||
jnt_type 1
|
||||
jnt_qposadr 0
|
||||
jnt_dofadr 0
|
||||
jnt_bodyid 1
|
||||
jnt_group 0
|
||||
jnt_limited 0
|
||||
jnt_solref 0.02 1
|
||||
jnt_solimp 0.9 0.95 0.001 0.5 2
|
||||
jnt_pos 0 0 0
|
||||
jnt_axis 0 0 1
|
||||
jnt_stiffness 0
|
||||
jnt_range 0 0
|
||||
jnt_margin 0
|
||||
|
||||
JOINT 1:
|
||||
name
|
||||
jnt_type 3
|
||||
jnt_qposadr 4
|
||||
jnt_dofadr 3
|
||||
jnt_bodyid 2
|
||||
jnt_group 0
|
||||
jnt_limited 0
|
||||
jnt_solref 0.02 1
|
||||
jnt_solimp 0.9 0.95 0.001 0.5 2
|
||||
jnt_pos 0 0 0
|
||||
jnt_axis 0 1 0
|
||||
jnt_stiffness 0
|
||||
jnt_range 0 0
|
||||
jnt_margin 0
|
||||
|
||||
JOINT 2:
|
||||
name
|
||||
jnt_type 3
|
||||
jnt_qposadr 5
|
||||
jnt_dofadr 4
|
||||
jnt_bodyid 2
|
||||
jnt_group 0
|
||||
jnt_limited 0
|
||||
jnt_solref 0.02 1
|
||||
jnt_solimp 0.9 0.95 0.001 0.5 2
|
||||
jnt_pos 0 0 0
|
||||
jnt_axis 1 0 0
|
||||
jnt_stiffness 0
|
||||
jnt_range 0 0
|
||||
jnt_margin 0
|
||||
|
||||
JOINT 3:
|
||||
name
|
||||
jnt_type 3
|
||||
jnt_qposadr 6
|
||||
jnt_dofadr 5
|
||||
jnt_bodyid 3
|
||||
jnt_group 0
|
||||
jnt_limited 0
|
||||
jnt_solref 0.02 1
|
||||
jnt_solimp 0.9 0.95 0.001 0.5 2
|
||||
jnt_pos 0 0 0
|
||||
jnt_axis 0 1 0
|
||||
jnt_stiffness 0
|
||||
jnt_range 0 0
|
||||
jnt_margin 0
|
||||
|
||||
JOINT 4:
|
||||
name
|
||||
jnt_type 3
|
||||
jnt_qposadr 7
|
||||
jnt_dofadr 6
|
||||
jnt_bodyid 3
|
||||
jnt_group 0
|
||||
jnt_limited 0
|
||||
jnt_solref 0.02 1
|
||||
jnt_solimp 0.9 0.95 0.001 0.5 2
|
||||
jnt_pos 0 0 0
|
||||
jnt_axis 0 0 1
|
||||
jnt_stiffness 0
|
||||
jnt_range 0 0
|
||||
jnt_margin 0
|
||||
|
||||
JOINT 5:
|
||||
name
|
||||
jnt_type 0
|
||||
jnt_qposadr 8
|
||||
jnt_dofadr 7
|
||||
jnt_bodyid 4
|
||||
jnt_group 0
|
||||
jnt_limited 0
|
||||
jnt_solref 0.02 1
|
||||
jnt_solimp 0.9 0.95 0.001 0.5 2
|
||||
jnt_pos 0 0 0
|
||||
jnt_axis 0 0 1
|
||||
jnt_stiffness 0
|
||||
jnt_range 0 0
|
||||
jnt_margin 0
|
||||
|
||||
|
||||
DOF 0:
|
||||
dof_bodyid 1
|
||||
dof_jntid 0
|
||||
dof_parentid -1
|
||||
dof_Madr 0
|
||||
dof_simplenum 0
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 6.9
|
||||
dof_M0 0.72
|
||||
|
||||
DOF 1:
|
||||
dof_bodyid 1
|
||||
dof_jntid 0
|
||||
dof_parentid 0
|
||||
dof_Madr 1
|
||||
dof_simplenum 0
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 6.9
|
||||
dof_M0 0.89
|
||||
|
||||
DOF 2:
|
||||
dof_bodyid 1
|
||||
dof_jntid 0
|
||||
dof_parentid 1
|
||||
dof_Madr 3
|
||||
dof_simplenum 0
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 6.9
|
||||
dof_M0 0.18
|
||||
|
||||
DOF 3:
|
||||
dof_bodyid 2
|
||||
dof_jntid 1
|
||||
dof_parentid 2
|
||||
dof_Madr 6
|
||||
dof_simplenum 0
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 16
|
||||
dof_M0 0.17
|
||||
|
||||
DOF 4:
|
||||
dof_bodyid 2
|
||||
dof_jntid 2
|
||||
dof_parentid 3
|
||||
dof_Madr 10
|
||||
dof_simplenum 0
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 4.4e+02
|
||||
dof_M0 0.0023
|
||||
|
||||
DOF 5:
|
||||
dof_bodyid 3
|
||||
dof_jntid 3
|
||||
dof_parentid 4
|
||||
dof_Madr 15
|
||||
dof_simplenum 0
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 3e+02
|
||||
dof_M0 0.0081
|
||||
|
||||
DOF 6:
|
||||
dof_bodyid 3
|
||||
dof_jntid 4
|
||||
dof_parentid 5
|
||||
dof_Madr 21
|
||||
dof_simplenum 0
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 2.5e+02
|
||||
dof_M0 0.0089
|
||||
|
||||
DOF 7:
|
||||
dof_bodyid 4
|
||||
dof_jntid 5
|
||||
dof_parentid -1
|
||||
dof_Madr 28
|
||||
dof_simplenum 6
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 0.32
|
||||
dof_M0 3.1
|
||||
|
||||
DOF 8:
|
||||
dof_bodyid 4
|
||||
dof_jntid 5
|
||||
dof_parentid 7
|
||||
dof_Madr 29
|
||||
dof_simplenum 5
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 0.32
|
||||
dof_M0 3.1
|
||||
|
||||
DOF 9:
|
||||
dof_bodyid 4
|
||||
dof_jntid 5
|
||||
dof_parentid 8
|
||||
dof_Madr 31
|
||||
dof_simplenum 4
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 0.32
|
||||
dof_M0 3.1
|
||||
|
||||
DOF 10:
|
||||
dof_bodyid 4
|
||||
dof_jntid 5
|
||||
dof_parentid 9
|
||||
dof_Madr 34
|
||||
dof_simplenum 3
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 92
|
||||
dof_M0 0.014
|
||||
|
||||
DOF 11:
|
||||
dof_bodyid 4
|
||||
dof_jntid 5
|
||||
dof_parentid 10
|
||||
dof_Madr 38
|
||||
dof_simplenum 2
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 92
|
||||
dof_M0 0.014
|
||||
|
||||
DOF 12:
|
||||
dof_bodyid 4
|
||||
dof_jntid 5
|
||||
dof_parentid 11
|
||||
dof_Madr 43
|
||||
dof_simplenum 1
|
||||
dof_solref 0.02 1
|
||||
dof_solimp 0.9 0.95 0.001 0.5 2
|
||||
dof_frictionloss 0
|
||||
dof_armature 0
|
||||
dof_damping 0
|
||||
dof_invweight0 92
|
||||
dof_M0 0.0075
|
||||
|
||||
|
||||
GEOM 0:
|
||||
name
|
||||
geom_type 3
|
||||
geom_contype 1
|
||||
geom_conaffinity 1
|
||||
geom_condim 3
|
||||
geom_bodyid 1
|
||||
geom_dataid -1
|
||||
geom_matid -1
|
||||
geom_group 0
|
||||
geom_priority 0
|
||||
geom_sameframe 2
|
||||
geom_solmix 1
|
||||
geom_solref 0.02 1
|
||||
geom_solimp 0.9 0.95 0.001 0.5 2
|
||||
geom_size 0.06 0.2 0
|
||||
geom_aabb 0 0 0 0.06 0.06 0.26
|
||||
geom_rbound 0.26
|
||||
geom_pos 0 0 -0.2
|
||||
geom_quat 1 0 0 0
|
||||
geom_friction 1 0.005 0.0001
|
||||
geom_margin 0
|
||||
geom_gap 0
|
||||
geom_fluid 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
geom_rgba 0.8 0.6 0.4 1
|
||||
|
||||
GEOM 1:
|
||||
name
|
||||
geom_type 3
|
||||
geom_contype 1
|
||||
geom_conaffinity 1
|
||||
geom_condim 3
|
||||
geom_bodyid 2
|
||||
geom_dataid -1
|
||||
geom_matid -1
|
||||
geom_group 0
|
||||
geom_priority 0
|
||||
geom_sameframe 2
|
||||
geom_solmix 1
|
||||
geom_solref 0.02 1
|
||||
geom_solimp 0.9 0.95 0.001 0.5 2
|
||||
geom_size 0.04 0.15 0
|
||||
geom_aabb 0 0 0 0.04 0.04 0.19
|
||||
geom_rbound 0.19
|
||||
geom_pos 0.15 0 0
|
||||
geom_quat 0.71 0 -0.71 0
|
||||
geom_friction 1 0.005 0.0001
|
||||
geom_margin 0
|
||||
geom_gap 0
|
||||
geom_fluid 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
geom_rgba 0.8 0.6 0.4 1
|
||||
|
||||
GEOM 2:
|
||||
name
|
||||
geom_type 4
|
||||
geom_contype 1
|
||||
geom_conaffinity 1
|
||||
geom_condim 3
|
||||
geom_bodyid 3
|
||||
geom_dataid -1
|
||||
geom_matid -1
|
||||
geom_group 0
|
||||
geom_priority 0
|
||||
geom_sameframe 2
|
||||
geom_solmix 1
|
||||
geom_solref 0.02 1
|
||||
geom_solimp 0.9 0.95 0.001 0.5 2
|
||||
geom_size 0.1 0.08 0.02
|
||||
geom_aabb 0 0 0 0.1 0.08 0.02
|
||||
geom_rbound 0.1
|
||||
geom_pos 0.1 0 0
|
||||
geom_quat 1 0 0 0
|
||||
geom_friction 1 0.005 0.0001
|
||||
geom_margin 0
|
||||
geom_gap 0
|
||||
geom_fluid 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
geom_rgba 0.8 0.6 0.4 1
|
||||
|
||||
GEOM 3:
|
||||
name
|
||||
geom_type 5
|
||||
geom_contype 1
|
||||
geom_conaffinity 1
|
||||
geom_condim 3
|
||||
geom_bodyid 4
|
||||
geom_dataid -1
|
||||
geom_matid -1
|
||||
geom_group 0
|
||||
geom_priority 0
|
||||
geom_sameframe 1
|
||||
geom_solmix 1
|
||||
geom_solref 0.02 1
|
||||
geom_solimp 0.9 0.95 0.001 0.5 2
|
||||
geom_size 0.07 0.1 0
|
||||
geom_aabb 0 0 0 0.07 0.07 0.1
|
||||
geom_rbound 0.12
|
||||
geom_pos 0 0 0
|
||||
geom_quat 1 0 0 0
|
||||
geom_friction 1 0.005 0.0001
|
||||
geom_margin 0
|
||||
geom_gap 0
|
||||
geom_fluid 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
geom_rgba 0.8 0.6 0.4 1
|
||||
|
||||
|
||||
SITE 0:
|
||||
name end1
|
||||
site_type 2
|
||||
site_bodyid 3
|
||||
site_matid -1
|
||||
site_group 0
|
||||
site_sameframe 0
|
||||
site_size 0.01 0.005 0.005
|
||||
site_pos 0.2 0 0
|
||||
site_quat 1 0 0 0
|
||||
site_rgba 0.5 0.5 0.5 1
|
||||
|
||||
SITE 1:
|
||||
name end2
|
||||
site_type 2
|
||||
site_bodyid 4
|
||||
site_matid -1
|
||||
site_group 0
|
||||
site_sameframe 0
|
||||
site_size 0.01 0.005 0.005
|
||||
site_pos 0 0 0.1
|
||||
site_quat 1 0 0 0
|
||||
site_rgba 0.5 0.5 0.5 1
|
||||
|
||||
|
||||
LIGHT 0:
|
||||
name
|
||||
light_mode 0
|
||||
light_bodyid 0
|
||||
light_targetbodyid -1
|
||||
light_directional 0
|
||||
light_castshadow 1
|
||||
light_active 1
|
||||
light_pos 0 1 1
|
||||
light_dir 0 -0.71 -0.71
|
||||
light_poscom0 -0.13 1 0.44
|
||||
light_pos0 0 1 1
|
||||
light_dir0 0 -0.71 -0.71
|
||||
light_attenuation 1 0 0
|
||||
light_cutoff 45
|
||||
light_exponent 10
|
||||
light_ambient 0 0 0
|
||||
light_diffuse 1 1 1
|
||||
light_specular 0.3 0.3 0.3
|
||||
|
||||
|
||||
TEXTURE 0:
|
||||
name
|
||||
tex_type 2
|
||||
tex_height 1536
|
||||
tex_width 256
|
||||
tex_adr 0
|
||||
|
||||
|
||||
TENDON 0:
|
||||
name
|
||||
tendon_adr 0
|
||||
tendon_num 2
|
||||
tendon_matid -1
|
||||
tendon_group 0
|
||||
tendon_limited 1
|
||||
tendon_width 0.005
|
||||
tendon_solref_lim 0.02 1
|
||||
tendon_solimp_lim 0.9 0.95 0.001 0.5 2
|
||||
tendon_solref_fri 0.02 1
|
||||
tendon_solimp_fri 0.9 0.95 0.001 0.5 2
|
||||
tendon_range 0 0.6
|
||||
tendon_margin 0
|
||||
tendon_stiffness 0
|
||||
tendon_damping 0
|
||||
tendon_frictionloss 0
|
||||
tendon_lengthspring 0.45 0.45
|
||||
tendon_length0 0.45
|
||||
tendon_invweight0 4.9
|
||||
tendon_rgba 0.5 0.5 0.5 1
|
||||
path
|
||||
3 0 0
|
||||
3 1 0
|
||||
@@ -1,38 +0,0 @@
|
||||
<mujoco model="example">
|
||||
<compiler angle="radian" autolimits="true"/>
|
||||
<default class="main">
|
||||
<geom rgba="0.8 0.6 0.4 1"/>
|
||||
</default>
|
||||
<asset>
|
||||
<texture type="skybox" builtin="gradient" rgb1="1 1 1" rgb2="0.6 0.8 1" width="256" height="1536"/>
|
||||
</asset>
|
||||
<worldbody>
|
||||
<light pos="0 1 1" dir="0 -0.707107 -0.707107" diffuse="1 1 1"/>
|
||||
<body pos="0 0 1">
|
||||
<joint pos="0 0 0" type="ball"/>
|
||||
<geom size="0.06 0.2" pos="0 0 -0.2" type="capsule"/>
|
||||
<body pos="0 0 -0.4">
|
||||
<joint pos="0 0 0" axis="0 1 0"/>
|
||||
<joint pos="0 0 0" axis="1 0 0"/>
|
||||
<geom size="0.04 0.15" pos="0.15 0 0" quat="0.707107 0 -0.707107 0" type="capsule"/>
|
||||
<body pos="0.3 0 0">
|
||||
<joint pos="0 0 0" axis="0 1 0"/>
|
||||
<joint pos="0 0 0" axis="0 0 1"/>
|
||||
<geom size="0.1 0.08 0.02" pos="0.1 0 0" type="ellipsoid"/>
|
||||
<site name="end1" pos="0.2 0 0" size="0.01"/>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
<body pos="0.3 0 0.1">
|
||||
<joint type="free"/>
|
||||
<geom size="0.07 0.1" type="cylinder"/>
|
||||
<site name="end2" pos="0 0 0.1" size="0.01"/>
|
||||
</body>
|
||||
</worldbody>
|
||||
<tendon>
|
||||
<spatial range="0 0.6" width="0.005">
|
||||
<site site="end1"/>
|
||||
<site site="end2"/>
|
||||
</spatial>
|
||||
</tendon>
|
||||
</mujoco>
|
||||
|
Before Width: | Height: | Size: 553 B |
|
Before Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,18 +0,0 @@
|
||||
<mujoco>
|
||||
<asset>
|
||||
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3" rgb2=".2 .3 .4"/>
|
||||
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2"/>
|
||||
</asset>
|
||||
|
||||
<worldbody>
|
||||
<light pos="0 -1 5" dir="1 1 -10"/>
|
||||
<light pos="1.5 -1 5" dir="-1 1 -10"/>
|
||||
<camera name="front" pos=".75 -5 1.5" xyaxes="1 0 0 0 .3 1"/>
|
||||
|
||||
<geom type="plane" material="grid" size="0 0 .1" pos="0 0 -.1"/>
|
||||
<geom type="capsule" size="0.1" fromto="0 0 0 0 0 1"/>
|
||||
<geom type="box" size="0.1" fromto=".5 0 0 .5 0 1"/>
|
||||
<geom type="cylinder" size="0.1" fromto="1 0 0 1 0 1"/>
|
||||
<geom type="ellipsoid" size="0.1" fromto="1.5 0 0 1.5 0 1"/>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
@@ -1,22 +0,0 @@
|
||||
<mujoco>
|
||||
<asset>
|
||||
<texture type="skybox" builtin="gradient" rgb1=".3 .5 .7" rgb2="0 0 0" width="32" height="512"/>
|
||||
<texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb1=".1 .2 .3" rgb2=".2 .3 .4"/>
|
||||
<material name="grid" texture="grid" texrepeat="1 1" texuniform="true" reflectance=".2"/>
|
||||
</asset>
|
||||
|
||||
<statistic extent="1"/>
|
||||
|
||||
<!-- switch the integrator to "implicit" for better gyroscopic stabillity -->
|
||||
<option timestep="0.01" integrator="implicitfast"/>
|
||||
|
||||
<worldbody>
|
||||
<geom pos="0 0 -.5" type="plane" size="100 100 .1" zaxis=".5 0 1" material="grid"/>
|
||||
<body pos="0 0 .3">
|
||||
<freejoint/>
|
||||
<geom type="ellipsoid" size="0.15 0.1 0.07" euler="20 40 60"/>
|
||||
<light pos="0 0 1.5" mode="track"/>
|
||||
<camera pos="0 -1.498 0.1" xyaxes="1 0 0 0 0 1" mode="track"/>
|
||||
</body>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
@@ -1,10 +0,0 @@
|
||||
<mujoco>
|
||||
<worldbody>
|
||||
<light diffuse=".5 .5 .5" pos="0 0 3" dir="0 0 -1"/>
|
||||
<geom type="plane" size="1 1 0.1" rgba=".9 0 0 1"/>
|
||||
<body pos="0 0 1">
|
||||
<joint type="free"/>
|
||||
<geom type="box" size=".1 .2 .3" rgba="0 .9 0 1"/>
|
||||
</body>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
* This script hides Sphinx auto-generated attribute links from the
|
||||
* "On this page" sidebar.
|
||||
* Adapted for the Furo theme.
|
||||
* Uses a MutationObserver to wait for Furo's JavaScript to create the
|
||||
* sidebar before attempting to modify it.
|
||||
*/
|
||||
function hideAttributesFromTOC() {
|
||||
// Furo's "On this page" sidebar container has the class .toc-tree
|
||||
const tocContainerSelector = '.toc-tree';
|
||||
|
||||
// Step 1: Find all attribute definitions and collect their IDs.
|
||||
const attributeDefs = document.querySelectorAll('dl.py.attribute');
|
||||
if (attributeDefs.length === 0) {
|
||||
return false; // No attributes on this page, nothing to do.
|
||||
}
|
||||
const attributeIds = new Set();
|
||||
attributeDefs.forEach(def => {
|
||||
const term = def.querySelector('dt');
|
||||
if (term && term.id) {
|
||||
attributeIds.add(term.id);
|
||||
}
|
||||
});
|
||||
|
||||
if (attributeIds.size === 0) {
|
||||
return false; // No attribute IDs found.
|
||||
}
|
||||
|
||||
// Step 2: Find the sidebar container.
|
||||
const tocContainer = document.querySelector(tocContainerSelector);
|
||||
if (!tocContainer) {
|
||||
// Container not found yet. The observer will try again.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Step 3: Get all links within that sidebar.
|
||||
const tocLinks = tocContainer.querySelectorAll('a');
|
||||
if (tocLinks.length === 0) {
|
||||
return false; // Container found, but it's empty. Let's wait.
|
||||
}
|
||||
|
||||
// Step 4: Iterate through the links and hide the ones that match.
|
||||
let hiddenCount = 0;
|
||||
tocLinks.forEach(link => {
|
||||
const href = link.getAttribute('href');
|
||||
if (href && href.startsWith('#')) {
|
||||
const linkId = href.substring(1);
|
||||
if (attributeIds.has(linkId)) {
|
||||
// In Furo, the link is inside a list item (<li>) which we need to hide.
|
||||
const listItem = link.closest('li');
|
||||
if (listItem && listItem.style.display !== 'none') {
|
||||
console.log(`Hiding sidebar link for: #${linkId}`);
|
||||
listItem.style.display = 'none';
|
||||
hiddenCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// If we successfully hid the links, we can stop observing.
|
||||
if (hiddenCount > 0) {
|
||||
return true; // Signal success
|
||||
}
|
||||
|
||||
// If we found the container but didn't hide anything, maybe it's not fully
|
||||
// rendered. Let the observer run a few more times. A better approach might be
|
||||
// needed if this fails, but for most cases, this is sufficient.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use a MutationObserver to wait for the page to be dynamically built.
|
||||
const observer = new MutationObserver((mutations, obs) => {
|
||||
// We only need to run our function once successfully.
|
||||
if (hideAttributesFromTOC()) {
|
||||
obs.disconnect(); // Stop observing once the task is done.
|
||||
}
|
||||
});
|
||||
|
||||
// Start observing the entire document body for added/removed nodes.
|
||||
observer.observe(document.body, {childList: true, subtree: true});
|
||||
@@ -1,27 +0,0 @@
|
||||
<mujoco model="energy conserving pendulum">
|
||||
<option integrator="RK4">
|
||||
<flag constraint="disable" energy="enable"/>
|
||||
</option>
|
||||
|
||||
<worldbody>
|
||||
<light pos="0 0 2"/>
|
||||
<geom pos="0 0 -.5" type="plane" size="1 1 .01"/>
|
||||
<body pos="0 0 0">
|
||||
<joint type="hinge" axis="0 1 0"/>
|
||||
<geom type="cylinder" size="0.02" fromto="0 -.02 0 0 .02 0"/>
|
||||
<geom type="capsule" size="0.02" fromto="0 0 0 .1 0 0"/>
|
||||
<body pos="0.1 0 0">
|
||||
<joint type="slide" axis="1 0 0" stiffness="200"/>
|
||||
<geom type="capsule" size="0.015" fromto="-.1 0 0 .1 0 0"/>
|
||||
<body pos=".1 0 0">
|
||||
<joint type="ball"/>
|
||||
<geom type="box" size=".02" fromto="0 0 0 0 .1 0"/>
|
||||
<body pos="0 .1 0">
|
||||
<joint axis="1 0 0"/>
|
||||
<geom type="capsule" size="0.02" fromto="0 0 0 0 .1 0"/>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
@@ -1,66 +0,0 @@
|
||||
<mujoco model="tendon">
|
||||
<default>
|
||||
<joint axis="0 1 0" range="0 60" limited="true"/>
|
||||
<geom type="capsule" size=".01" rgba=".9 .7 .1 1"/>
|
||||
<site rgba=".9 .9 .9 1"/>
|
||||
<default class="visual_cylinder">
|
||||
<geom type="cylinder" fromto="0 .015 0 0 -.015 0" size=".02" rgba=".3 .9 .3 .4"/>
|
||||
</default>
|
||||
</default>
|
||||
|
||||
<worldbody>
|
||||
<light pos="0 0 1"/>
|
||||
<body name="weight" pos="-.03 0 .175">
|
||||
<joint axis="0 0 1" pos="0 0 .025" type="slide"/>
|
||||
<geom type="cylinder" size=".03 .025" density="5000" rgba=".2 .2 .5 1"/>
|
||||
<site name="s1" pos="0 0 .025"/>
|
||||
</body>
|
||||
|
||||
<site name="s2" pos="-.03 0 .33"/>
|
||||
|
||||
<body pos="0 0 .3">
|
||||
<joint/>
|
||||
<geom name="g1" class="visual_cylinder"/>
|
||||
<geom fromto="0 0 0 .1 0 0"/>
|
||||
<site name="s3" pos=".02 0 .03"/>
|
||||
|
||||
<body pos=".1 0 0">
|
||||
<joint/>
|
||||
<geom name="g2" class="visual_cylinder"/>
|
||||
<geom fromto="0 0 0 .1 0 0"/>
|
||||
<site name="s4" pos=".03 0 .01"/>
|
||||
<site name="s5" pos=".05 0 .02"/>
|
||||
<site name="side2" pos="0 0 .03"/>
|
||||
|
||||
<body pos=".1 0 0">
|
||||
<joint/>
|
||||
<geom name="g3" class="visual_cylinder"/>
|
||||
<geom fromto="0 0 0 .1 0 0"/>
|
||||
<site name="s6" pos=".03 0 .01"/>
|
||||
<site name="side3" pos="0 0 .03"/>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</worldbody>
|
||||
|
||||
<tendon>
|
||||
<spatial range="0 .33" limited="true" width=".002" rgba=".95 .3 .3 1">
|
||||
<site site="s1"/>
|
||||
<site site="s2"/>
|
||||
<geom geom="g1"/>
|
||||
<site site="s3"/>
|
||||
|
||||
<pulley divisor="2"/>
|
||||
<site site="s3"/>
|
||||
<geom geom="g2" sidesite="side2"/>
|
||||
<site site="s4"/>
|
||||
|
||||
<pulley divisor="2"/>
|
||||
<site site="s3"/>
|
||||
<geom geom="g2" sidesite="side2"/>
|
||||
<site site="s5"/>
|
||||
<geom geom="g3" sidesite="side3"/>
|
||||
<site site="s6"/>
|
||||
</spatial>
|
||||
</tendon>
|
||||
</mujoco>
|
||||