Skip to content

tyofushun5/rcj-soccer-reinforcement-learning-bullet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RCJ Soccer Reinforcement Learning (PyBullet)

PyBullet 上に RoboCup Junior サッカーの試合環境を再現し、Gymnasium 環境と Stable-Baselines3 (PPO / RecurrentPPO) を用いた学習スクリプトをまとめたリポジトリです。ローカル実行から大規模並列実行まで同じ環境で学習できます。

  • シミュレーション環境
    Simulation environment
  • 実機ロボット
    Real robot example

動作要件

  • Python 3.10
  • PyBullet 自体は CPU 実行。学習速度を上げたい場合のみ GPU(CUDA)があると便利です。GPU を使わない場合はスクリプト内の device='cuda'cpu に変更してください。
  • 主要依存関係: pybullet, gymnasium, stable-baselines3[extra], sb3-contrib

セットアップ

ローカル (pip)

git clone https://github.com/tyofushun5/rcj-soccer-reinforcement-learning-bullet.git
cd RCJ_Reinforcement_learning
python -m venv .venv
.\.venv\Scripts\activate         # Windows
# source .venv/bin/activate      # Linux / macOS
pip install -U pip
pip install -r requirements.txt

Docker (NVIDIA GPU用)

  • 大規模CPUサーバで環境を分散学習する用
git https://github.com/tyofushun5/rcj-soccer-reinforcement-learning-bullet.git
cd RCJ_Reinforcement_learning
docker build -t rcj-rl -f docker/Dockerfile .
docker run --gpus all -it --rm -v %cd%:/workspace rcj-rl bash         # PowerShell
# docker run --gpus all -it --rm -v $(pwd):/workspace rcj-rl bash     # Linux / macOS

使い方

  • 単一環境で PPO 学習(GUI あり): python -m rcj_soccer_reinforcement_learning_pybullet.train.train
  • 20 並列環境で RecurrentPPO 学習(ヘッドレス): python -m rcj_soccer_reinforcement_learning_pybullet.dispersion_train.dispersion_train
  • 256 並列の大規模 RecurrentPPO(大規模CPUサーバ 向け): python -m rcj_soccer_reinforcement_learning_pybullet.gpgpu_dispersion_train.gpgpu_dispersion_train
  • 学習済みモデルのプレビュー(GUI): python -m rcj_soccer_reinforcement_learning_pybullet.preview.preview
    • 利用したいモデルに合わせて rcj_soccer_reinforcement_learning_pybullet/preview/preview.pymodel_path.zip ファイル(例: model/default_model/default_model.zip)へ変更してください。

チェックポイントは rcj_soccer_reinforcement_learning_pybullet/model/default_model/ に保存されます。実行環境に応じて各スクリプト内の total_timestepsnum_envs を調整してください。

環境仕様

  • 行動空間: 2 次元連続値(角度・回転)を [-1.0, 1.0] で出力
  • 観測空間: 4 次元ベクトル(ボール角度、敵ゴール角度、自ゴール角度の正規化値 + オンライン接触フラグ)
  • reset 時にロボットとボールをランダム配置し、両者の距離が 0.18m 未満にならないよう制約
  • GUI 表示に対応(学習はヘッドレス推奨)

ディレクトリ構成

  • rcj_soccer_reinforcement_learning_pybullet/environment/: Gymnasium 環境定義
  • rcj_soccer_reinforcement_learning_pybullet/train/: 単一環境 PPO 学習
  • rcj_soccer_reinforcement_learning_pybullet/dispersion_train/: 並列 RecurrentPPO 学習
  • rcj_soccer_reinforcement_learning_pybullet/gpgpu_dispersion_train/: 大規模並列版
  • rcj_soccer_reinforcement_learning_pybullet/preview/: 学習済みモデルの可視化
  • rcj_soccer_reinforcement_learning_pybullet/object/: コート・ロボット・STL メッシュ
  • rcj_soccer_reinforcement_learning_pybullet/reward_function/: 報酬計算
  • rcj_soccer_reinforcement_learning_pybullet/tools/: 角度・距離計算ツール

ライセンス

  • 本リポジトリは MIT License で公開しています。
  • 利用・改変・再配布は自由ですが、著作権表示とライセンス全文(LICENSE)の同梱が必要です。
  • Issue や PR への提案も歓迎します。利用時の注意点・制限事項は LICENSE を参照してください。

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors