Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions training/playground/common/rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ def cost_action_rate(act: jax.Array, last_act: jax.Array) -> jax.Array:
return c1


def cost_action_jerk(
act: jax.Array, last_act: jax.Array, last_last_act: jax.Array
) -> jax.Array:
"""Penalize jerky actions - second derivative of action for smoother motion."""
action_accel = act - 2 * last_act + last_last_act
return jp.nan_to_num(jp.sum(jp.square(action_accel)))


# Other rewards.


Expand Down
7 changes: 6 additions & 1 deletion training/playground/open_duck_mini_v2/joystick.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
reward_tracking_ang_vel,
cost_torques,
cost_action_rate,
cost_action_jerk,
cost_stand_still,
reward_alive,
reward_foot_height_tracking,
Expand Down Expand Up @@ -81,7 +82,8 @@ def default_config() -> config_dict.ConfigDict:
tracking_ang_vel=6.0,
torques=-1.0e-3,
action_rate=-0.5, # was -1.5
stand_still=-0.2, # was -1.0 TODO try to relax this a bit ?
action_jerk=-0.1, # smoothness penalty for character-like motion
stand_still=-0.2, # was -1.0 TODO try to relax this a bit ?
alive=20.0,
imitation=1.0,
foot_height_tracking=0.5,
Expand Down Expand Up @@ -648,6 +650,9 @@ def _get_reward(
),
"torques": cost_torques(data.actuator_force),
"action_rate": cost_action_rate(action, info["last_act"]),
"action_jerk": cost_action_jerk(
action, info["last_act"], info["last_last_act"]
),
"alive": reward_alive(),
"imitation": reward_imitation(
self.get_floating_base_qpos(data.qpos),
Expand Down