Amend some bugs and make it training
This commit is contained in:
@@ -26,7 +26,7 @@ class T1ObservationCfg:
|
||||
base_ang_vel = ObsTerm(func=mdp.base_ang_vel)
|
||||
projected_gravity = ObsTerm(func=mdp.projected_gravity)
|
||||
# ⬅️ 新增:让机器人知道自己离地多高
|
||||
root_height = ObsTerm(func=mdp.root_height)
|
||||
root_height = ObsTerm(func=mdp.root_pos_w)
|
||||
joint_pos = ObsTerm(func=mdp.joint_pos_rel)
|
||||
joint_vel = ObsTerm(func=mdp.joint_vel_rel)
|
||||
actions = ObsTerm(func=mdp.last_action)
|
||||
@@ -41,18 +41,32 @@ class T1EventCfg:
|
||||
# 每次重置时,随机给基座一个旋转角度
|
||||
# 包括:背躺 (Pitch=1.57), 趴着 (Pitch=-1.57), 侧躺 (Roll=1.57)
|
||||
reset_robot_rotation = EventTerm(
|
||||
func=mdp.reset_root_custom_orientation,
|
||||
func=mdp.reset_root_state_uniform, # 修正为报错建议的函数名
|
||||
params={
|
||||
"euler_angles_range": {
|
||||
"roll": (-1.57, 1.57), # 覆盖侧躺
|
||||
"pitch": (-1.57, 1.57), # 覆盖趴下和背躺
|
||||
"yaw": (-3.14, 3.14), # 随机朝向
|
||||
},
|
||||
"asset_cfg": SceneEntityCfg("robot"),
|
||||
"pose_range": {
|
||||
"roll": (-1.57, 1.57), # 侧躺随机
|
||||
"pitch": (-1.57, 1.57), # 趴下/背躺随机
|
||||
"yaw": (-3.14, 3.14), # 航向角随机
|
||||
"x": (0.0, 0.0), # 位置不随机(保持在原点)
|
||||
"y": (0.0, 0.0),
|
||||
"z": (0.0, 0.0), # 高度由 init_state 决定,这里设为0偏移
|
||||
},
|
||||
"velocity_range": {}, # 初始速度默认为0
|
||||
},
|
||||
mode="reset",
|
||||
)
|
||||
|
||||
@configclass
|
||||
class T1ActionCfg:
|
||||
"""动作空间配置组"""
|
||||
# 这里的变量名 (例如 joint_pos) 将决定 ActionManager 中的 term 名称
|
||||
joint_pos = JointPositionActionCfg(
|
||||
asset_name="robot",
|
||||
joint_names=[".*"],
|
||||
scale=0.5,
|
||||
use_default_offset=True
|
||||
)
|
||||
|
||||
@configclass
|
||||
class T1GetUpRewardCfg:
|
||||
@@ -87,7 +101,7 @@ class T1TerminationsCfg:
|
||||
# 提前成功:如果站起来了并保持稳定,直接结束 Episode 并拿奖励,节省算力
|
||||
is_standing_success = DoneTerm(
|
||||
func=mdp.root_height_below_minimum,
|
||||
params={"minimum_height": 0.65, "inverted": True} # 高于 0.65m 则重置
|
||||
params={"minimum_height": 0.65},
|
||||
)
|
||||
time_out = DoneTerm(func=mdp.time_out)
|
||||
|
||||
@@ -107,9 +121,7 @@ class T1EnvCfg(ManagerBasedRLEnvCfg):
|
||||
terminations = T1TerminationsCfg()
|
||||
events = T1EventCfg() # ⬅️ 挂载随机姿态事件
|
||||
|
||||
actions = JointPositionActionCfg(
|
||||
asset_name="robot", joint_names=[".*"], scale=0.5, use_default_offset=True
|
||||
)
|
||||
actions = T1ActionCfg()
|
||||
|
||||
# 训练参数
|
||||
episode_length_s = 5.0 # 强制 5秒内必须站起来
|
||||
|
||||
@@ -71,7 +71,7 @@ def main():
|
||||
rl_game_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "."))
|
||||
log_dir = os.path.join(rl_game_dir, "logs")
|
||||
rl_config['params']['config']['train_dir'] = log_dir
|
||||
rl_config['params']['config']['name'] = "T1_GetUp_Experiment"
|
||||
rl_config['params']['config']['name'] = "T1_GetUp"
|
||||
|
||||
# 7. 运行训练
|
||||
runner = Runner()
|
||||
|
||||
Reference in New Issue
Block a user