Skip to content
切换导航面板
P
项目
G
群组
S
代码片段
帮助
yzh
/
agielf2_amp
当前项目
正在载入...
登录
切换导航面板
转到一个项目
项目
版本库
问题
0
合并请求
0
流水线
维基
代码片段
成员
活动
图像
图表
创建新的问题
作业
提交
问题看板
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
03eab9af
authored
Mar 25, 2025
by
liufq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.elf12 good
parent
acced63a
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
116 行增加
和
61 行删除
+116
-61
humanoid/envs/__init__.py
+6
-0
humanoid/envs/elf12/elf12_dh_stand_config.py
+44
-43
humanoid/envs/elf12/elf12_dh_stand_env.py
+7
-6
humanoid/export.sh
+2
-0
humanoid/play.sh
+3
-0
humanoid/scripts/play.py
+4
-4
humanoid/train.sh
+6
-0
humanoid/utils/logger.py
+36
-0
resources/robots/elf12/urdf/elf12.urdf
+8
-8
没有找到文件。
humanoid/envs/__init__.py
查看文件 @
03eab9af
...
@@ -38,6 +38,12 @@ from .x1.x1_dh_stand_config import X1DHStandCfg, X1DHStandCfgPPO
...
@@ -38,6 +38,12 @@ from .x1.x1_dh_stand_config import X1DHStandCfg, X1DHStandCfgPPO
from
.x1.x1_dh_stand_env
import
X1DHStandEnv
from
.x1.x1_dh_stand_env
import
X1DHStandEnv
from
.elf12.elf12_dh_stand_config
import
Elf12DHStandCfg
,
Elf12DHStandCfgPPO
from
.elf12.elf12_dh_stand_env
import
Elf12DHStandEnv
from
humanoid.utils.task_registry
import
task_registry
from
humanoid.utils.task_registry
import
task_registry
task_registry
.
register
(
"x1_dh_stand"
,
X1DHStandEnv
,
X1DHStandCfg
(),
X1DHStandCfgPPO
()
)
task_registry
.
register
(
"x1_dh_stand"
,
X1DHStandEnv
,
X1DHStandCfg
(),
X1DHStandCfgPPO
()
)
task_registry
.
register
(
"elf12_dh_stand"
,
Elf12DHStandEnv
,
Elf12DHStandCfg
(),
Elf12DHStandCfgPPO
()
)
humanoid/envs/elf12/elf12_dh_stand_config.py
查看文件 @
03eab9af
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
from
humanoid.envs.base.legged_robot_config
import
LeggedRobotCfg
,
LeggedRobotCfgPPO
from
humanoid.envs.base.legged_robot_config
import
LeggedRobotCfg
,
LeggedRobotCfgPPO
class
X1
DHStandCfg
(
LeggedRobotCfg
):
class
Elf12
DHStandCfg
(
LeggedRobotCfg
):
"""
"""
Configuration class for the XBotL humanoid robot.
Configuration class for the XBotL humanoid robot.
"""
"""
...
@@ -60,16 +60,16 @@ class X1DHStandCfg(LeggedRobotCfg):
...
@@ -60,16 +60,16 @@ class X1DHStandCfg(LeggedRobotCfg):
class
asset
(
LeggedRobotCfg
.
asset
):
class
asset
(
LeggedRobotCfg
.
asset
):
file
=
'{LEGGED_GYM_ROOT_DIR}/resources/robots/
x1/urdf/x1
.urdf'
file
=
'{LEGGED_GYM_ROOT_DIR}/resources/robots/
elf12/urdf/elf12
.urdf'
xml_file
=
'{LEGGED_GYM_ROOT_DIR}/resources/robots/x
1/mjcf/xyber_x1_flat.xml
'
xml_file
=
'{LEGGED_GYM_ROOT_DIR}/resources/robots/x
xxx
'
name
=
"
x1
"
name
=
"
elf12
"
foot_name
=
"ankle_
roll
"
foot_name
=
"ankle_
x_link
"
knee_name
=
"knee_
pitch
"
knee_name
=
"knee_
y_link
"
terminate_after_contacts_on
=
[
'base_link'
]
terminate_after_contacts_on
=
[
'base_link'
,
'hip'
]
penalize_contacts_on
=
[
"base_link"
]
penalize_contacts_on
=
[
"base_link"
,
"hip"
]
self_collisions
=
0
# 1 to disable, 0 to enable...bitwise filter
self_collisions
=
1
# 1 to disable, 0 to enable...bitwise filter
flip_visual_attachments
=
False
flip_visual_attachments
=
False
replace_cylinder_with_capsule
=
False
replace_cylinder_with_capsule
=
False
fix_base_link
=
False
fix_base_link
=
False
...
@@ -123,31 +123,30 @@ class X1DHStandCfg(LeggedRobotCfg):
...
@@ -123,31 +123,30 @@ class X1DHStandCfg(LeggedRobotCfg):
class
init_state
(
LeggedRobotCfg
.
init_state
):
class
init_state
(
LeggedRobotCfg
.
init_state
):
pos
=
[
0.0
,
0.0
,
0.7
]
pos
=
[
0.0
,
0.0
,
0.7
8
]
default_joint_angles
=
{
# = target angles [rad] when action = 0.0
default_joint_angles
=
{
# = target angles [rad] when action = 0.0
'left_hip_pitch_joint'
:
0.4
,
'l_hip_z_joint'
:
0.0
,
'left_hip_roll_joint'
:
0.05
,
'l_hip_x_joint'
:
0.0
,
'left_hip_yaw_joint'
:
-
0.31
,
'l_hip_y_joint'
:
-
0.3
,
'left_knee_pitch_joint'
:
0.49
,
'l_knee_y_joint'
:
0.6
,
'left_ankle_pitch_joint'
:
-
0.21
,
'l_ankle_y_joint'
:
-
0.3
,
'left_ankle_roll_joint'
:
0.0
,
'l_ankle_x_joint'
:
0.0
,
'right_hip_pitch_joint'
:
-
0.4
,
'right_hip_roll_joint'
:
-
0.05
,
'r_hip_z_joint'
:
0.0
,
'right_hip_yaw_joint'
:
0.31
,
'r_hip_x_joint'
:
0.0
,
'right_knee_pitch_joint'
:
0.49
,
'r_hip_y_joint'
:
-
0.3
,
'right_ankle_pitch_joint'
:
-
0.21
,
'r_knee_y_joint'
:
0.6
,
'right_ankle_roll_joint'
:
0.0
,
'r_ankle_y_joint'
:
-
0.3
,
'r_ankle_x_joint'
:
0.0
,
}
}
class
control
(
LeggedRobotCfg
.
control
):
class
control
(
LeggedRobotCfg
.
control
):
# PD Drive parameters:
# PD Drive parameters:
control_type
=
'P'
control_type
=
'P'
stiffness
=
{
'hip_pitch_joint'
:
30
,
'hip_roll_joint'
:
40
,
'hip_yaw_joint'
:
35
,
stiffness
=
{
'hip_z'
:
150
,
'hip_x'
:
150
,
'hip_y'
:
150
,
'knee_y'
:
150
,
'ankle_y'
:
20
,
'ankle_x'
:
20
}
'knee_pitch_joint'
:
100
,
'ankle_pitch_joint'
:
35
,
'ankle_roll_joint'
:
35
}
damping
=
{
'hip_z'
:
3
,
'hip_x'
:
3
,
'hip_y'
:
3
,
'knee_y'
:
3
,
'ankle_y'
:
1
,
'ankle_x'
:
1
}
damping
=
{
'hip_pitch_joint'
:
3
,
'hip_roll_joint'
:
3.0
,
'hip_yaw_joint'
:
4
,
'knee_pitch_joint'
:
10
,
'ankle_pitch_joint'
:
0.5
,
'ankle_roll_joint'
:
0.5
}
# action scale: target angle = actionScale * action + defaultAngle
# action scale: target angle = actionScale * action + defaultAngle
action_scale
=
0.5
action_scale
=
0.5
...
@@ -183,8 +182,8 @@ class X1DHStandCfg(LeggedRobotCfg):
...
@@ -183,8 +182,8 @@ class X1DHStandCfg(LeggedRobotCfg):
push_interval_s
=
4
# every this second, push robot
push_interval_s
=
4
# every this second, push robot
update_step
=
2000
*
24
# after this count, increase push_duration index
update_step
=
2000
*
24
# after this count, increase push_duration index
push_duration
=
[
0
,
0.05
,
0.1
,
0.15
,
0.2
,
0.25
]
# increase push duration during training
push_duration
=
[
0
,
0.05
,
0.1
,
0.15
,
0.2
,
0.25
]
# increase push duration during training
max_push_vel_xy
=
0.
2
max_push_vel_xy
=
0.
5
max_push_ang_vel
=
0.
2
max_push_ang_vel
=
0.
3
randomize_base_mass
=
True
randomize_base_mass
=
True
added_mass_range
=
[
-
3
,
3
]
# base mass rand range, base mass is all fix link sum mass
added_mass_range
=
[
-
3
,
3
]
# base mass rand range, base mass is all fix link sum mass
...
@@ -295,7 +294,7 @@ class X1DHStandCfg(LeggedRobotCfg):
...
@@ -295,7 +294,7 @@ class X1DHStandCfg(LeggedRobotCfg):
sw_switch
=
True
# use stand_com_threshold or not
sw_switch
=
True
# use stand_com_threshold or not
class
ranges
:
class
ranges
:
lin_vel_x
=
[
-
0.4
,
1.2
]
# min max [m/s]
lin_vel_x
=
[
-
0.4
,
0.8
]
# min max [m/s]
lin_vel_y
=
[
-
0.4
,
0.4
]
# min max [m/s]
lin_vel_y
=
[
-
0.4
,
0.4
]
# min max [m/s]
ang_vel_yaw
=
[
-
0.6
,
0.6
]
# min max [rad/s]
ang_vel_yaw
=
[
-
0.6
,
0.6
]
# min max [rad/s]
heading
=
[
-
3.14
,
3.14
]
heading
=
[
-
3.14
,
3.14
]
...
@@ -304,16 +303,18 @@ class X1DHStandCfg(LeggedRobotCfg):
...
@@ -304,16 +303,18 @@ class X1DHStandCfg(LeggedRobotCfg):
soft_dof_pos_limit
=
0.98
soft_dof_pos_limit
=
0.98
soft_dof_vel_limit
=
0.9
soft_dof_vel_limit
=
0.9
soft_torque_limit
=
0.9
soft_torque_limit
=
0.9
base_height_target
=
0.6
1
base_height_target
=
0.6
8
foot_min_dist
=
0.
2
foot_min_dist
=
0.
15
foot_max_dist
=
1.0
foot_max_dist
=
1.0
# final_swing_joint_pos = final_swing_joint_delta_pos + default_pos
# final_swing_joint_pos = final_swing_joint_delta_pos + default_pos
final_swing_joint_delta_pos
=
[
0.25
,
0.05
,
-
0.11
,
0.35
,
-
0.16
,
0.0
,
-
0.25
,
-
0.05
,
0.11
,
0.35
,
-
0.16
,
0.0
]
final_swing_joint_delta_pos
=
[
0.0
,
0.0
,
-
0.16
,
0.32
,
-
0.16
,
0.0
,
0.0
,
0.0
,
-
0.16
,
0.32
,
-
0.16
,
0.0
]
target_feet_height
=
0.03
target_feet_height
=
0.03
target_feet_height_max
=
0.0
6
target_feet_height_max
=
0.0
8
feet_to_ankle_distance
=
0.04
1
feet_to_ankle_distance
=
0.04
cycle_time
=
0.7
cycle_time
=
0.7
double_suport
=
0.4
# if true negative total rewards are clipped at zero (avoids early termination problems)
# if true negative total rewards are clipped at zero (avoids early termination problems)
only_positive_rewards
=
True
only_positive_rewards
=
True
# tracking reward = exp(-error*sigma)
# tracking reward = exp(-error*sigma)
...
@@ -341,7 +342,7 @@ class X1DHStandCfg(LeggedRobotCfg):
...
@@ -341,7 +342,7 @@ class X1DHStandCfg(LeggedRobotCfg):
default_joint_pos
=
1.0
default_joint_pos
=
1.0
orientation
=
1.
orientation
=
1.
feet_rotation
=
0.3
feet_rotation
=
0.3
base_height
=
0.2
#
base_height = 0.2
base_acc
=
0.2
base_acc
=
0.2
# energy
# energy
action_smoothness
=
-
0.002
action_smoothness
=
-
0.002
...
@@ -367,7 +368,7 @@ class X1DHStandCfg(LeggedRobotCfg):
...
@@ -367,7 +368,7 @@ class X1DHStandCfg(LeggedRobotCfg):
clip_actions
=
100.
clip_actions
=
100.
class
X1
DHStandCfgPPO
(
LeggedRobotCfgPPO
):
class
Elf12
DHStandCfgPPO
(
LeggedRobotCfgPPO
):
seed
=
5
seed
=
5
runner_class_name
=
'DHOnPolicyRunner'
# DWLOnPolicyRunner
runner_class_name
=
'DHOnPolicyRunner'
# DWLOnPolicyRunner
...
@@ -382,7 +383,7 @@ class X1DHStandCfgPPO(LeggedRobotCfgPPO):
...
@@ -382,7 +383,7 @@ class X1DHStandCfgPPO(LeggedRobotCfgPPO):
filter_size
=
[
32
,
16
]
filter_size
=
[
32
,
16
]
stride_size
=
[
3
,
2
]
stride_size
=
[
3
,
2
]
lh_output_dim
=
64
#long history output dim
lh_output_dim
=
64
#long history output dim
in_channels
=
X1
DHStandCfg
.
env
.
frame_stack
in_channels
=
Elf12
DHStandCfg
.
env
.
frame_stack
class
algorithm
(
LeggedRobotCfgPPO
.
algorithm
):
class
algorithm
(
LeggedRobotCfgPPO
.
algorithm
):
entropy_coef
=
0.001
entropy_coef
=
0.001
...
@@ -391,20 +392,20 @@ class X1DHStandCfgPPO(LeggedRobotCfgPPO):
...
@@ -391,20 +392,20 @@ class X1DHStandCfgPPO(LeggedRobotCfgPPO):
gamma
=
0.994
gamma
=
0.994
lam
=
0.9
lam
=
0.9
num_mini_batches
=
4
num_mini_batches
=
4
if
X1
DHStandCfg
.
terrain
.
measure_heights
:
if
Elf12
DHStandCfg
.
terrain
.
measure_heights
:
lin_vel_idx
=
(
X1DHStandCfg
.
env
.
single_num_privileged_obs
+
X1DHStandCfg
.
terrain
.
num_height
)
*
(
X1DHStandCfg
.
env
.
c_frame_stack
-
1
)
+
X1
DHStandCfg
.
env
.
single_linvel_index
lin_vel_idx
=
(
Elf12DHStandCfg
.
env
.
single_num_privileged_obs
+
Elf12DHStandCfg
.
terrain
.
num_height
)
*
(
Elf12DHStandCfg
.
env
.
c_frame_stack
-
1
)
+
Elf12
DHStandCfg
.
env
.
single_linvel_index
else
:
else
:
lin_vel_idx
=
X1DHStandCfg
.
env
.
single_num_privileged_obs
*
(
X1DHStandCfg
.
env
.
c_frame_stack
-
1
)
+
X1
DHStandCfg
.
env
.
single_linvel_index
lin_vel_idx
=
Elf12DHStandCfg
.
env
.
single_num_privileged_obs
*
(
Elf12DHStandCfg
.
env
.
c_frame_stack
-
1
)
+
Elf12
DHStandCfg
.
env
.
single_linvel_index
class
runner
:
class
runner
:
policy_class_name
=
'ActorCriticDH'
policy_class_name
=
'ActorCriticDH'
algorithm_class_name
=
'DHPPO'
algorithm_class_name
=
'DHPPO'
num_steps_per_env
=
24
# per iteration
num_steps_per_env
=
24
# per iteration
max_iterations
=
2
0000
# number of policy updates
max_iterations
=
5
0000
# number of policy updates
# logging
# logging
save_interval
=
1
00
# check for potential saves every this many iterations
save_interval
=
5
00
# check for potential saves every this many iterations
experiment_name
=
'
x1
_dh_stand'
experiment_name
=
'
elf12
_dh_stand'
run_name
=
''
run_name
=
''
# load and resume
# load and resume
resume
=
False
resume
=
False
...
...
humanoid/envs/elf12/elf12_dh_stand_env.py
查看文件 @
03eab9af
...
@@ -76,7 +76,7 @@ def get_euler_xyz_tensor(quat):
...
@@ -76,7 +76,7 @@ def get_euler_xyz_tensor(quat):
euler_xyz
[
euler_xyz
>
np
.
pi
]
-=
2
*
np
.
pi
euler_xyz
[
euler_xyz
>
np
.
pi
]
-=
2
*
np
.
pi
return
euler_xyz
return
euler_xyz
class
X1
DHStandEnv
(
LeggedRobot
):
class
Elf12
DHStandEnv
(
LeggedRobot
):
'''
'''
X1DHStandEnv is a class that represents a custom environment for a legged robot.
X1DHStandEnv is a class that represents a custom environment for a legged robot.
...
@@ -157,7 +157,7 @@ class X1DHStandEnv(LeggedRobot):
...
@@ -157,7 +157,7 @@ class X1DHStandEnv(LeggedRobot):
# right foot stance
# right foot stance
stance_mask
[:,
1
]
=
sin_pos
<
0
stance_mask
[:,
1
]
=
sin_pos
<
0
# Add double support phase
# Add double support phase
stance_mask
[
torch
.
abs
(
sin_pos
)
<
0.1
]
=
1
stance_mask
[
torch
.
abs
(
sin_pos
)
<
self
.
cfg
.
rewards
.
double_suport
]
=
1
# stand mask == 1 means stand leg
# stand mask == 1 means stand leg
return
stance_mask
return
stance_mask
...
@@ -295,7 +295,7 @@ class X1DHStandEnv(LeggedRobot):
...
@@ -295,7 +295,7 @@ class X1DHStandEnv(LeggedRobot):
self
.
ref_dof_pos
[:,
10
]
=
sin_pos_r
*
self
.
cfg
.
rewards
.
final_swing_joint_delta_pos
[
10
]
self
.
ref_dof_pos
[:,
10
]
=
sin_pos_r
*
self
.
cfg
.
rewards
.
final_swing_joint_delta_pos
[
10
]
self
.
ref_dof_pos
[:,
11
]
=
sin_pos_r
*
self
.
cfg
.
rewards
.
final_swing_joint_delta_pos
[
11
]
self
.
ref_dof_pos
[:,
11
]
=
sin_pos_r
*
self
.
cfg
.
rewards
.
final_swing_joint_delta_pos
[
11
]
self
.
ref_dof_pos
[
torch
.
abs
(
sin_pos
)
<
0.1
]
=
0.
self
.
ref_dof_pos
[
torch
.
abs
(
sin_pos
)
<
self
.
cfg
.
rewards
.
double_suport
]
=
0.
# if use_ref_actions=True, action += ref_action
# if use_ref_actions=True, action += ref_action
self
.
ref_action
=
2
*
self
.
ref_dof_pos
self
.
ref_action
=
2
*
self
.
ref_dof_pos
...
@@ -610,7 +610,8 @@ class X1DHStandEnv(LeggedRobot):
...
@@ -610,7 +610,8 @@ class X1DHStandEnv(LeggedRobot):
with the ground. The speed of the foot is calculated and scaled by the contact conditions.
with the ground. The speed of the foot is calculated and scaled by the contact conditions.
"""
"""
contact
=
self
.
contact_forces
[:,
self
.
feet_indices
,
2
]
>
5.
contact
=
self
.
contact_forces
[:,
self
.
feet_indices
,
2
]
>
5.
foot_speed_norm
=
torch
.
norm
(
self
.
rigid_state
[:,
self
.
feet_indices
,
10
:
12
],
dim
=
2
)
# foot_speed_norm = torch.norm(self.rigid_state[:, self.feet_indices, 10:12], dim=2)
foot_speed_norm
=
torch
.
norm
(
self
.
rigid_state
[:,
self
.
feet_indices
,
7
:
9
],
dim
=
2
)
rew
=
torch
.
sqrt
(
foot_speed_norm
)
rew
=
torch
.
sqrt
(
foot_speed_norm
)
rew
*=
contact
rew
*=
contact
return
torch
.
sum
(
rew
,
dim
=
1
)
return
torch
.
sum
(
rew
,
dim
=
1
)
...
@@ -665,8 +666,8 @@ class X1DHStandEnv(LeggedRobot):
...
@@ -665,8 +666,8 @@ class X1DHStandEnv(LeggedRobot):
on penalizing deviation in yaw and roll directions. Excludes yaw and roll from the main penalty.
on penalizing deviation in yaw and roll directions. Excludes yaw and roll from the main penalty.
"""
"""
joint_diff
=
self
.
dof_pos
-
self
.
default_joint_pd_target
joint_diff
=
self
.
dof_pos
-
self
.
default_joint_pd_target
left_yaw_roll
=
joint_diff
[:,
[
1
,
2
,
5
]]
left_yaw_roll
=
joint_diff
[:,
[
0
,
1
,
5
]]
right_yaw_roll
=
joint_diff
[:,
[
7
,
8
,
11
]]
right_yaw_roll
=
joint_diff
[:,
[
6
,
7
,
11
]]
yaw_roll
=
torch
.
norm
(
left_yaw_roll
,
dim
=
1
)
+
torch
.
norm
(
right_yaw_roll
,
dim
=
1
)
yaw_roll
=
torch
.
norm
(
left_yaw_roll
,
dim
=
1
)
+
torch
.
norm
(
right_yaw_roll
,
dim
=
1
)
yaw_roll
=
torch
.
clamp
(
yaw_roll
-
0.1
,
0
,
50
)
yaw_roll
=
torch
.
clamp
(
yaw_roll
-
0.1
,
0
,
50
)
return
torch
.
exp
(
-
yaw_roll
*
100
)
-
0.01
*
torch
.
norm
(
joint_diff
,
dim
=
1
)
return
torch
.
exp
(
-
yaw_roll
*
100
)
-
0.01
*
torch
.
norm
(
joint_diff
,
dim
=
1
)
...
...
humanoid/export.sh
0 → 100644
查看文件 @
03eab9af
python scripts/export_policy_dh.py
--task
=
elf12_dh_stand
#--load_run=<date_time><run_name>
\ No newline at end of file
humanoid/play.sh
0 → 100644
查看文件 @
03eab9af
# python scripts/play.py --task=bot_elf_dh_stand #--load_run=<date_time><run_name>
python scripts/play.py
--task
=
elf12_dh_stand
#--load_run=<date_time><run_name>
\ No newline at end of file
humanoid/scripts/play.py
查看文件 @
03eab9af
...
@@ -132,7 +132,7 @@ def play(args):
...
@@ -132,7 +132,7 @@ def play(args):
logger
=
Logger
(
env_cfg
.
sim
.
dt
*
env_cfg
.
control
.
decimation
)
logger
=
Logger
(
env_cfg
.
sim
.
dt
*
env_cfg
.
control
.
decimation
)
robot_index
=
0
# which robot is used for logging
robot_index
=
0
# which robot is used for logging
joint_index
=
5
# which joint is used for logging
joint_index
=
5
# which joint is used for logging
stop_state_log
=
10
00
# number of steps before plotting states
stop_state_log
=
5
00
# number of steps before plotting states
if
RENDER
:
if
RENDER
:
camera_properties
=
gymapi
.
CameraProperties
()
camera_properties
=
gymapi
.
CameraProperties
()
camera_properties
.
width
=
1920
camera_properties
.
width
=
1920
...
@@ -193,8 +193,8 @@ def play(args):
...
@@ -193,8 +193,8 @@ def play(args):
'base_height'
:
env
.
root_states
[
robot_index
,
2
]
.
item
(),
'base_height'
:
env
.
root_states
[
robot_index
,
2
]
.
item
(),
'foot_z_l'
:
env
.
rigid_state
[
robot_index
,
4
,
2
]
.
item
(),
'foot_z_l'
:
env
.
rigid_state
[
robot_index
,
4
,
2
]
.
item
(),
'foot_z_r'
:
env
.
rigid_state
[
robot_index
,
9
,
2
]
.
item
(),
'foot_z_r'
:
env
.
rigid_state
[
robot_index
,
9
,
2
]
.
item
(),
'foot_forcez_l'
:
env
.
contact_forces
[
robot_index
,
4
,
2
]
.
item
(),
'foot_forcez_l'
:
env
.
contact_forces
[
robot_index
,
6
,
2
]
.
item
(),
'foot_forcez_r'
:
env
.
contact_forces
[
robot_index
,
9
,
2
]
.
item
(),
'foot_forcez_r'
:
env
.
contact_forces
[
robot_index
,
12
,
2
]
.
item
(),
'base_vel_x'
:
env
.
base_lin_vel
[
robot_index
,
0
]
.
item
(),
'base_vel_x'
:
env
.
base_lin_vel
[
robot_index
,
0
]
.
item
(),
'command_x'
:
x_vel_cmd
,
'command_x'
:
x_vel_cmd
,
'base_vel_y'
:
env
.
base_lin_vel
[
robot_index
,
1
]
.
item
(),
'base_vel_y'
:
env
.
base_lin_vel
[
robot_index
,
1
]
.
item
(),
...
@@ -245,6 +245,6 @@ def play(args):
...
@@ -245,6 +245,6 @@ def play(args):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
EXPORT_POLICY
=
False
EXPORT_POLICY
=
False
RENDER
=
False
RENDER
=
False
FIX_COMMAND
=
False
FIX_COMMAND
=
True
#
False
args
=
get_args
()
args
=
get_args
()
play
(
args
)
play
(
args
)
humanoid/train.sh
0 → 100644
查看文件 @
03eab9af
# python scripts/train.py --task=x1_dh_stand --run_name=test #--headless #--resume
# python ./scripts/train.py --task=bot_elf_dh_stand --run_name=test #--num_envs=3 #--resume #--headless
python ./scripts/train.py
--task
=
elf12_dh_stand
--run_name
=
test
#--num_envs=3 #--resume #--headless
\ No newline at end of file
humanoid/utils/logger.py
查看文件 @
03eab9af
...
@@ -74,6 +74,7 @@ class Logger:
...
@@ -74,6 +74,7 @@ class Logger:
# self.plot_process10 = Process(target=self._plot_tn_rms1)
# self.plot_process10 = Process(target=self._plot_tn_rms1)
# self.plot_process11 = Process(target=self._plot_tn1)
# self.plot_process11 = Process(target=self._plot_tn1)
# self.plot_process12 = Process(target=self._plot_torque_vel1)
# self.plot_process12 = Process(target=self._plot_torque_vel1)
self
.
plot_process13
=
Process
(
target
=
self
.
_plot_force
)
self
.
plot_process
.
start
()
self
.
plot_process
.
start
()
self
.
plot_process1
.
start
()
self
.
plot_process1
.
start
()
# self.plot_process2.start()
# self.plot_process2.start()
...
@@ -87,6 +88,7 @@ class Logger:
...
@@ -87,6 +88,7 @@ class Logger:
# self.plot_process10.start()
# self.plot_process10.start()
# self.plot_process11.start()
# self.plot_process11.start()
# self.plot_process12.start()
# self.plot_process12.start()
self
.
plot_process13
.
start
()
def
_plot
(
self
):
def
_plot
(
self
):
nb_rows
=
3
nb_rows
=
3
...
@@ -128,6 +130,40 @@ class Logger:
...
@@ -128,6 +130,40 @@ class Logger:
# a.legend()
# a.legend()
plt
.
show
()
plt
.
show
()
def
_plot_force
(
self
):
for
key
,
value
in
self
.
state_log
.
items
():
time
=
np
.
linspace
(
0
,
len
(
value
)
*
self
.
dt
,
len
(
value
))
break
log
=
self
.
state_log
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
if
log
[
"foot_forcez_l"
]:
forcez_l
=
np
.
array
(
log
[
"foot_forcez_l"
])
forcez_l
/=
100.0
smothf_l
=
np
.
convolve
(
forcez_l
,
np
.
ones
(
3
)
/
3
,
mode
=
'same'
)
#'valid'
# smothf_l = forcez_l
ax
.
plot
(
time
,
smothf_l
+
1.1
,
label
=
'measured_l'
,
color
=
'y'
)
if
log
[
"foot_forcez_r"
]:
forcez_r
=
np
.
array
(
log
[
"foot_forcez_r"
])
forcez_r
/=
100.0
smothf_r
=
np
.
convolve
(
forcez_r
,
np
.
ones
(
3
)
/
3
,
mode
=
'same'
)
# smothf_r = forcez_r
ax
.
plot
(
time
,
smothf_r
+
1.1
,
label
=
'measured_r'
,
color
=
'b'
)
# if log["contact_mask_r"]:
# ax.plot(time, log["contact_mask_r"], label='contact_mask_r', color='b')
# if log["ref_r_3"]:
# ax.plot(time, log["ref_r_3"], label='ref_r_3', color='b')
if
log
[
"command_sin"
]:
ax
.
plot
(
time
,
log
[
"command_sin"
],
label
=
'commanded_sin'
,
color
=
'y'
)
if
log
[
"command_cos"
]:
ax
.
plot
(
time
,
log
[
"command_cos"
],
label
=
'commanded_cos'
,
color
=
'b'
)
ax
.
set
(
xlabel
=
'time [s]'
,
ylabel
=
'command cos'
,
title
=
'Command Cos'
)
plt
.
show
()
def
_plot_position
(
self
):
def
_plot_position
(
self
):
nb_rows
=
2
nb_rows
=
2
nb_cols
=
3
nb_cols
=
3
...
...
resources/robots/elf12/urdf/elf12.urdf
查看文件 @
03eab9af
...
@@ -361,7 +361,7 @@
...
@@ -361,7 +361,7 @@
rgba=
"0.752941176470588 0.752941176470588 0.752941176470588 1"
/>
rgba=
"0.752941176470588 0.752941176470588 0.752941176470588 1"
/>
</material>
</material>
</visual>
</visual>
<
!-- <
collision>
<collision>
<origin
<origin
xyz=
"0 0 0"
xyz=
"0 0 0"
rpy=
"0 0 0"
/>
rpy=
"0 0 0"
/>
...
@@ -369,8 +369,8 @@
...
@@ -369,8 +369,8 @@
<mesh
<mesh
filename=
"../meshes/l_ankle_x_link.STL"
/>
filename=
"../meshes/l_ankle_x_link.STL"
/>
</geometry>
</geometry>
</collision>
-->
</collision>
<collision
name=
"l_foot_1"
>
<
!-- <
collision name="l_foot_1">
<origin rpy="0 1.5708 0" xyz="0.0 0.03 -0.03"/>
<origin rpy="0 1.5708 0" xyz="0.0 0.03 -0.03"/>
<geometry>
<geometry>
<cylinder length="0.185" radius="0.01"/>
<cylinder length="0.185" radius="0.01"/>
...
@@ -381,7 +381,7 @@
...
@@ -381,7 +381,7 @@
<geometry>
<geometry>
<cylinder length="0.185" radius="0.01"/>
<cylinder length="0.185" radius="0.01"/>
</geometry>
</geometry>
</collision>
</collision>
-->
</link>
</link>
<joint
<joint
name=
"l_ankle_x_joint"
name=
"l_ankle_x_joint"
...
@@ -721,7 +721,7 @@
...
@@ -721,7 +721,7 @@
rgba=
"0.752941176470588 0.752941176470588 0.752941176470588 1"
/>
rgba=
"0.752941176470588 0.752941176470588 0.752941176470588 1"
/>
</material>
</material>
</visual>
</visual>
<
!-- <
collision>
<collision>
<origin
<origin
xyz=
"0 0 0"
xyz=
"0 0 0"
rpy=
"0 0 0"
/>
rpy=
"0 0 0"
/>
...
@@ -729,8 +729,8 @@
...
@@ -729,8 +729,8 @@
<mesh
<mesh
filename=
"../meshes/r_ankle_x_link.STL"
/>
filename=
"../meshes/r_ankle_x_link.STL"
/>
</geometry>
</geometry>
</collision>
-->
</collision>
<collision
name=
"r_foot_1"
>
<
!-- <
collision name="r_foot_1">
<origin rpy="0 1.5708 0" xyz="0.0 0.03 -0.03"/>
<origin rpy="0 1.5708 0" xyz="0.0 0.03 -0.03"/>
<geometry>
<geometry>
<cylinder length="0.185" radius="0.01"/>
<cylinder length="0.185" radius="0.01"/>
...
@@ -741,7 +741,7 @@
...
@@ -741,7 +741,7 @@
<geometry>
<geometry>
<cylinder length="0.185" radius="0.01"/>
<cylinder length="0.185" radius="0.01"/>
</geometry>
</geometry>
</collision>
</collision>
-->
</link>
</link>
<joint
<joint
name=
"r_ankle_x_joint"
name=
"r_ankle_x_joint"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或
登录
后发表评论