本帖最后由 kiara 于 2024-9-13 10:10 编辑
本片内容会对aloha在虚拟环境的任务进行逐一复现,包含详细内容和常见错误解决方案。
数据采集模块从仿真/样机收集数据,采集内容包括'top', 'left_wrist', 'right_wrist'3个相机RGB图像(3,3,630,480),以及双臂关节角qpos,actions。输出为h5df统一格式。
- conda create -n aloha python=3.8.10
- conda activate aloha
- pip install torchvision
- pip install torch
- pip install pyquaternion
- pip install pyyaml
- pip install rospkg
- pip install pexpect
- pip install mujoco==2.3.7
- pip install dm_control==1.0.14
- pip install opencv-python
- pip install matplotlib
- pip install einops
- pip install packaging
- pip install h5py
- pip install ipython
- cd act/detr && pip install -e .
复制代码
安装 Robomimic https://github.com/ARISE-Initiative/robomimic/tree/r2d2 (note the r2d2 branch) 为了使用 Diffusion Policy
模拟实验,请运行:
- <pre class="ace-line ace-line old-record-id-KfbJdHaMhoGteex2tiycGxAgnph"><code class="language-Plain Text" data-lark-language="Plain Text" data-wrap="false">python3 record_sim_episodes.py --task_name sim_transfer_cube_scripted --dataset_dir <data save dir> --num_episodes 50</code></pre>
复制代码 加flag --onscreen_render 可视化模拟实验
可视化收集的模拟实验,请运行:
- python3 visualize_episodes.py --dataset_dir <data save dir> --episode_idx 0
复制代码 视频和曲线图会存入数据存储的路径
#Transfer Cube task- python3 imitate_episodes.py --task_name sim_transfer_cube_scripted --ckpt_dir <ckpt dir> --policy_class ACT --kl_weight 10 --chunk_size 100 --hidden_dim 512 --batch_size <span style="font-family: Tahoma, "Microsoft Yahei", Simsun;">8 --dim_feedforward 3200 --num_epochs 5000 --lr 1e-5 --seed </span><span style="background-color: rgb(255, 255, 255); font-family: Tahoma, "Microsoft Yahei", Simsun;">0</span>
复制代码 结果:
Training finished:Seed 0, val loss 0.187290 at step 2000Best ckpt, val loss 0.187290 @ step2000evaluate the policy, run the same command but add --eval:
policy_last.ckpt: success_rate=0.2 avg_return=86.6
按照GitHub设置的2000steps,在10个episodes10中成功2个。但是作者给出了90%的正确率。考虑可能有参数设置的原因和mujoco版本不同导致。
并且在训练过程中会有 Warning: step duration: 0.033 s at step 399 longer than DT: 0.02 s, culmulated delay: 1.005 s 的警告,应该是由于电脑硬件性能低,超过了测试的规定时间导致的。
将steps提高到5000后,结果:
Training finished:Seed 0, val loss 0.119787 at step 4500Best ckpt, val loss 0.119787 @ step4500--eval:
policy_last.ckpt: success_rate=0.5 avg_return=362.6加flag--onscreen_render可视化:这不禁让我想设10000steps看看会不会100%:
Training finished:Seed 0, val loss 0.069404 at step 10000Best ckpt, val loss 0.069404 @ step10000policy_last.ckpt: success_rate=0.5 avg_return=352.6不会。
设到40000steps后可以达到100%的成功率:
Training finished:Seed 0, val loss 0.024802 at step 33500Best ckpt, val loss 0.024802 @ step33500policy_last.ckpt: success_rate=1.0 avg_return=628.0
可能遇到的BUG- 报错:ModuleNotFoundError: No module named 'robomimic.algo.diffusion_policy':
conda activate 环境pip uninstall robomimiccd somewhere && git clone https://github.com/ARISE-Initiative/robomimic.gitcd somewhere/robomimic && git checkout diffusion-policy-mgpip install -e .
- 报错: mujoco.FatalError: gladLoadGL error
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
http://t.csdnimg.cn/IKvyN
在网站成功登录后始终无法获得权限,可以把所有相关行注释掉
- 报错:TypeError: forward() got an unexpected keyword argument 'pos'
在位置 detr/models/detr_vae.py 第 285 行,更改 build_transformer 为 build_encoder
https://github.com/MarkFzp/act-plus-plus/issues/3#top
|