Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions conf/appo/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ training:
no_play: false
load_run: "-1"
play_env_num: 16
play_steps: 1000
Comment thread
caozx1110 marked this conversation as resolved.
Outdated
cam_distance: 6.0
cam_elevation: -20.0
cam_azimuth: 90.0
replay_queue_size: null

hydra:
Expand Down
21 changes: 21 additions & 0 deletions conf/appo/reward/g1_motion_tracking.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# @package _global_
reward:
scales:
motion_global_root_pos: 0.5
motion_global_root_ori: 0.5
motion_body_pos: 1.0
motion_body_ori: 1.0
motion_body_lin_vel: 1.0
motion_body_ang_vel: 1.0
motion_joint_pos: 0.0
motion_joint_vel: 0.0
action_rate_l2: -0.1
joint_limit: -10.0
std_root_pos: 0.3
std_root_ori: 0.4
std_body_pos: 0.3
std_body_ori: 0.4
std_body_lin_vel: 1.0
std_body_ang_vel: 3.14
std_joint_pos: 0.2
std_joint_vel: 1.0
12 changes: 12 additions & 0 deletions conf/appo/task/g1_motion_tracking.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @package _global_
defaults:
- override /reward: g1_motion_tracking

training:
task_name: G1MotionTracking
play_steps: 1000

algo:
num_envs: 1024
max_iterations: 5000
save_interval: 500
19 changes: 14 additions & 5 deletions scripts/train_appo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@


def ensure_registries():
for pkg_name in ("unilab.envs.locomotion", "unilab.envs.manipulation"):
for pkg_name in (
"unilab.envs.locomotion",
"unilab.envs.manipulation",
"unilab.envs.motion_tracking",
):
try:
package = importlib.import_module(pkg_name)
if hasattr(package, "__path__"):
Expand Down Expand Up @@ -147,13 +151,11 @@ def play_appo(cfg: DictConfig, rl_cfg: dict):
if env.state is None:
env.init_state()
env_indices = np.arange(cfg.training.play_env_num, dtype=np.int32)
from unilab.utils.obs_utils import flatten_obs_dict

obs_out, _ = env.reset(env_indices)
obs_np = np.asarray(obs_out["obs"], dtype=np.float32)

state_list = []
num_steps = 150
num_steps = int(getattr(cfg.training, "play_steps", 1000))

print("Collecting physics states...")
with torch.inference_mode():
Expand All @@ -168,7 +170,14 @@ def play_appo(cfg: DictConfig, rl_cfg: dict):

print("Rendering frames...")
frames = render_many.render_states_get_frames(
state_list, env.cfg.model_file, width=1280, height=720, camera_id=-1
state_list,
env.cfg.model_file,
width=1280,
height=720,
camera_id=-1,
cam_distance=cfg.training.cam_distance,
cam_elevation=cfg.training.cam_elevation,
cam_azimuth=cfg.training.cam_azimuth,
)
Comment on lines 157 to 181

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

play_appo currently renders all frames into memory (frames = render_states_get_frames(...)) before writing the video. Increasing the default play_steps to 1000 can easily create multi-GB frame lists at 1280x720 (and OOM) even with a modest number of steps/envs. Consider keeping the historical default (150) here and only overriding training.play_steps in task-specific configs that truly need longer videos, or refactoring playback to stream/chunk frames instead of accumulating them all at once.

Copilot uses AI. Check for mistakes.

print(f"Saving video to {output_video} with mediapy...")
Expand Down
6 changes: 5 additions & 1 deletion src/unilab/utils/algo_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

def ensure_registries():
"""Import all env modules so they are registered."""
for pkg_name in ("unilab.envs.locomotion", "unilab.envs.manipulation"):
for pkg_name in (
"unilab.envs.locomotion",
"unilab.envs.manipulation",
"unilab.envs.motion_tracking",
):
try:
package = importlib.import_module(pkg_name)
if hasattr(package, "__path__"):
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/test_train_script_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@pytest.mark.veryslow
@pytest.mark.parametrize(
"task",
["go1_joystick", "go2_joystick", "g1_joystick"],
["go1_joystick", "go2_joystick", "g1_joystick", "g1_motion_tracking"],
)
def test_appo_task_configs_load(task):
"""APPO can start training with all task configs."""
Expand Down
Loading