add chinese
build / setup (compute matrix) (push) Has been cancelled
build / ${{ matrix.label }} (push) Has been cancelled
build / macos-15-arm64-studio (push) Has been cancelled
build / ubuntu-24.04-clang-18-studio (push) Has been cancelled
build / ubuntu-24.04-gcc-14-studio (push) Has been cancelled
build / windows-2025-ninja-studio (push) Has been cancelled
build / ubuntu-24.04-clang-18-wasm (push) Has been cancelled
build / ubuntu-24.04-clang-18-mjx (push) Has been cancelled
build / setup (compute matrix) (push) Has been cancelled
build / ${{ matrix.label }} (push) Has been cancelled
build / macos-15-arm64-studio (push) Has been cancelled
build / ubuntu-24.04-clang-18-studio (push) Has been cancelled
build / ubuntu-24.04-gcc-14-studio (push) Has been cancelled
build / windows-2025-ninja-studio (push) Has been cancelled
build / ubuntu-24.04-clang-18-wasm (push) Has been cancelled
build / ubuntu-24.04-clang-18-mjx (push) Has been cancelled
This commit is contained in:
+18
-42
@@ -1,4 +1,4 @@
|
||||
# MuJoCo Python Bindings
|
||||
# MuJoCo Python 绑定
|
||||
|
||||
[![PyPI Python Version][pypi-versions-badge]][pypi]
|
||||
[![PyPI version][pypi-badge]][pypi]
|
||||
@@ -7,67 +7,43 @@
|
||||
[pypi-badge]: https://badge.fury.io/py/mujoco.svg
|
||||
[pypi]: https://pypi.org/project/mujoco/
|
||||
|
||||
This package is the canonical Python bindings for the
|
||||
[MuJoCo physics engine](https://github.com/google-deepmind/mujoco).
|
||||
These bindings are developed and maintained by Google DeepMind, and is kept
|
||||
up-to-date with the latest developments in MuJoCo itself.
|
||||
本软件包是 [MuJoCo 物理引擎](https://github.com/google-deepmind/mujoco) 的官方规范 Python 绑定。这些绑定由 Google DeepMind 开发和维护,并与 MuJoCo 本身的最新进展保持同步。
|
||||
|
||||
The `mujoco` package provides direct access to raw MuJoCo C API functions,
|
||||
structs, constants, and enumerations. Structs are provided as Python classes,
|
||||
with Pythonic initialization and deletion semantics.
|
||||
`mujoco` 软件包提供了对底层 MuJoCo C API 函数、结构体、常量和枚举的直接访问。结构体以 Python 类的形式提供,具有符合 Python 习惯的对象初始化和销毁语义。
|
||||
|
||||
It is not the aim of this package to provide fully fledged
|
||||
scene/environment/game authoring API, as there are already a number of existing
|
||||
packages that do this well. However, this package does provide a number of
|
||||
lower-level components outside of MuJoCo itself that are likely to be useful to
|
||||
most users who access MuJoCo through Python. For example, the `egl`, `glfw`, and
|
||||
`osmesa` subpackages contain utilities for setting up OpenGL rendering contexts.
|
||||
本软件包的目的并不是提供功能完备的场景/环境/游戏创作 API,因为已有许多优秀的现有软件包做到了这一点。不过,本软件包确实提供了 MuJoCo 本身之外的一些底层组件,这些组件对大多数通过 Python 访问 MuJoCo 的用户很有用。例如,`egl`、`glfw` 和 `osmesa` 子包包含了用于设置 OpenGL 渲染上下文的实用工具。
|
||||
|
||||
## Installation
|
||||
## 安装
|
||||
|
||||
The recommended way to install this package is via [PyPI](https://pypi.org/project/mujoco/):
|
||||
推荐通过 [PyPI](https://pypi.org/project/mujoco/) 安装本软件包:
|
||||
|
||||
```sh
|
||||
pip install mujoco
|
||||
```
|
||||
|
||||
A copy of the MuJoCo library is provided as part of the package and does **not**
|
||||
need to be downloaded or installed separately.
|
||||
MuJoCo 库的副本已作为软件包的一部分提供,**无需**单独下载或安装。
|
||||
|
||||
### Source
|
||||
### 源码编译
|
||||
|
||||
**IMPORTANT:** Building from source is only necessary if you are modifying the
|
||||
Python bindings (or are trying to run on exceptionally old Linux systems).
|
||||
If that's not the case, then we recommend installing the prebuilt binaries from
|
||||
PyPI.
|
||||
**重要提示:** 仅当您需要修改 Python 绑定(或尝试在特别老旧的 Linux 系统上运行)时,才需要从源码构建。若非此类情况,我们建议直接安装来自 PyPI 的预编译二进制包。
|
||||
|
||||
If you need to build the Python bindings from source, please consult
|
||||
[the documentation](https://mujoco.readthedocs.io/en/latest/python.html#building-from-source).
|
||||
如果您需要从源码构建 Python 绑定,请查阅[官方文档](https://mujoco.readthedocs.io/en/latest/python.html#building-from-source)。
|
||||
|
||||
## Usage
|
||||
## 使用说明
|
||||
|
||||
Once installed, the package can be imported via `import mujoco`. Please consult
|
||||
our [documentation](https://mujoco.readthedocs.io/en/stable/python.html) for
|
||||
further detail on the package's API.
|
||||
安装完成后,可以通过 `import mujoco` 导入该包。有关该包 API 的更多详细信息,请参阅我们的[官方文档](https://mujoco.readthedocs.io/en/stable/python.html)。
|
||||
|
||||
We recommend going through the tutorial notebook which covers the basics of
|
||||
MuJoCo using Python:
|
||||
我们建议阅读教程 Notebook,其中介绍了使用 Python 操作 MuJoCo 的基础知识:
|
||||
[](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/tutorial.ipynb)
|
||||
|
||||
## Versioning
|
||||
## 版本规范
|
||||
|
||||
The `major.minor.micro` portion of the version number matches the version of
|
||||
MuJoCo that the bindings provide. Optionally, if we release updates to the
|
||||
Python bindings themselves that target the same version of MuJoCo, a `.postN`
|
||||
suffix is added, for example `2.1.2.post2` represents the second update to the
|
||||
bindings for MuJoCo 2.1.2.
|
||||
版本号的 `major.minor.micro` 部分与绑定所对应的 MuJoCo 版本完全一致。可选地,如果我们针对同一版本的 MuJoCo 发布了 Python 绑定自身的更新,则会添加 `.postN` 后缀,例如 `2.1.2.post2` 表示针对 MuJoCo 2.1.2 的绑定的第二次更新。
|
||||
|
||||
## License and Disclaimer
|
||||
## 开源许可证与免责声明
|
||||
|
||||
Copyright 2022 DeepMind Technologies Limited
|
||||
|
||||
MuJoCo and its Python bindings are licensed under the Apache License,
|
||||
Version 2.0. You may obtain a copy of the License at
|
||||
https://www.apache.org/licenses/LICENSE-2.0.
|
||||
MuJoCo 及其 Python 绑定基于 Apache 许可证 2.0 版(Apache License, Version 2.0)授权。您可在 https://www.apache.org/licenses/LICENSE-2.0 获取许可证副本。
|
||||
|
||||
This is not an officially supported Google product.
|
||||
本项目不是 Google 官方支持的产品。
|
||||
|
||||
@@ -1,73 +1,55 @@
|
||||
# System Identification Toolbox
|
||||
# 系统辨识工具箱(System Identification Toolbox)
|
||||
|
||||
[](https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/mujoco/sysid/sysid.ipynb)
|
||||
|
||||
Given a MuJoCo model and recorded sensor data, find parameters
|
||||
that make simulation match reality. By default, the library uses
|
||||
nonlinear least-squares with box constraints to minimize the difference
|
||||
between measured and simulated (predicted) outputs. Residuals
|
||||
can be modified by static or optimized parameters, such as
|
||||
weights and time-delays.
|
||||
给定 MuJoCo 模型和采集到的传感器数据,寻找能够使仿真结果与真实物理系统相吻合的模型参数。默认情况下,该库使用带有边界约束(box constraints)的非线性最小二乘法来最小化测量输出与仿真(预测)输出之间的差异。残差可以通过静态或待优化的参数(例如权重和时间延迟)进行调整。
|
||||
|
||||
The optimizer uses Gauss-Newton with finite-difference Jacobians. Each
|
||||
parameter perturbation requires an independent simulation rollout. All
|
||||
of them execute in a single batched call to `mujoco.rollout`, parallelized
|
||||
across threads.
|
||||
优化器采用基于有限差分雅可比矩阵的高斯-牛顿法(Gauss-Newton)。每次参数摄动都需要一次独立的仿真 rollout(推演)。所有 rollout 均在对 `mujoco.rollout` 的单次批处理调用中跨多线程并行执行。
|
||||
|
||||
## Pipeline
|
||||
## 工作流程(Pipeline)
|
||||
|
||||
**You provide:**
|
||||
- One or more `ModelSequences` each bundling a single `MjSpec` with one or
|
||||
more sequences of measured data. All will be optimized jointly.
|
||||
- A `ParameterDict` defining differentiable `Parameter`s with bounds.
|
||||
- Callbacks to apply `Parameter`s to an `MjSpec` (individually or jointly)
|
||||
- (optional) Functions (`build_model`, `custom_rollout`, `modify_residual`)
|
||||
that override the default residual function behavior.
|
||||
**用户提供:**
|
||||
- 一个或多个 `ModelSequences`,每个序列将单个 `MjSpec` 与一个或多个测量数据序列打包在一起。所有序列将被联合优化。
|
||||
- 一个 `ParameterDict`,用于定义带有上下界的可微参数 `Parameter`。
|
||||
- 用于将 `Parameter` 应用到 `MjSpec` 上的回调函数(可单独或联合应用)。
|
||||
- (可选)用于覆盖默认残差函数行为的自定义函数(`build_model`、`custom_rollout`、`modify_residual`)。
|
||||
|
||||
**The framework:**
|
||||
- Composes user code into a residual function (`build_residual_fn`).
|
||||
- Optimizes parameters via batched parallel rollouts (`optimize`).
|
||||
- Saves results and generates an HTML report (`save_results`, `default_report`).
|
||||
**框架执行:**
|
||||
- 将用户代码组合为残差函数(`build_residual_fn`)。
|
||||
- 通过批量并行 rollout 优化参数(`optimize`)。
|
||||
- 保存结果并生成交互式 HTML 报告(`save_results`、`default_report`)。
|
||||
|
||||
## What Can You Identify?
|
||||
## 可以辨识哪些参数?
|
||||
|
||||
You can optimize any parameter that differentiably modifies the final
|
||||
residuals. Common use cases include:
|
||||
您可以优化任何能够以可微方式修改最终残差的参数。常见用例包括:
|
||||
|
||||
**Physics parameters** settable on `MjSpec`. Most parameters in MjSpec
|
||||
can be easily set directly by user-provided callbacks:
|
||||
在 `MjSpec` 上可设置的**物理参数**。MjSpec 中的大多数参数可以通过用户提供的回调函数直接轻松设置:
|
||||
|
||||
| Target | Approach |
|
||||
| 辨识目标 | 对应方法 |
|
||||
|---|---|
|
||||
| Contact sliding friction | `spec.pair("cp").friction[0] = p.value[0]` |
|
||||
| Joint damping | `spec.joint("j1").damping = p.value[0]` |
|
||||
| 接触滑动摩擦力 | `spec.pair("cp").friction[0] = p.value[0]` |
|
||||
| 关节阻尼 | `spec.joint("j1").damping = p.value[0]` |
|
||||
|
||||
Convenience functions are provided for common system identification
|
||||
parameterizations that cannot be trivially applied to an MjSpec:
|
||||
对于无法直接简单应用到 MjSpec 的常见系统辨识参数化方式,该库提供了便捷函数:
|
||||
|
||||
| Target | Approach |
|
||||
| 辨识目标 | 对应方法 |
|
||||
|---|---|
|
||||
| Body mass | `body_inertia_param(..., InertiaType.Mass)` |
|
||||
| Body mass + center of mass | `body_inertia_param(..., InertiaType.MassIpos)` |
|
||||
| Full inertia (10-D) | `body_inertia_param(..., InertiaType.Pseudo)` |
|
||||
| Actuator P/D gains | `apply_pdgain(spec, "act1", p.value)` |
|
||||
| 刚体质量 | `body_inertia_param(..., InertiaType.Mass)` |
|
||||
| 刚体质量 + 质心位置 | `body_inertia_param(..., InertiaType.MassIpos)` |
|
||||
| 完整惯量(10 维) | `body_inertia_param(..., InertiaType.Pseudo)` |
|
||||
| 执行器 P/D 增益 | `apply_pdgain(spec, "act1", p.value)` |
|
||||
|
||||
Full inertia uses the pseudo-inertia Cholesky parameterization
|
||||
([Rucker & Wensing 2022](https://ieeexplore.ieee.org/document/9690029)),
|
||||
guaranteeing physical consistency without singularities.
|
||||
完整惯量采用伪惯量 Cholesky 参数化(Pseudo-inertia Cholesky Parameterization,[Rucker & Wensing 2022](https://ieeexplore.ieee.org/document/9690029)),保证物理一致性且不存在奇异点。
|
||||
|
||||
**Measurement parameters** such as sensor delays, gains, and biases are
|
||||
properties of the measurement system, not the physics model. The library
|
||||
provides utilities for applying these corrections to the residual after
|
||||
rollout. They are functionally complete but their API is not yet final.
|
||||
诸如传感器延迟、增益和偏差等**测量参数**属于测量系统的属性,而非物理模型本身的属性。该库提供了在 rollout 之后将这些校正应用于残差的实用工具。这些功能已完备,但其 API 尚未最终定型。
|
||||
|
||||
## Example
|
||||
## 示例
|
||||
|
||||
```python
|
||||
import mujoco
|
||||
from mujoco import sysid
|
||||
|
||||
# 1. Load model and define parameters.
|
||||
# 1. 加载模型并定义待辨识参数。
|
||||
spec = mujoco.MjSpec.from_file("robot.xml")
|
||||
model = spec.compile()
|
||||
|
||||
@@ -79,18 +61,17 @@ params.add(sysid.Parameter(
|
||||
"link1_mass", nominal=2.0, min_value=0.5, max_value=5.0,
|
||||
modifier=set_link1_mass))
|
||||
|
||||
# 2. Load and package measured data.
|
||||
# arrays assumed to be in MuJoCo order, otherwise pass names argument
|
||||
# 2. 加载并封装实测数据。
|
||||
# 数组默认采用 MuJoCo 顺序,否则请传入 names 参数
|
||||
control = sysid.TimeSeries.from_control_names(times, ctrl_array, model)
|
||||
measureddata = sysid.TimeSeries.from_names(times, measurement_array, model)
|
||||
initial_state = sysid.create_initial_state(model, qpos_0, qvel_0)
|
||||
ms = sysid.ModelSequences("robot", spec, "traj_1", initial_state, control, measureddata)
|
||||
|
||||
# 3. Build residual, optimize, save.
|
||||
# 3. 构建残差函数、执行优化并保存结果。
|
||||
residual_fn = sysid.build_residual_fn(models_sequences=[ms])
|
||||
opt_params, opt_result = sysid.optimize(initial_params=params, residual_fn=residual_fn)
|
||||
sysid.save_results("results/", [ms], params, opt_params, opt_result, residual_fn)
|
||||
```
|
||||
|
||||
`default_report` generates an interactive HTML report with videos, measurement comparisons,
|
||||
parameter tables, and confidence intervals.
|
||||
`default_report` 可生成包含视频、测量对比图、参数表格以及置信区间的交互式 HTML 报告。
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# USD exporter module
|
||||
# USD 导出器模块
|
||||
|
||||
Please see [documentation](https://mujoco.readthedocs.io/en/stable/python.html) for details.
|
||||
详情请参阅[官方文档](https://mujoco.readthedocs.io/en/stable/python.html)。
|
||||
|
||||
Reference in New Issue
Block a user