mujoco 3.13.0__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mujoco/__init__.py +256 -0
- mujoco/_callbacks.cp315-win_amd64.pyd +0 -0
- mujoco/_constants.cp315-win_amd64.pyd +0 -0
- mujoco/_enums.cp315-win_amd64.pyd +0 -0
- mujoco/_errors.cp315-win_amd64.pyd +0 -0
- mujoco/_functions.cp315-win_amd64.pyd +0 -0
- mujoco/_render.cp315-win_amd64.pyd +0 -0
- mujoco/_rollout.cp315-win_amd64.pyd +0 -0
- mujoco/_simulate.cp315-win_amd64.pyd +0 -0
- mujoco/_specs.cp315-win_amd64.pyd +0 -0
- mujoco/_structs.cp315-win_amd64.pyd +0 -0
- mujoco/bindings_test.py +2155 -0
- mujoco/cgl/__init__.py +74 -0
- mujoco/cgl/cgl.py +142 -0
- mujoco/egl/__init__.py +138 -0
- mujoco/egl/egl_ext.py +71 -0
- mujoco/experimental/dear_imgui/dear_imgui.cp315-win_amd64.pyd +0 -0
- mujoco/experimental/implot/implot.cp315-win_amd64.pyd +0 -0
- mujoco/experimental/studio/assets/AtkinsonHyperlegibleMono-Regular.ttf +0 -0
- mujoco/experimental/studio/assets/AtkinsonHyperlegibleNext[wght].ttf +0 -0
- mujoco/experimental/studio/assets/decor.filamat +0 -0
- mujoco/experimental/studio/assets/decor_fade.filamat +0 -0
- mujoco/experimental/studio/assets/fontawesome-webfont.ttf +0 -0
- mujoco/experimental/studio/assets/ibl.ktx +0 -0
- mujoco/experimental/studio/assets/outline_composite.filamat +0 -0
- mujoco/experimental/studio/assets/outline_flatten.filamat +0 -0
- mujoco/experimental/studio/assets/outline_jumpflood.filamat +0 -0
- mujoco/experimental/studio/assets/pbr.filamat +0 -0
- mujoco/experimental/studio/assets/pbr_packed.filamat +0 -0
- mujoco/experimental/studio/assets/pbr_packed_reflect.filamat +0 -0
- mujoco/experimental/studio/assets/pbr_packed_transparent.filamat +0 -0
- mujoco/experimental/studio/assets/pbr_reflect.filamat +0 -0
- mujoco/experimental/studio/assets/pbr_transparent.filamat +0 -0
- mujoco/experimental/studio/assets/phong_2d.filamat +0 -0
- mujoco/experimental/studio/assets/phong_2d_fade.filamat +0 -0
- mujoco/experimental/studio/assets/phong_2d_uv.filamat +0 -0
- mujoco/experimental/studio/assets/phong_2d_uv_fade.filamat +0 -0
- mujoco/experimental/studio/assets/phong_2d_uv_reflect.filamat +0 -0
- mujoco/experimental/studio/assets/phong_color.filamat +0 -0
- mujoco/experimental/studio/assets/phong_color_fade.filamat +0 -0
- mujoco/experimental/studio/assets/phong_color_reflect.filamat +0 -0
- mujoco/experimental/studio/assets/phong_cube.filamat +0 -0
- mujoco/experimental/studio/assets/phong_cube_fade.filamat +0 -0
- mujoco/experimental/studio/assets/phong_cube_reflect.filamat +0 -0
- mujoco/experimental/studio/assets/unlit_depth.filamat +0 -0
- mujoco/experimental/studio/assets/unlit_segmentation.filamat +0 -0
- mujoco/experimental/studio/assets/unlit_ui.filamat +0 -0
- mujoco/experimental/studio/endpoints.py +148 -0
- mujoco/experimental/studio/launch_native.py +63 -0
- mujoco/experimental/studio/launch_passive.py +64 -0
- mujoco/experimental/studio/launch_thread.py +110 -0
- mujoco/experimental/studio/launch_web.py +77 -0
- mujoco/experimental/studio/messages.py +302 -0
- mujoco/experimental/studio/native_viewer.py +195 -0
- mujoco/experimental/studio/native_viewer_cc.cp315-win_amd64.pyd +0 -0
- mujoco/experimental/studio/parser.py +30 -0
- mujoco/experimental/studio/plugin_registry.py +62 -0
- mujoco/experimental/studio/renderer.cp315-win_amd64.pyd +0 -0
- mujoco/experimental/studio/sample/ghost.py +204 -0
- mujoco/experimental/studio/sample/implot.py +255 -0
- mujoco/experimental/studio/sample/render.py +77 -0
- mujoco/experimental/studio/sim.cp315-win_amd64.pyd +0 -0
- mujoco/experimental/studio/step_control.py +54 -0
- mujoco/experimental/studio/ux.cp315-win_amd64.pyd +0 -0
- mujoco/experimental/studio/viewer.py +74 -0
- mujoco/experimental/studio/viewer_app.py +501 -0
- mujoco/experimental/studio/viewer_app_events.py +624 -0
- mujoco/experimental/studio/viewer_handle.py +208 -0
- mujoco/experimental/studio/viewer_protocol.py +288 -0
- mujoco/experimental/studio/viewer_utils.py +62 -0
- mujoco/experimental/studio/web/web_server.py +1153 -0
- mujoco/experimental/studio/web_viewer.py +390 -0
- mujoco/gil_test.py +35 -0
- mujoco/gl_context.py +21 -0
- mujoco/glfw/__init__.py +41 -0
- mujoco/include/mujoco/mujoco/experimental/filament/compat/scene_bridge.h +78 -0
- mujoco/include/mujoco/mujoco/experimental/filament/compat/scene_geom_util.h +35 -0
- mujoco/include/mujoco/mujoco/experimental/filament/compat/scene_objects.h +51 -0
- mujoco/include/mujoco/mujoco/experimental/studio/app.h +284 -0
- mujoco/include/mujoco/mujoco/experimental/studio/hal/classic_renderer.h +91 -0
- mujoco/include/mujoco/mujoco/experimental/studio/hal/egl_utils.h +28 -0
- mujoco/include/mujoco/mujoco/experimental/studio/hal/filament_renderer.h +108 -0
- mujoco/include/mujoco/mujoco/experimental/studio/hal/graphics_mode.h +62 -0
- mujoco/include/mujoco/mujoco/experimental/studio/hal/renderer.h +67 -0
- mujoco/include/mujoco/mujoco/experimental/studio/hal/window.h +110 -0
- mujoco/include/mujoco/mujoco/experimental/studio/io/resources.h +30 -0
- mujoco/include/mujoco/mujoco/experimental/studio/launcher.h +49 -0
- mujoco/include/mujoco/mujoco/experimental/studio/sim/model_holder.h +94 -0
- mujoco/include/mujoco/mujoco/experimental/studio/sim/sim_history.h +94 -0
- mujoco/include/mujoco/mujoco/experimental/studio/sim/sim_profiler.h +56 -0
- mujoco/include/mujoco/mujoco/experimental/studio/sim/step_control.h +132 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/enum_utils.h +170 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/file_dialog.h +59 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/fonts.h +48 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/gui.h +241 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/gui_helpers.h +42 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/gui_spec.h +47 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/imgui_widgets.h +831 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/interaction.h +84 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/picture_gui.h +39 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/plugin.h +155 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/spec_editor.h +180 -0
- mujoco/include/mujoco/mujoco/experimental/studio/ux/well_tempered.h +76 -0
- mujoco/include/mujoco/mujoco/experimental/usd/layer_sink.h +41 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/actuator.h +874 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/api.h +44 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/collisionAPI.h +393 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/equalityAPI.h +224 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/equalityConnectAPI.h +163 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/equalityJointAPI.h +365 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/equalityWeldAPI.h +189 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/imageableAPI.h +186 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/jointAPI.h +654 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/keyframe.h +294 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/materialAPI.h +219 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/meshCollisionAPI.h +223 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/sceneAPI.h +1789 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/siteAPI.h +185 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/tendon.h +843 -0
- mujoco/include/mujoco/mujoco/experimental/usd/mjcPhysics/tokens.h +853 -0
- mujoco/include/mujoco/mujoco/experimental/usd/plugins/mjcf/mjcf_file_format.h +89 -0
- mujoco/include/mujoco/mujoco/experimental/usd/plugins/mjcf/mujoco_to_usd.h +34 -0
- mujoco/include/mujoco/mujoco/experimental/usd/plugins/mjcf/utils.h +127 -0
- mujoco/include/mujoco/mujoco/experimental/usd/utils.h +35 -0
- mujoco/include/mujoco/mujoco/experimental/usd/writer.h +53 -0
- mujoco/include/mujoco/mujoco/mjassert.h +156 -0
- mujoco/include/mujoco/mujoco/mjdata.h +469 -0
- mujoco/include/mujoco/mujoco/mjexport.h +47 -0
- mujoco/include/mujoco/mujoco/mjmacro.h +38 -0
- mujoco/include/mujoco/mujoco/mjmodel.h +921 -0
- mujoco/include/mujoco/mujoco/mjplugin.h +233 -0
- mujoco/include/mujoco/mujoco/mjrender.h +237 -0
- mujoco/include/mujoco/mujoco/mjrfilament.h +400 -0
- mujoco/include/mujoco/mujoco/mjsan.h +81 -0
- mujoco/include/mujoco/mujoco/mjspec.h +855 -0
- mujoco/include/mujoco/mujoco/mjspecmacro.h +613 -0
- mujoco/include/mujoco/mujoco/mjtype.h +645 -0
- mujoco/include/mujoco/mujoco/mjui.h +338 -0
- mujoco/include/mujoco/mujoco/mjvisualize.h +413 -0
- mujoco/include/mujoco/mujoco/mjxmacro.h +1101 -0
- mujoco/include/mujoco/mujoco/mujoco.h +2137 -0
- mujoco/include/mujoco/mujoco/render/filament/mjrfilament_cpp.h +74 -0
- mujoco/include/mujoco/mujoco/render/filament/support/filament_util.h +161 -0
- mujoco/include/mujoco/mujoco/render/filament/support/imgui_bridge.h +69 -0
- mujoco/include/mujoco/mujoco/render/filament/support/mesh_util.h +43 -0
- mujoco/include/mujoco/mujoco/render/filament/support/model_decorations.h +65 -0
- mujoco/include/mujoco/mujoco/render/filament/support/model_lights.h +66 -0
- mujoco/include/mujoco/mujoco/render/filament/support/model_objects.h +87 -0
- mujoco/include/mujoco/mujoco/render/filament/support/model_renderables.h +113 -0
- mujoco/introspect/__init__.py +14 -0
- mujoco/introspect/ast_nodes.py +307 -0
- mujoco/introspect/ast_nodes_test.py +202 -0
- mujoco/introspect/codegen/ast_processor.py +369 -0
- mujoco/introspect/codegen/formatter.py +149 -0
- mujoco/introspect/codegen/generate.py +151 -0
- mujoco/introspect/enums.py +1128 -0
- mujoco/introspect/enums_test.py +69 -0
- mujoco/introspect/functions.py +13170 -0
- mujoco/introspect/functions_test.py +68 -0
- mujoco/introspect/mjxmacro.py +43 -0
- mujoco/introspect/structs.py +12639 -0
- mujoco/introspect/structs_test.py +129 -0
- mujoco/introspect/type_parsing.py +154 -0
- mujoco/introspect/type_parsing_test.py +58 -0
- mujoco/memory_leak_test.py +70 -0
- mujoco/minimize.py +609 -0
- mujoco/minimize_test.py +464 -0
- mujoco/msh2obj.py +111 -0
- mujoco/msh2obj_test.py +80 -0
- mujoco/mujoco.dll +0 -0
- mujoco/osmesa/__init__.py +81 -0
- mujoco/plugin/actuator.dll +0 -0
- mujoco/plugin/elasticity.dll +0 -0
- mujoco/plugin/sdf_plugin.dll +0 -0
- mujoco/plugin/sensor.dll +0 -0
- mujoco/render_test.py +172 -0
- mujoco/renderer.py +21 -0
- mujoco/renderer_test.py +213 -0
- mujoco/rendering/classic/__init__.py +16 -0
- mujoco/rendering/classic/gl_context.py +48 -0
- mujoco/rendering/classic/renderer.py +343 -0
- mujoco/rendering/filament/renderer.py +282 -0
- mujoco/rollout.py +433 -0
- mujoco/rollout_test.py +1005 -0
- mujoco/specs_test.py +2364 -0
- mujoco/sysid/__init__.py +62 -0
- mujoco/sysid/_src/__init__.py +15 -0
- mujoco/sysid/_src/io.py +81 -0
- mujoco/sysid/_src/model_modifier.py +598 -0
- mujoco/sysid/_src/optimize.py +363 -0
- mujoco/sysid/_src/parameter.py +700 -0
- mujoco/sysid/_src/plotting.py +114 -0
- mujoco/sysid/_src/residual.py +449 -0
- mujoco/sysid/_src/signal_modifier.py +325 -0
- mujoco/sysid/_src/signal_transform.py +301 -0
- mujoco/sysid/_src/timeseries.py +816 -0
- mujoco/sysid/_src/trajectory.py +659 -0
- mujoco/sysid/py.typed +0 -0
- mujoco/sysid/report/builder.py +122 -0
- mujoco/sysid/report/defaults.py +291 -0
- mujoco/sysid/report/sections/__init__.py +15 -0
- mujoco/sysid/report/sections/base.py +63 -0
- mujoco/sysid/report/sections/covariance.py +177 -0
- mujoco/sysid/report/sections/group.py +59 -0
- mujoco/sysid/report/sections/insights.py +113 -0
- mujoco/sysid/report/sections/optimization_trace.py +471 -0
- mujoco/sysid/report/sections/parameter_distribution.py +428 -0
- mujoco/sysid/report/sections/parameters.py +240 -0
- mujoco/sysid/report/sections/row.py +63 -0
- mujoco/sysid/report/sections/signals.py +231 -0
- mujoco/sysid/report/sections/video.py +216 -0
- mujoco/sysid/report/templates/covariance.html +204 -0
- mujoco/sysid/report/templates/group.html +13 -0
- mujoco/sysid/report/templates/insights.html +90 -0
- mujoco/sysid/report/templates/layout.html +699 -0
- mujoco/sysid/report/templates/optimization_trace.html +20 -0
- mujoco/sysid/report/templates/parameter_confidence.html +3 -0
- mujoco/sysid/report/templates/parameters_table.html +147 -0
- mujoco/sysid/report/templates/plot_generic.html +8 -0
- mujoco/sysid/report/templates/row.html +13 -0
- mujoco/sysid/report/templates/signals.html +3 -0
- mujoco/sysid/report/templates/video.html +11 -0
- mujoco/sysid/report/utils.py +61 -0
- mujoco/sysid/tests/__init__.py +15 -0
- mujoco/sysid/tests/conftest.py +230 -0
- mujoco/sysid/tests/test_integration.py +276 -0
- mujoco/sysid/tests/test_model_modifier.py +131 -0
- mujoco/sysid/tests/test_parameter.py +183 -0
- mujoco/sysid/tests/test_signal.py +391 -0
- mujoco/sysid/tests/test_timeseries.py +453 -0
- mujoco/sysid/tests/test_trajectory.py +204 -0
- mujoco/testdata/MJCF_NoRoot.zip +0 -0
- mujoco/testdata/MJCF_Root.zip +0 -0
- mujoco/testdata/abdomen_1_body.msh +0 -0
- mujoco/testdata/model.urdf +4 -0
- mujoco/testdata/model.xml +178 -0
- mujoco/testdata/msh.xml +5 -0
- mujoco/testdata/simple_usd_preview_surface.usda +81 -0
- mujoco/testdata/usd_golden.usda +89 -0
- mujoco/thread_safety_test.py +208 -0
- mujoco/usd/camera.py +55 -0
- mujoco/usd/demo.py +96 -0
- mujoco/usd/exporter.py +529 -0
- mujoco/usd/exporter_test.py +74 -0
- mujoco/usd/lights.py +83 -0
- mujoco/usd/objects.py +552 -0
- mujoco/usd/shapes.py +440 -0
- mujoco/usd/utils.py +28 -0
- mujoco/vfs_test.py +251 -0
- mujoco/viewer.py +620 -0
- mujoco/viewer_test.py +28 -0
- mujoco-3.13.0.dist-info/METADATA +4798 -0
- mujoco-3.13.0.dist-info/RECORD +257 -0
- mujoco-3.13.0.dist-info/WHEEL +5 -0
- mujoco-3.13.0.dist-info/licenses/LICENSE +202 -0
- mujoco-3.13.0.dist-info/licenses/LICENSES_THIRD_PARTY.md +4675 -0
- mujoco-3.13.0.dist-info/top_level.txt +1 -0
mujoco/__init__.py
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Copyright 2022 DeepMind Technologies Limited
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""Python bindings for MuJoCo."""
|
|
16
|
+
|
|
17
|
+
import ctypes
|
|
18
|
+
import ctypes.util
|
|
19
|
+
import os
|
|
20
|
+
import platform
|
|
21
|
+
import subprocess
|
|
22
|
+
from typing import Any, IO, Union, Sequence
|
|
23
|
+
from typing_extensions import TypeAlias
|
|
24
|
+
import warnings
|
|
25
|
+
import zipfile
|
|
26
|
+
|
|
27
|
+
# Extend the path to enable multiple directories to contribute to the same
|
|
28
|
+
# package. Without this line, the `mujoco-mjx` package would not be able to
|
|
29
|
+
# be discovered by import. For more information, see: https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages
|
|
30
|
+
# NOTE: As per the Python Packaging User Guide linked above, the preferable way
|
|
31
|
+
# of declaring the namespace package is to use the native namespace packages.
|
|
32
|
+
# This seems non-trivial at the current state of the project, however.
|
|
33
|
+
# For more information, see: https://github.com/google-deepmind/mujoco/issues/2119
|
|
34
|
+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
|
35
|
+
|
|
36
|
+
_SYSTEM = platform.system()
|
|
37
|
+
if _SYSTEM == 'Windows':
|
|
38
|
+
ctypes.WinDLL(os.path.join(os.path.dirname(__file__), 'mujoco.dll'))
|
|
39
|
+
elif _SYSTEM == 'Darwin':
|
|
40
|
+
proc_translated = subprocess.run(
|
|
41
|
+
['sysctl', '-n', 'sysctl.proc_translated'], capture_output=True).stdout
|
|
42
|
+
try:
|
|
43
|
+
is_rosetta = bool(int(proc_translated))
|
|
44
|
+
except ValueError:
|
|
45
|
+
is_rosetta = False
|
|
46
|
+
if is_rosetta and platform.machine() == 'x86_64':
|
|
47
|
+
raise ImportError(
|
|
48
|
+
'You are running an x86_64 build of Python on an Apple Silicon '
|
|
49
|
+
'machine. This is not supported by MuJoCo. Please install and run a '
|
|
50
|
+
'native, arm64 build of Python.')
|
|
51
|
+
|
|
52
|
+
from mujoco import _specs
|
|
53
|
+
from mujoco import _structs
|
|
54
|
+
from mujoco._callbacks import *
|
|
55
|
+
from mujoco._constants import *
|
|
56
|
+
from mujoco._enums import *
|
|
57
|
+
from mujoco._errors import *
|
|
58
|
+
from mujoco._functions import *
|
|
59
|
+
from mujoco._specs import *
|
|
60
|
+
from mujoco._structs import *
|
|
61
|
+
|
|
62
|
+
import numpy as np
|
|
63
|
+
MJTNUM_DTYPE = np.float32 if MJTNUM_BYTES == 4 else np.float64 # pylint: disable=undefined-variable
|
|
64
|
+
|
|
65
|
+
try:
|
|
66
|
+
from mujoco._render import * # pytype: disable=import-error
|
|
67
|
+
except ImportError:
|
|
68
|
+
pass
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
from mujoco.rendering.classic.renderer import Renderer # pytype: disable=import-error
|
|
72
|
+
except ImportError:
|
|
73
|
+
pass
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
from mujoco.rendering.classic.gl_context import * # pytype: disable=import-error
|
|
77
|
+
except ImportError:
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
MjStruct: TypeAlias = Union[
|
|
81
|
+
_specs.MjsBody,
|
|
82
|
+
_specs.MjsFrame,
|
|
83
|
+
_specs.MjsGeom,
|
|
84
|
+
_specs.MjsJoint,
|
|
85
|
+
_specs.MjsLight,
|
|
86
|
+
_specs.MjsMaterial,
|
|
87
|
+
_specs.MjsSite,
|
|
88
|
+
_specs.MjsMesh,
|
|
89
|
+
_specs.MjsSkin,
|
|
90
|
+
_specs.MjsTexture,
|
|
91
|
+
_specs.MjsText,
|
|
92
|
+
_specs.MjsTuple,
|
|
93
|
+
_specs.MjsCamera,
|
|
94
|
+
_specs.MjsFlex,
|
|
95
|
+
_specs.MjsHField,
|
|
96
|
+
_specs.MjsKey,
|
|
97
|
+
_specs.MjsNumeric,
|
|
98
|
+
_specs.MjsPair,
|
|
99
|
+
_specs.MjsExclude,
|
|
100
|
+
_specs.MjsEquality,
|
|
101
|
+
_specs.MjsTendon,
|
|
102
|
+
_specs.MjsSensor,
|
|
103
|
+
_specs.MjsActuator,
|
|
104
|
+
_specs.MjsPlugin,
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def to_zip(spec: _specs.MjSpec, file: Union[str, IO[bytes]]) -> None:
|
|
109
|
+
"""Converts an MjSpec to a zip file.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
spec: The mjSpec to save to a file.
|
|
113
|
+
file: The path to the file to save to or the file object to write to.
|
|
114
|
+
"""
|
|
115
|
+
files_to_zip = spec.assets
|
|
116
|
+
files_to_zip[spec.modelname + '.xml'] = spec.to_xml()
|
|
117
|
+
if isinstance(file, str):
|
|
118
|
+
directory = os.path.dirname(file)
|
|
119
|
+
os.makedirs(directory, exist_ok=True)
|
|
120
|
+
file = open(file, 'wb')
|
|
121
|
+
with zipfile.ZipFile(file, 'w') as zip_file:
|
|
122
|
+
for filename, contents in files_to_zip.items():
|
|
123
|
+
zip_info = zipfile.ZipInfo(filename)
|
|
124
|
+
zip_file.writestr(zip_info, contents)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def from_zip(file: Union[str, IO[bytes]]) -> _specs.MjSpec:
|
|
128
|
+
"""Reads a zip file and returns an MjSpec.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
file: The path to the file to read from or the file object to read from.
|
|
132
|
+
Returns:
|
|
133
|
+
An MjSpec object.
|
|
134
|
+
"""
|
|
135
|
+
assets = {}
|
|
136
|
+
xml_string = None
|
|
137
|
+
if isinstance(file, str):
|
|
138
|
+
file = open(file, 'rb')
|
|
139
|
+
if not zipfile.is_zipfile(file):
|
|
140
|
+
raise ValueError(f'File {file} is not a zip file.')
|
|
141
|
+
with zipfile.ZipFile(file, 'r') as zip_file:
|
|
142
|
+
xml_dir = None
|
|
143
|
+
for zip_info in zip_file.infolist():
|
|
144
|
+
if not zip_info.filename.endswith(os.path.sep):
|
|
145
|
+
with zip_file.open(zip_info.filename) as f:
|
|
146
|
+
if zip_info.filename.endswith('.xml'):
|
|
147
|
+
xml_string = f.read()
|
|
148
|
+
xml_dir = os.path.dirname(zip_info.filename)
|
|
149
|
+
else:
|
|
150
|
+
assets[zip_info.filename] = f.read()
|
|
151
|
+
|
|
152
|
+
if not xml_string:
|
|
153
|
+
raise ValueError('No XML file found in zip file.')
|
|
154
|
+
|
|
155
|
+
relative_assets = {}
|
|
156
|
+
for key, value in assets.items():
|
|
157
|
+
new_key = os.path.relpath(key, xml_dir)
|
|
158
|
+
relative_assets[new_key] = value
|
|
159
|
+
assets = relative_assets
|
|
160
|
+
|
|
161
|
+
return _specs.MjSpec.from_string(xml_string, assets=assets)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class _MjBindModel:
|
|
165
|
+
"""Wrapper for MjModel that allows binding multiple specs."""
|
|
166
|
+
|
|
167
|
+
def __init__(self, elements: Sequence[Any]):
|
|
168
|
+
object.__setattr__(self, 'elements', elements)
|
|
169
|
+
|
|
170
|
+
def __getattr__(self, key: str):
|
|
171
|
+
items = []
|
|
172
|
+
for e in self.elements:
|
|
173
|
+
items.extend(getattr(e, key))
|
|
174
|
+
return items
|
|
175
|
+
|
|
176
|
+
def __setattr__(self, key: str, value: Any):
|
|
177
|
+
raise AttributeError(f'Cannot set {key} on MjModel.')
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class _MjBindData:
|
|
181
|
+
"""Wrapper for MjData that allows binding multiple specs."""
|
|
182
|
+
|
|
183
|
+
def __init__(self, elements: Sequence[Any]):
|
|
184
|
+
object.__setattr__(self, 'elements', elements)
|
|
185
|
+
|
|
186
|
+
def __getattr__(self, key: str):
|
|
187
|
+
items = []
|
|
188
|
+
for e in self.elements:
|
|
189
|
+
items.extend(getattr(e, key))
|
|
190
|
+
return items
|
|
191
|
+
|
|
192
|
+
def __setattr__(self, key: str, value: Any):
|
|
193
|
+
value_it = iter(value)
|
|
194
|
+
for element in self.elements:
|
|
195
|
+
setattr(element, key, next(value_it))
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def _bind_model(
|
|
199
|
+
model: _structs.MjModel, specs: Union[Sequence[MjStruct], MjStruct]
|
|
200
|
+
):
|
|
201
|
+
"""Bind a Mujoco spec to a mjModel.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
model: The mjModel to bind to.
|
|
205
|
+
specs: The mjSpec elements to use for binding, can be a single element or a
|
|
206
|
+
sequence.
|
|
207
|
+
Returns:
|
|
208
|
+
A MjModelGroupedViews object or a list of the same type.
|
|
209
|
+
"""
|
|
210
|
+
if isinstance(specs, Sequence):
|
|
211
|
+
return _MjBindModel([model.bind_scalar(s) for s in specs])
|
|
212
|
+
else:
|
|
213
|
+
return model.bind_scalar(specs)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def _bind_data(
|
|
217
|
+
data: _structs.MjData, specs: Union[Sequence[MjStruct], MjStruct]
|
|
218
|
+
):
|
|
219
|
+
"""Bind a Mujoco spec to a mjData.
|
|
220
|
+
|
|
221
|
+
Args:
|
|
222
|
+
data: The mjData to bind to.
|
|
223
|
+
specs: The mjSpec elements to use for binding, can be a single element or a
|
|
224
|
+
sequence.
|
|
225
|
+
Returns:
|
|
226
|
+
A MjDataGroupedViews object or a list of the same type.
|
|
227
|
+
"""
|
|
228
|
+
if isinstance(specs, Sequence):
|
|
229
|
+
return _MjBindData([data.bind_scalar(s) for s in specs])
|
|
230
|
+
else:
|
|
231
|
+
return data.bind_scalar(specs)
|
|
232
|
+
|
|
233
|
+
_specs.MjSpec.from_zip = from_zip
|
|
234
|
+
_specs.MjSpec.to_zip = to_zip
|
|
235
|
+
_structs.MjData.bind = _bind_data # pyrefly: ignore[bad-assignment]
|
|
236
|
+
_structs.MjModel.bind = _bind_model # pyrefly: ignore[bad-assignment]
|
|
237
|
+
|
|
238
|
+
HEADERS_DIR = os.path.join(os.path.dirname(__file__), 'include/mujoco')
|
|
239
|
+
PLUGINS_DIR = os.path.join(os.path.dirname(__file__), 'plugin')
|
|
240
|
+
|
|
241
|
+
PLUGIN_HANDLES = []
|
|
242
|
+
|
|
243
|
+
def _load_all_bundled_plugins():
|
|
244
|
+
for directory, _, filenames in os.walk(PLUGINS_DIR):
|
|
245
|
+
for filename in filenames:
|
|
246
|
+
if os.path.splitext(filename)[-1] in [".dll", ".dylib", ".so"]:
|
|
247
|
+
PLUGIN_HANDLES.append(ctypes.CDLL(os.path.join(directory, filename)))
|
|
248
|
+
elif filename == "__init__.py":
|
|
249
|
+
pass
|
|
250
|
+
else:
|
|
251
|
+
warnings.warn('Ignoring non-library in plugin directory: '
|
|
252
|
+
f'{os.path.join(directory, filename)}', ImportWarning)
|
|
253
|
+
|
|
254
|
+
_load_all_bundled_plugins()
|
|
255
|
+
|
|
256
|
+
__version__ = mj_versionString() # pylint: disable=undefined-variable
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|