MCPcopy Index your code
hub / github.com/AgibotTech/agibot_x1_train

github.com/AgibotTech/agibot_x1_train @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
267 symbols 656 edges 27 files 77 documented · 29%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

English | 中文

简介

智元灵犀X1 是由智元研发并开源的模块化、高自由度人形机器人,X1的软件系统基于智元开源组件 AimRT 作为中间件实现,并且采用强化学习方法进行运动控制。

本工程为智元灵犀X1所使用的强化学习训练代码,可配合智元灵犀X1配套的推理软件进行真机和仿真的行走调试,或导入其他机器人模型进行训练。

代码运行

安装依赖

  1. 创建一个新的python3.8虚拟环境:
  2. conda create -n myenv python=3.8.
  3. 安装 pytorch 1.13 和 cuda-11.7:
  4. conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia
  5. 安装 numpy-1.23:
  6. conda install numpy=1.23.
  7. 安装 Isaac Gym:
  8. 下载并安装 Isaac Gym Preview 4 https://developer.nvidia.com/isaac-gym.
  9. cd isaacgym/python && pip install -e .
  10. Run an example with cd examples && python 1080_balls_of_solitude.py.
  11. Consult isaacgym/docs/index.html for troubleshooting.
  12. 安装训练代码依赖:
  13. Clone this repository.
  14. pip install -e .

使用

Train:

python scripts/train.py --task=x1_dh_stand --run_name=<run_name> --headless - 训练好的模型会存/log/<experiment_name>/exported_data/<date_time><run_name>/model_<iteration>.pt 其中 <experiment_name> 在config文件中定义.

Play:

python /scripts/play.py --task=x1_dh_stand --load_run=<date_time><run_name>

生成jit模型:

python scripts/export_policy_dh.py --task=x1_dh_stand --load_run=<date_time><run_name> - jit模型会存在 log/exported_policies/<date_time>

生成onnx模型:

python scripts/export_onnx_dh.py --task=x1_dh_stand --load_run=<date_time> - onnx模型会存在 log/exported_policies/<date_time>

参数说明:

  • task: Task name
  • resume: Resume training from a checkpoint
  • experiment_name: Name of the experiment to run or load.
  • run_name: Name of the run.
  • load_run: Name of the run to load when resume=True. If -1: will load the last run.
  • checkpoint: Saved model checkpoint number. If -1: will load the last checkpoint.
  • num_envs: Number of environments to create.
  • seed: Random seed.
  • max_iterations: Maximum number of training iterations.

添加新环境

1.在 envs/目录下创建一个新文件夹,在新文件夹下创建一个配置文件<your_env>_config.py和环境文件<your_env>_env.py,这两个文件要分别继承LeggedRobotCfgLeggedRobot

2.将新机器的urdf, mesh, mjcf放到 resources/文件夹下 - 在<your_env>_config.py里配置新机器的urdf path,PD gain,body name, default_joint_angles, experiment_name等

3.在humanoid/envs/__init__.py里注册你的新机器

sim2sim

使用mujoco来进行sim2sim验证: python scripts/sim2sim.py --task=x1_dh_stand --load_model /path/to/exported_policies/

手柄使用

我们使用Logitech f710手柄,在启动play.py和sim2sim.py时,按住4的同时转动摇杆可以控制机器人前后,左右和旋转。 | 按键 | 命令 | | -------------------- |:--------------------:| | 4 + 1- | 前进 | | 4 + 1+ | 后退 | | 4 + 0- | 左平移 | | 4 + 0+ | 右平移 | | 4 + 3- | 逆时针旋转 | | 4 + 3+ | 顺时针旋转 |

目录结构

.
|— humanoid           # 主要代码目录
|  |—algo             # 算法目录
|  |—envs             # 环境目录
|  |—scripts          # 脚本目录
|  |—utilis           # 工具、功能目录
|— logs               # 模型目录
|— resources          # 资源库
|  |— robots          # 机器人urdf, mjcf, mesh
|— README.md          # 说明文档

参考项目:

Core symbols most depended-on inside this repo

get_euler_xyz_tensor
called by 7
humanoid/envs/base/legged_robot.py
class_to_dict
called by 6
humanoid/utils/helpers.py
get_args
called by 6
humanoid/utils/helpers.py
get_cfgs
called by 6
humanoid/utils/task_registry.py
_get_stance_mask
called by 5
humanoid/envs/x1/x1_dh_stand_env.py
clear
called by 5
humanoid/algo/ppo/rollout_storage.py
save
called by 4
humanoid/algo/ppo/dh_on_policy_runner.py
load
called by 4
humanoid/algo/ppo/dh_on_policy_runner.py

Shape

Method 175
Class 62
Function 30

Languages

Python100%

Modules by API surface

humanoid/envs/x1/x1_dh_stand_env.py53 symbols
humanoid/envs/base/legged_robot.py44 symbols
humanoid/utils/logger.py22 symbols
humanoid/envs/x1/x1_dh_stand_config.py22 symbols
humanoid/envs/base/legged_robot_config.py22 symbols
humanoid/algo/ppo/actor_critic_dh.py13 symbols
humanoid/algo/ppo/rollout_storage.py11 symbols
humanoid/utils/terrain.py9 symbols
humanoid/scripts/sim2sim.py9 symbols
humanoid/envs/base/base_task.py9 symbols
humanoid/algo/ppo/dh_ppo.py9 symbols
humanoid/utils/helpers.py8 symbols

For agents

$ claude mcp add agibot_x1_train \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page