1 下載相關檔案
進入github中下載相關的檔案
https://github.com/leggedrobotics/legged_gym
2 載入自己繪製的URTL檔案
這個連結用來下載宇樹的Go2模型機器人
https://github.com/unitreerobotics/unitree_rl_gym/tree/main
下載好了urdf檔案,將其中resources/robots/go2檔案複製到legged_gym/resources/robots/目錄下
這樣就把機器人模型檔案載入好了
在下面這個檔案修改:
from legged_gym import LEGGED_GYM_ROOT_DIR, LEGGED_GYM_ENVS_DIR
from legged_gym.envs.a1.a1_config import A1RoughCfg, A1RoughCfgPPO
from .base.legged_robot import LeggedRobot
from .anymal_c.anymal import Anymal
from .anymal_c.mixed_terrains.anymal_c_rough_config import AnymalCRoughCfg, AnymalCRoughCfgPPO
from .anymal_c.flat.anymal_c_flat_config import AnymalCFlatCfg, AnymalCFlatCfgPPO
from .anymal_b.anymal_b_config import AnymalBRoughCfg, AnymalBRoughCfgPPO
from .cassie.cassie import Cassie
from .cassie.cassie_config import CassieRoughCfg, CassieRoughCfgPPO
from .a1.a1_config import A1RoughCfg, A1RoughCfgPPO
from .go2.go2_config import GO2RoughCfg, GO2RoughCfgPPO # 新增的
import os
from legged_gym.utils.task_registry import task_registry
task_registry.register( "anymal_c_rough", Anymal, AnymalCRoughCfg(), AnymalCRoughCfgPPO() )
task_registry.register( "anymal_c_flat", Anymal, AnymalCFlatCfg(), AnymalCFlatCfgPPO() )
task_registry.register( "anymal_b", Anymal, AnymalBRoughCfg(), AnymalBRoughCfgPPO() )
task_registry.register( "a1", LeggedRobot, A1RoughCfg(), A1RoughCfgPPO() )
task_registry.register( "cassie", Cassie, CassieRoughCfg(), CassieRoughCfgPPO() )
task_registry.register( "go2", LeggedRobot, GO2RoughCfg(), GO2RoughCfgPPO() ) # 新增的
這樣就可以執行程式碼訓練機器人了