diff --git a/src/experimental/studio/README.md b/src/experimental/studio/README.md new file mode 100644 index 00000000..835cbcfd --- /dev/null +++ b/src/experimental/studio/README.md @@ -0,0 +1,66 @@ +# MuJoCo Studio + +MuJoCo Studio is the next iteration of the [simulate](../../../simulate) +application. The UI has been reimplemented using [Dear ImGui](https://github.com/ocornut/imgui) +and the default renderer has been switched to Filament. The application is +still WIP, see the [Future Work](#future-work) section for details. + +## Usage + +Configure and build MuJoCo Studio by running this command from the top-level +directory. Then follow the printed instructions to run the executable. + +``` +bash build.sh +``` + +> [!NOTE] For now [`build.sh`](build.sh) script works on windows in a git bash +> shell. + +## Development + +The [`build.sh`](build.sh) script is intended to get you up and running quickly. +If you intend to develop the application you may prefer to work from an IDE: + +* [Clion](https://www.jetbrains.com/clion/). You should be able to set this up + to work with the cmake files we provide. + +* [VSCode](https://code.visualstudio.com/). We have found that Microsoft's + [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) + extension works well. + +* [Visual Studio](https://visualstudio.microsoft.com/). Follow these + [instructions](https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-170). + +## Filament Rendering + +Studio uses legacy OpenGL rendering by default but there is an option to use +Physically Based Rendering via [Filament](https://google.github.io/filament/Filament.md.html). +To enable Filament you need to `-DMUJOCO_USE_FILAMENT=ON` during the cmake +configuration step. The Filament renderer has multiple rendering backends, +on Linux OpenGL is the default but Vulkan can be used by also providing +the `-DMUJOCO_USE_FILAMENT_VULKAN=ON` option. + +Also note that you will need to run the application from the folder containing +the executable so that the expected materials/assets can be found. + +> [!WARNING] Filament rendering currently supported on Linux. We are actively +> working on bugs and build issues we've encountered on MacOS and Windows. +> Contributions improving support on those platforms are very welcome, your +> fixes may need to be applied in the upstream [Filament](https://github.com/google/filament) +> GitHub repository. + +## Known Bugs + +* MuJoCo Studio does not yet work using Wayland on Linux, use X11 instead. + +## Future Work + +1. **Stability and Robustness**. We need user feedback to find and fix bugs. + +1. **UI/UX improvements**. We have ported the simulate UI to make it easier to +users to switch. We will be making further changes to make use of the +flexibility offered by Dear ImGui ([examples](https://github.com/ocornut/imgui/issues/8942)). + +1. **Python integration**. As with simulate, we would like to make Studio usable + via Python. diff --git a/src/experimental/studio/build.sh b/src/experimental/studio/build.sh new file mode 100755 index 00000000..28e36894 --- /dev/null +++ b/src/experimental/studio/build.sh @@ -0,0 +1,99 @@ +#!/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. + + +# Detect the operating system +OS="$(uname -s)" +case "${OS}" in + Linux*) export OS_NAME="linux" ;; + Darwin*) export OS_NAME="macos" ;; + MINGW* | CYGWIN* | MSYS*) export OS_NAME="windows" ;; + *) echo "Unsupported OS: ${OS}" >&2; exit 1 ;; +esac + +# Parse arguments +do_configure=false +do_build=false +build_type="Release" +explicit_action=false + +for arg in "$@"; do + case "$arg" in + configure|config) + do_configure=true + explicit_action=true + ;; + build) + do_build=true + explicit_action=true + ;; + debug|dbg) + build_type="Debug" + ;; + esac +done + +# If no specific action (configure/build) was requested, do both by default. +if [[ "$explicit_action" == false ]]; then + do_configure=true + do_build=true +fi + +cd "$(git rev-parse --show-toplevel)" + +# Configure MuJoCo Studio +if [[ "$do_configure" == true ]]; then + echo "Configuring MuJoCo Studio (${build_type})..." + CMAKE_CONFIG_ARGS=( + "-B build" + "-DCMAKE_BUILD_TYPE=${build_type}" + "-DUSE_STATIC_LIBCXX=OFF" + "-DBUILD_SHARED_LIB=OFF" + "-DMUJOCO_USE_FILAMENT=OFF" + "-DMUJOCO_USE_FILAMENT_VULKAN=OFF" + "-DMUJOCO_BUILD_EXAMPLES=OFF" + "-DMUJOCO_BUILD_SIMULATE=OFF" + "-DMUJOCO_BUILD_TESTS=OFF" + "-DMUJOCO_TEST_PYTHON_UTIL=OFF" + "-DMUJOCO_WITH_USD=OFF" + "-DMUJOCO_BUILD_STUDIO=ON" + ) + + # Add user-defined CMAKE_ARGS at the end so they override other settings. + if [[ -n "${CMAKE_ARGS}" ]]; then + read -a cmake_args_arr <<<"$CMAKE_ARGS" + CMAKE_CONFIG_ARGS+=("${cmake_args_arr[@]}") + fi + + cmake ${CMAKE_CONFIG_ARGS[@]} + + echo "Configuring MuJoCo Studio (${build_type})... DONE" +fi + +# Build MuJoCo Studio +if [[ "$do_build" == true ]]; then + echo "Building MuJoCo Studio..." + cmake --build build --config=${build_type} --target mujoco_studio --parallel + echo "Building MuJoCo Studio... DONE" + + # Print the command to run the built MuJoCo Studio from the right directory. + echo "Use the following command to run mujoco_studio" + echo "" + if [[ "${OS_NAME}" == "windows" ]]; then + echo " cd $(git rev-parse --show-toplevel)/build/bin && ./${build_type}/mujoco_studio.exe " + else + echo " cd $(git rev-parse --show-toplevel)/build/bin && ./mujoco_studio " + fi +fi