Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ポリシー確認時のエージェントの転倒回数計測とリセット機能のオミット #2

Open
aiba0921 opened this issue Dec 1, 2024 · 1 comment

Comments

@aiba0921
Copy link
Collaborator

aiba0921 commented Dec 1, 2024

各パラメータにおいて生成されたポリシーについて客観的な評価を行うためエージェントの転倒回数、その時間とエージェントのリセット機能のオミットを行った。

エージェントの転倒回数とその時間の計測

play.pyに以下のようなコードを追加した。以下のコードによって転倒したエージェントの番号、転倒した総数、全てのエージェントが点灯するまでにかかった時間がターミナルに表示されるようになっている

    obs, _ = env.get_observations()
    timestep = 0
    removed_agents = set()
    removed_agents_count = 0
    total_agents = env.num_envs
    start_time = time.time()
    last_checkpoint_time = start_time
    # simulate environment
    while simulation_app.is_running():
        # run everything in inference mode
        with torch.inference_mode():
            # agent stepping
            actions = policy(obs)
            # env stepping
            obs, reward, done, info = env.step(actions)
            current_time = time.time()
            
            if current_time - last_checkpoint_time >= 10:
                elapsed_time = current_time - start_time
                print(f"[INFO] Elapsed time: {elapsed_time:.2f} seconds.")
                last_checkpoint_time = current_time
            
            for idx, is_done in enumerate(done):
                if is_done and idx not in removed_agents:
                    removed_agents.add(idx)
                    removed_agents_count += 1
                    print(f"[INFO] Agent {idx} has fallen. Total fallen: {removed_agents_count}")
                   
            if removed_agents_count == total_agents:
                elapsed_time = current_time - start_time
                print(f"[INFO] All agents have fallen at {elapsed_time:.2f} seconds.")
                break
            for idx in removed_agents:
               actions[idx] = 0
            obs, reward, done, info = env.step(actions)

リセット機能のオミット

source/extensions/omni.isaac.lab_tasks/omni/isaac/lab_tasks/manager_based/locomotion/velocity/config/g1/rough_env_cfg.py
source/extensions/omni.isaac.lab_tasks/omni/isaac/lab_tasks/manager_based/locomotion/velocity/velocity_env_cfg.pyの2つのファイルからreset_baseをコメントアウトしてリセット機能をオミットした。こうすることでエージェントは転倒などが起こってもリセットがかからないため前述のカウント機能によって何度も同じエージェントが転倒するのを計測し続けるようなことがなくなる。リセット機能はこの両方をコメントアウトしないと切ることはできない

@aiba0921
Copy link
Collaborator Author

aiba0921 commented Dec 1, 2024

カウント時の様子
カウント機能の追加とリセット機能のオミットはできたが、リセット後のエージェントがの残り続けているため非常に見づらい
2024-12-01_15-05-19.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant