add joint_pos_penalty_l1 for better performance.
This commit is contained in:
@@ -366,7 +366,7 @@ class RewardsCfg:
|
||||
# Thus, we need to use a smaller weight for the dof_acc_l2 term in Lab compared to Gym.
|
||||
dof_acc_l2 = RewTerm(
|
||||
func=mdp.joint_acc_l2,
|
||||
weight=-1.0e-7, # gym和lab的dof_acc reward实现尺度不一样,lab是physic step level的,由于l2对于离群值的敏感性会导致更大的惩罚
|
||||
weight=-1.0e-7,
|
||||
params={"asset_cfg": SceneEntityCfg("robot", joint_names=JOINT_NAMES)}
|
||||
)
|
||||
joint_power = RewTerm(
|
||||
@@ -419,6 +419,17 @@ class RewardsCfg:
|
||||
"command_threshold": 0.1,
|
||||
},
|
||||
)
|
||||
joint_pos_penalty_l1 = RewTerm(
|
||||
func=mdp.joint_pos_penalty_l1,
|
||||
weight=-0.02,
|
||||
params={
|
||||
"command_name": "base_velocity",
|
||||
"asset_cfg": SceneEntityCfg("robot", joint_names=".*_(thigh|calf)_joint"),
|
||||
"stand_still_scale": 1.0,
|
||||
"velocity_threshold": 0.1,
|
||||
"command_threshold": 0.1,
|
||||
},
|
||||
)
|
||||
|
||||
@configclass
|
||||
class TerminationsCfg:
|
||||
|
||||
@@ -109,7 +109,7 @@ def stand_still(
|
||||
return reward
|
||||
|
||||
|
||||
def joint_pos_penalty(
|
||||
def joint_pos_penalty_l1(
|
||||
env: ManagerBasedRLEnv,
|
||||
command_name: str,
|
||||
asset_cfg: SceneEntityCfg,
|
||||
@@ -123,14 +123,13 @@ def joint_pos_penalty(
|
||||
cmd = torch.linalg.norm(env.command_manager.get_command(command_name), dim=1)
|
||||
body_vel = torch.linalg.norm(asset.data.root_lin_vel_b[:, :2], dim=1)
|
||||
running_reward = torch.linalg.norm(
|
||||
(asset.data.joint_pos[:, asset_cfg.joint_ids] - asset.data.default_joint_pos[:, asset_cfg.joint_ids]), dim=1
|
||||
(asset.data.joint_pos[:, asset_cfg.joint_ids] - asset.data.default_joint_pos[:, asset_cfg.joint_ids]), dim=1, ord=1
|
||||
)
|
||||
reward = torch.where(
|
||||
torch.logical_or(cmd > command_threshold, body_vel > velocity_threshold),
|
||||
running_reward,
|
||||
stand_still_scale * running_reward,
|
||||
)
|
||||
reward *= torch.clamp(-env.scene["robot"].data.projected_gravity_b[:, 2], 0, 0.7) / 0.7
|
||||
return reward
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user