Humanoid Standup¶

此环境是 Mujoco 环境的一部分,其中包含有关环境的通用信息。
Action Space |
|
Observation Space |
|
import |
|
Description¶
此环境基于 Tassa、Erez 和 Todorov 在 “通过在线轨迹优化合成和稳定复杂行为” 中介绍的环境。3D 双足机器人旨在模拟人类。它有一个躯干(腹部),带有一对腿和手臂,以及一对将髋部连接到膝盖的肌腱。腿部各由三个身体部分(大腿、小腿、脚)组成,手臂由两个身体部分(上臂、前臂)组成。环境从人形机器人躺在地面上开始,然后环境的目标是让人形机器人站起来,然后通过对各种铰链施加扭矩来保持站立。
Action Space¶

动作空间是 Box(-0.4, 0.4, (17,), float32)
。动作表示在铰链关节处施加的扭矩。
Num |
Action |
Control Min |
Control Max |
Name (在相应的 XML 文件中) |
Joint |
Type (单位) |
---|---|---|---|---|---|---|
0 |
施加在腹部 y 坐标铰链上的扭矩 |
-0.4 |
0.4 |
abdomen_y |
hinge |
torque (N m) |
1 |
施加在腹部 z 坐标铰链上的扭矩 |
-0.4 |
0.4 |
abdomen_z |
hinge |
torque (N m) |
2 |
施加在腹部 x 坐标铰链上的扭矩 |
-0.4 |
0.4 |
abdomen_x |
hinge |
torque (N m) |
3 |
施加在躯干/腹部和右髋部(x 坐标)之间转子上的扭矩 |
-0.4 |
0.4 |
right_hip_x (right_thigh) |
hinge |
torque (N m) |
4 |
施加在躯干/腹部和右髋部(z 坐标)之间转子上的扭矩 |
-0.4 |
0.4 |
right_hip_z (right_thigh) |
hinge |
torque (N m) |
5 |
施加在躯干/腹部和右髋部(y 坐标)之间转子上的扭矩 |
-0.4 |
0.4 |
right_hip_y (right_thigh) |
hinge |
torque (N m) |
6 |
施加在右髋部/大腿和右小腿之间转子上的扭矩 |
-0.4 |
0.4 |
right_knee |
hinge |
torque (N m) |
7 |
施加在躯干/腹部和左髋部(x 坐标)之间转子上的扭矩 |
-0.4 |
0.4 |
left_hip_x (left_thigh) |
hinge |
torque (N m) |
8 |
施加在躯干/腹部和左髋部(z 坐标)之间转子上的扭矩 |
-0.4 |
0.4 |
left_hip_z (left_thigh) |
hinge |
torque (N m) |
9 |
施加在躯干/腹部和左髋部(y 坐标)之间转子上的扭矩 |
-0.4 |
0.4 |
left_hip_y (left_thigh) |
hinge |
torque (N m) |
10 |
施加在左髋部/大腿和左小腿之间转子上的扭矩 |
-0.4 |
0.4 |
left_knee |
hinge |
torque (N m) |
11 |
施加在躯干和右上臂(坐标 -1)之间转子上的扭矩 |
-0.4 |
0.4 |
right_shoulder1 |
hinge |
torque (N m) |
12 |
施加在躯干和右上臂(坐标 -2)之间转子上的扭矩 |
-0.4 |
0.4 |
right_shoulder2 |
hinge |
torque (N m) |
13 |
施加在右上臂和右下臂之间转子上的扭矩 |
-0.4 |
0.4 |
right_elbow |
hinge |
torque (N m) |
14 |
施加在躯干和左上臂(坐标 -1)之间转子上的扭矩 |
-0.4 |
0.4 |
left_shoulder1 |
hinge |
torque (N m) |
15 |
施加在躯干和左上臂(坐标 -2)之间转子上的扭矩 |
-0.4 |
0.4 |
left_shoulder2 |
hinge |
torque (N m) |
16 |
施加在左上臂和左下臂之间转子上的扭矩 |
-0.4 |
0.4 |
left_elbow |
hinge |
torque (N m) |
Observation Space¶
观察空间由以下部分组成(按顺序)
qpos (默认 22 个元素): 机器人身体部位的位置值。
qvel (23 个元素): 这些独立身体部位的速度(它们的导数)。
cinert (130 个元素): 刚性身体部位相对于质心的质量和惯性,(这是过渡的中间结果)。它的形状为 13*10 (nbody * 10)。 (cinert - 惯性矩阵和身体质量偏移量和身体质量)
cvel (78 个元素): 基于质心的速度。它的形状为 13 * 6 (nbody * 6)。 (质心速度 - 速度 x、y、z 和角速度 x、y、z)
qfrc_actuator (17 个元素): 在每个关节处作为执行器力生成的约束力。它的形状为
(17,)
(nv * 1)。cfrc_ext (78 个元素): 这是基于质心的身体部位上的外力。它的形状为 13 * 6 (nbody * 6),因此为观察空间添加了另外 78 个元素。 (外力 - 力 x、y、z 和扭矩 x、y、z)
其中 nbody 是机器人中的身体数量,nv 是自由度数 (= dim(qvel))。
默认情况下,观察不包括躯干的 x 和 y 坐标。可以通过在构造期间传递 exclude_current_positions_from_observation=False
来包含这些坐标。在这种情况下,观察空间将是 Box(-Inf, Inf, (350,), float64)
,其中前两个观察是躯干的 x 和 y 坐标。无论 exclude_current_positions_from_observation
设置为 True
还是 False
,x 和 y 坐标都会在 info
中返回,键分别为 "x_position"
和 "y_position"
。
但是,默认情况下,观察空间是 Box(-Inf, Inf, (348,), float64)
,其中位置和速度元素如下
Num |
观察 |
最小值 |
最大值 |
Name (在相应的 XML 文件中) |
Joint |
Type (单位) |
---|---|---|---|---|---|---|
0 |
躯干(中心)的 z 坐标 |
-Inf |
Inf |
root |
free |
position (m) |
1 |
躯干(中心)的 w 方向 |
-Inf |
Inf |
root |
free |
angle (rad) |
2 |
躯干(中心)的 x 方向 |
-Inf |
Inf |
root |
free |
angle (rad) |
3 |
躯干(中心)的 y 方向 |
-Inf |
Inf |
root |
free |
angle (rad) |
4 |
躯干(中心)的 z 方向 |
-Inf |
Inf |
root |
free |
angle (rad) |
5 |
腹部(在 lower_waist 中)的 z 角 |
-Inf |
Inf |
abdomen_z |
hinge |
angle (rad) |
6 |
腹部(在 lower_waist 中)的 y 角 |
-Inf |
Inf |
abdomen_y |
hinge |
angle (rad) |
7 |
腹部(在 pelvis 中)的 x 角 |
-Inf |
Inf |
abdomen_x |
hinge |
angle (rad) |
8 |
骨盆和右髋部之间角度的 x 坐标(在 right_thigh 中) |
-Inf |
Inf |
right_hip_x |
hinge |
angle (rad) |
9 |
骨盆和右髋部之间角度的 z 坐标(在 right_thigh 中) |
-Inf |
Inf |
right_hip_z |
hinge |
angle (rad) |
10 |
骨盆和右髋部之间角度的 y 坐标(在 right_thigh 中) |
-Inf |
Inf |
right_hip_y |
hinge |
angle (rad) |
11 |
右髋部和右小腿之间角度(在 right_knee 中) |
-Inf |
Inf |
right_knee |
hinge |
angle (rad) |
12 |
骨盆和左髋部之间角度的 x 坐标(在 left_thigh 中) |
-Inf |
Inf |
left_hip_x |
hinge |
angle (rad) |
13 |
骨盆和左髋部之间角度的 z 坐标(在 left_thigh 中) |
-Inf |
Inf |
left_hip_z |
hinge |
angle (rad) |
14 |
骨盆和左髋部之间角度的 y 坐标(在 left_thigh 中) |
-Inf |
Inf |
left_hip_y |
hinge |
angle (rad) |
15 |
左髋部和左小腿之间角度(在 left_knee 中) |
-Inf |
Inf |
left_knee |
hinge |
angle (rad) |
16 |
躯干和右臂之间(在 right_upper_arm 中)的坐标-1(多轴)角度 |
-Inf |
Inf |
right_shoulder1 |
hinge |
angle (rad) |
17 |
躯干和右臂之间(在 right_upper_arm 中)的坐标-2(多轴)角度 |
-Inf |
Inf |
right_shoulder2 |
hinge |
angle (rad) |
18 |
右上臂和 right_lower_arm 之间的角度 |
-Inf |
Inf |
right_elbow |
hinge |
angle (rad) |
19 |
躯干和左臂之间(在 left_upper_arm 中)的坐标-1(多轴)角度 |
-Inf |
Inf |
left_shoulder1 |
hinge |
angle (rad) |
20 |
躯干和左臂之间(在 left_upper_arm 中)的坐标-2(多轴)角度 |
-Inf |
Inf |
left_shoulder2 |
hinge |
angle (rad) |
21 |
左上臂和 left_lower_arm 之间的角度 |
-Inf |
Inf |
left_elbow |
hinge |
angle (rad) |
22 |
躯干(中心)的 x 坐标速度 |
-Inf |
Inf |
root |
free |
velocity (m/s) |
23 |
躯干(中心)的 y 坐标速度 |
-Inf |
Inf |
root |
free |
velocity (m/s) |
24 |
躯干(中心)的 z 坐标速度 |
-Inf |
Inf |
root |
free |
velocity (m/s) |
25 |
躯干(中心)的 x 坐标角速度 |
-Inf |
Inf |
root |
free |
angular velocity (rad/s) |
26 |
躯干(中心)的 y 坐标角速度 |
-Inf |
Inf |
root |
free |
angular velocity (rad/s) |
27 |
躯干(中心)的 z 坐标角速度 |
-Inf |
Inf |
root |
free |
angular velocity (rad/s) |
28 |
腹部(在 lower_waist 中)的 z 坐标角速度 |
-Inf |
Inf |
abdomen_z |
hinge |
angular velocity (rad/s) |
29 |
腹部(在 lower_waist 中)的 y 坐标角速度 |
-Inf |
Inf |
abdomen_y |
hinge |
angular velocity (rad/s) |
30 |
腹部(在 pelvis 中)的 x 坐标角速度 |
-Inf |
Inf |
abdomen_x |
hinge |
angular velocity (rad/s) |
31 |
骨盆和右髋部之间角度(在 right_thigh 中)的角速度的 x 坐标 |
-Inf |
Inf |
right_hip_x |
hinge |
angular velocity (rad/s) |
32 |
骨盆和右髋部之间角度(在 right_thigh 中)的角速度的 z 坐标 |
-Inf |
Inf |
right_hip_z |
hinge |
angular velocity (rad/s) |
33 |
骨盆和右髋部之间角度(在 right_thigh 中)的角速度的 y 坐标 |
-Inf |
Inf |
right_hip_y |
hinge |
angular velocity (rad/s) |
34 |
右髋部和右小腿之间角度(在 right_knee 中)的角速度 |
-Inf |
Inf |
right_knee |
hinge |
angular velocity (rad/s) |
35 |
骨盆和左髋部之间角度(在 left_thigh 中)的角速度的 x 坐标 |
-Inf |
Inf |
left_hip_x |
hinge |
angular velocity (rad/s) |
36 |
骨盆和左髋部之间角度(在 left_thigh 中)的角速度的 z 坐标 |
-Inf |
Inf |
left_hip_z |
hinge |
angular velocity (rad/s) |
37 |
骨盆和左髋部之间角度(在 left_thigh 中)的角速度的 y 坐标 |
-Inf |
Inf |
left_hip_y |
hinge |
angular velocity (rad/s) |
38 |
左髋部和左小腿之间角度(在 left_knee 中)的角速度 |
-Inf |
Inf |
left_knee |
hinge |
angular velocity (rad/s) |
39 |
躯干和右臂之间(在 right_upper_arm 中)角度的角速度的坐标-1(多轴) |
-Inf |
Inf |
right_shoulder1 |
hinge |
angular velocity (rad/s) |
40 |
躯干和右臂之间(在 right_upper_arm 中)角度的角速度的坐标-2(多轴) |
-Inf |
Inf |
right_shoulder2 |
hinge |
angular velocity (rad/s) |
41 |
右上臂和 right_lower_arm 之间角度的角速度 |
-Inf |
Inf |
right_elbow |
hinge |
angular velocity (rad/s) |
42 |
躯干和左臂之间(在 left_upper_arm 中)角度的角速度的坐标-1(多轴) |
-Inf |
Inf |
left_shoulder1 |
hinge |
angular velocity (rad/s) |
43 |
躯干和左臂之间(在 left_upper_arm 中)角度的角速度的坐标-2(多轴) |
-Inf |
Inf |
left_shoulder2 |
hinge |
angular velocity (rad/s) |
44 |
左上臂和 left_lower_arm 之间角度的角速度 |
-Inf |
Inf |
left_elbow |
hinge |
angular velocity (rad/s) |
已排除 |
躯干(中心)的 x 坐标 |
-Inf |
Inf |
root |
free |
position (m) |
已排除 |
躯干(中心)的 y 坐标 |
-Inf |
Inf |
root |
free |
position (m) |
身体部位是
身体部位 |
id (对于 |
id (对于 |
---|---|---|
worldbody (注意:所有值均为常数 0) |
0 |
已排除 |
torso |
1 |
0 |
lwaist |
2 |
1 |
pelvis |
3 |
2 |
right_thigh |
4 |
3 |
right_sin |
5 |
4 |
right_foot |
6 |
5 |
left_thigh |
7 |
6 |
left_sin |
8 |
7 |
left_foot |
9 |
8 |
right_upper_arm |
10 |
9 |
right_lower_arm |
11 |
10 |
left_upper_arm |
12 |
11 |
left_lower_arm |
13 |
12 |
关节是
关节 |
id (对于 |
id (对于 |
---|---|---|
root (注意:所有值均为常数 0) |
0 |
已排除 |
root (注意:所有值均为常数 0) |
1 |
已排除 |
root (注意:所有值均为常数 0) |
2 |
已排除 |
root (注意:所有值均为常数 0) |
3 |
已排除 |
root (注意:所有值均为常数 0) |
4 |
已排除 |
root (注意:所有值均为常数 0) |
5 |
已排除 |
abdomen_z |
6 |
0 |
abdomen_y |
7 |
1 |
abdomen_x |
8 |
2 |
right_hip_x |
9 |
3 |
right_hip_z |
10 |
4 |
right_hip_y |
11 |
5 |
right_knee |
12 |
6 |
left_hip_x |
13 |
7 |
left_hiz_z |
14 |
8 |
left_hip_y |
15 |
9 |
left_knee |
16 |
10 |
right_shoulder1 |
17 |
11 |
right_shoulder2 |
18 |
12 |
right_elbow |
19 |
13 |
left_shoulder1 |
20 |
14 |
left_shoulder2 |
21 |
15 |
left_elfbow |
22 |
16 |
(x,y,z) 坐标是平移自由度,而方向是表示为四元数的旋转自由度。可以在 MuJoCo 文档中阅读有关自由关节的更多信息。
注意: 当使用 HumanoidStandup-v3 或更早版本时,据报告,当使用 mujoco-py
版本 > 2.0 时,接触力始终为 0 时会出现问题。因此,建议在使用 HumanoidStandup 环境时使用 mujoco-py
版本 < 2.0,如果您想报告接触力的结果(如果您的实验中未使用接触力,则可以使用版本 > 2.0)。
奖励¶
总奖励为:reward = uph_cost + 1 - quad_ctrl_cost - quad_impact_cost。
uph_cost:向上移动(尝试站立)的奖励。这不是相对奖励,它衡量机器人自上次时间步以来向上移动了多远,而是绝对奖励,它衡量人形机器人总共向上移动了多远。它被衡量为 \(w_{uph} \times \frac{z_{after\_action} - 0}{dt}\),其中 \(z_{after\_action}\) 是采取行动后躯干的 z 坐标,\(dt\) 是动作之间的时间,这取决于
frame_skip
参数(默认为 \(5\))和frametime
,即 \(0.01\) - 因此默认值为 \(dt = 5 \times 0.01 = 0.05\),\(w_{uph}\) 是uph_cost_weight
(默认为 \(1\))。quad_ctrl_cost:对人形机器人采取过大动作进行惩罚的负奖励。\(w_{quad\_control} \times \|action\|_2^2\),其中 \(w_{quad\_control}\) 是
ctrl_cost_weight
(默认为 \(0.1\))。impact_cost:如果外部接触力过大,则对人形机器人进行惩罚的负奖励。\(w_{impact} \times clamp(impact\_cost\_range, \|F_{contact}\|_2^2)\),其中 \(w_{impact}\) 是
impact_cost_weight
(默认为 \(5\times10^{-7}\)),\(F_{contact}\) 是外部接触力(请参阅“观察空间”上的cfrc_ext
部分)。
info
包含各个奖励项。
起始状态¶
初始位置状态为 \([0.0, 0.0, 1.4, 1.0, 0.0, ... 0.0] + \mathcal{U}_{[-reset\_noise\_scale \times I_{24}, reset\_noise\_scale \times I_{24}]}\)。初始速度状态为 \(\mathcal{U}_{[-reset\_noise\_scale \times I_{23}, reset\_noise\_scale \times I_{23}]}\)。
其中 \(\mathcal{U}\) 是多元均匀连续分布。
请注意,z 和 x 坐标是非零的,因此人形机器人会立即躺下并面向前方(x 轴)。
Episode End¶
终止¶
人形机器人永远不会终止。
截断¶
剧集的默认持续时间为 1000 个时间步。
参数¶
HumanoidStandup 提供了一系列参数来修改观察空间、奖励函数、初始状态和终止条件。这些参数可以在 gymnasium.make
中通过以下方式应用
import gymnasium as gym
env = gym.make('HumanoidStandup-v5', impact_cost_weight=0.5e-6, ....)
参数 |
类型 |
默认值 |
描述 |
---|---|---|---|
|
str |
|
MuJoCo 模型的路径 |
|
float |
|
uph_cost 项的权重(请参阅 |
|
float |
|
quad_ctrl_cost 项的权重(请参阅 |
|
float |
|
impact_cost 项的权重(请参阅 |
|
float |
|
钳制 impact_cost(请参阅 |
|
float |
|
初始位置和速度的随机扰动的比例(请参阅 |
|
bool |
|
是否从观察中省略 x 和 y 坐标。排除位置可以作为归纳偏置,以在策略中诱导与位置无关的行为(请参阅 |
|
bool |
|
是否在观察中包含 cinert 元素(请参阅 |
|
bool |
|
是否在观察中包含 cvel 元素(请参阅 |
|
bool |
|
是否在观察中包含 qfrc_actuator 元素(请参阅 |
|
bool |
|
是否在观察中包含 cfrc_ext 元素(请参阅 |
版本历史¶
v5
最低
mujoco
版本现在是 2.3.3。添加了对使用
xml_file
参数完全自定义/第三方mujoco
模型(以前只能对现有模型进行少量更改)的支持。添加了
default_camera_config
参数,一个用于设置mj_camera
属性的字典,主要用于自定义环境。添加了
env.observation_structure
,一个用于指定观察空间组成的字典(例如qpos
、qvel
),用于为 MuJoCo 环境构建工具和 wrappers。返回带有
reset()
的非空info
,以前返回的是空字典,新键与step()
的状态信息相同。添加了
frame_skip
参数,用于配置dt
(step()
的持续时间),默认值因环境而异,请查看环境文档页面。从观察空间中排除了
worldbody
和root
/freejoint
qfrc_actuator
的cinert
&cvel
&cfrc_ext
,因为它始终为 0,因此没有为智能体提供有用的信息,从而略微加快了训练速度(相关 GitHub issue)。恢复了
xml_file
参数(在v4
中已删除)。添加了
xml_file
参数。添加了
uph_cost_weight
、ctrl_cost_weight
、impact_cost_weight
、impact_cost_range
参数来配置奖励函数(默认值实际上与v4
中的相同)。添加了
reset_noise_scale
参数来设置初始状态的范围。添加了
include_cinert_in_observation
、include_cvel_in_observation
、include_qfrc_actuator_in_observation
、include_cfrc_ext_in_observation
参数,以允许从观察空间中排除观察元素。添加了
info["tendon_length"]
和info["tendon_velocity"]
,其中包含对人形机器人 2 条将髋部连接到膝盖的肌腱的观察。添加了
info["x_position"]
&info["y_position"]
,其中包含当exclude_current_positions_from_observation == True
时排除的观察。添加了
info["z_distance_from_origin"]
,它是“躯干”身体与其初始位置的垂直距离。
v4:所有 MuJoCo 环境现在都使用 mujoco >= 2.1.3 中的 MuJoCo 绑定。
v3:此环境没有 v3 版本。
v2:所有连续控制环境现在都使用 mujoco-py >= 1.50。
v1:基于机器人的任务的最大时间步数增加到 1000。为环境添加了 reward_threshold。
v0:初始版本发布。