论文复现Pushing and Grasping Policies

论文题目:Self-Supervised Learning for Joint Pushing and Grasping Policies in Highly Cluttered Environments

论文地址:https://arxiv.org/abs/2203.02511

论文代码:GitHub - Kamalnl92/Self-Supervised-Learning-for-pushing-and-grasping

使用readme中的Method 2 (Ubuntu 20.04)

  • Python 3.8
  • CoppeliaSim_Edu_V4_2_0_Ubuntu20_04

1.首先,下载代码解压到主目录下命名为pushing_and_grasping。Robot simulator CoppeliaSim: create, compose, simulate, any robot - Coppelia Robotics下载ubuntu20.4对应版本的压缩包,解压至主目录下。

然后,在~/pushing_and_grasping目录下打开终端,创建虚拟环境,使用第二行创建成功。接着,激活虚拟环境。

conda create -n push_grasp python=3.8
conda create -n push_grasp python=3.8 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

conda activate push_grasp

开始使用第一行配置环境,报错显示哈希值不匹配,可能还有网络的原因,期间尝试过换成清华源,于是先清除通道再开始一个库一个库的进行安装,

在电脑上使用GPU训练的话,安装对应的GPU版本的pytorch,安装torchvision。其中,-c pytorch -c conda-forge是指从 pytorch和conda-forge这两个频道安装包。

 conda install pytorch==1.10.1 cudatoolkit=11.3 -c pytorch -c conda-forge

 conda install torchvision==0.11.2 -c pytorch -c conda-forge

pip install -r requirementsMethod2.txt

pip cache purge

pip install matplotlib==3.5.1
pip install numpy==1.22.1
pip install opencv-python==4.5.5.62
pip install tensorboardX == 2.4.1
pip install trimesh == 3.9.42
pip install scikit-image==0.19.1
pip install scipy==1.7.3
#pip install torch==1.10.1安装没有成功,使用下面一行成功安装
pip install torch==1.10.1 torchvision==0.11.2 -i https://pypi.doubanio.com/simple
Looking in indexes: https://pypi.doubanio.com/simple

#使用这个命令,返回可以看到需要的库都已经安装
pip list | grep -E "torch|torchvision|matplotlib|numpy|opencv-python|tensorboardX|trimesh|scikit-image|scipy"

2.训练模型

直接执行第一个命令,报错关于protobuf 库版本问题,使用 pipprotobuf 包降级到 3.20.x 版本。

# Grasp Goal agnostic
python main.py --stage grasp_only --num_obj 5 --goal_conditioned --goal_obj_idx 4 --experience_replay --explore_rate_decay --save_visualizations

#第一个错误,使用 pip 将 protobuf 包降级到 3.20.x 版本
pip install protobuf==3.20.0

再次执行第一个命令,出现另外一个错误,无法连接到CoppeliaSim(以前称为V-REP)的远程API服务器,于是,在~/CoppeliaSim_Edu_V4_7_0_rev4_Ubuntu20_04下打开一个终端,输入 ./coppeliaSim.sh,成功启动CoppeliaSim。然后,在CoppeliaSim中,点击“File” > “Open scene...”,导航到项目的simulation目录,选择并打开 simulation.ttt 文件。再次执行第一个命令,终端显示AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS',也就是报错是由于PIL库的版本更新导致的API变动所致,于是卸载重装。

pip uninstall pillow
pip install pillow==6.2.2

但执行后也有报错如下,说当前安装的 imageio 库要求的 pillow 版本与你尝试安装的 pillow==6.2.2 版本不兼容导致的。imageio 要求的 pillow 最低版本为 8.3.2,而你尝试安装的是 6.2.2 版本,二者存在冲突。目前没有管它,再次执行第一个命令。

后来你电脑上下载的Pillow==9.0.0版本,没有说不兼容的问题。

pip install Pillow==9.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install pillow==6.2.2

Collecting pillow==6.2.2
  Downloading Pillow-6.2.2-cp38-cp38-manylinux1_x86_64.whl.metadata (4.8 kB)
Downloading Pillow-6.2.2-cp38-cp38-manylinux1_x86_64.whl (2.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 509.5 kB/s eta 0:00:00
Installing collected packages: pillow
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
imageio 2.34.2 requires pillow>=8.3.2, but you have pillow 6.2.2 which is incompatible.
Successfully installed pillow-6.2.2

出现效果如下,刚开始打开 simulation.ttt 文件是没有五个积木的,运行第一条命令后才会出现(从天而降),并且机械臂尝试抓取积木,但我这里因为CUDA内存不足导致出问题,PyTorch尝试分配额外的内存超出了GPU的可用限制,只进行了一次就终止了。

最后,看CoppeliaSim中的返回值,在终端安装了两个库。

pip install pyzmq cbor2

你可能感兴趣的:(linux,机器人,机器学习)