论文复现--ASE: Large-Scale Reusable Adversarial Skill Embeddings for Physically Simulated Characters

分类:行为仿真
github地址:https://github.com/xbpeng/DeepMimic
所需环境:Windows10,Anaconda4.12.0,Visual Stdio 2019(其他也可)

1.安装CMake

下载地址[1]

https://cmake.org/download/

直接下载CMake二进制压缩包。

在这里插入图片描述
下载完成后,直接解压。 其中bin目录下的exe就是CMake编译工具,可以直接用。

在这里插入图片描述

2.用Ananconda创建python3.6环境

conda create -n DeepMimic python=3.6 

为什么要创建python3.6环境?因为作者使用的 TensorFlow版本是1.13.1,经查询[2],对应的Python版本是python3.6。见下图:
在这里插入图片描述

3.安装Bullet2.88

下载地址

https://github.com/bulletphysics/bullet3/releases

在这里插入图片描述
解压 bullet3-2.88.zip 为 bullet3CMake-2.88 ,在 bullet3CMake-2.88 里新建一个 build 文件夹[3]

在这里插入图片描述
CMake选择源码路径:
D:/Wlm_Project/MotionSimulated/1.DeepMimic_SIGGRAPH2018/DeepMimic/3rdparty/bullet3CMake-2.88
编译路径:
D:/Wlm_Project/MotionSimulated/1.DeepMimic_SIGGRAPH2018/DeepMimic/3rdparty/bullet3CMake-2.88/build
勾选Advanced选项后,点击Configure
在这里插入图片描述
生成器选择VS2019 生成器平台选择x64,点击Finish。
在这里插入图片描述
显示 Configuring done 后,再点击 Generate。
在这里插入图片描述
显示 Generating done 即可。
在这里插入图片描述
用VS2019打开 ALL_BUILD.vcxproj。
在这里插入图片描述

配置管理器选择Release x64[12]
在这里插入图片描述

右键 ALL_BUILD 项目,点击生成。
在这里插入图片描述
如下为编译结束。
在这里插入图片描述

进入/build/lib/Release,可看到已经生成的Release x64 .lib 库文件[11]
在这里插入图片描述

至此,Release版的Bullet库文件已经成功生成,Debug版操作类似,在选择配置管理器的时候选Debug就可以。

至于作者说的:

be sure to disable double precision with the build flag USE_DOUBLE_PRECISION=OFF.

经查阅资料[12],对应于本机环境应该是这样实现的: 打开ALL_BUILD.vcxproj 后,找到Bullet3Dynamic ,BulletCollation, linearMath三个项目,右键属性-C/C+±预处理器-预处理器定义,删掉第二行BT_USE_DOUBLE_PRECISION。

但是实际上预处理器定义并没有此选项,应该是多年过去了,Bullet官方修改了这个预定义吧。
在这里插入图片描述

4.安装Eigen3.3.7

下载地址

https://gitlab.com/libeigen/eigen/-/releases

在这里插入图片描述
首先在eigen-3.3.7目录下建造两个空文件夹。installbuild [4]

在这里插入图片描述
打开cmake-gui.exe。

源码路径(CMakeList.txt所在路径)选择:
D:/Wlm_Project/MotionSimulated/1.DeepMimic_SIGGRAPH2018/DeepMimic/3rdparty/eigen-3.3.7/eigen-3.3.7
构建路径选择(build文件夹路径):
D:/Wlm_Project/MotionSimulated/1.DeepMimic_SIGGRAPH2018/DeepMimic/3rdparty/eigen-3.3.7/eigen-3.3.7/build
勾选Advanced后,点击Configure
在这里插入图片描述
选择生成适配于VS2019x64的工程,之后点击Finish。
在这里插入图片描述
直到显示 Configuring done。
在这里插入图片描述
在Search输入框中输入INSTALL_PREFIX找到安装目录前缀(CMAKE_INSTALL_PREFIX),value修改为刚才创建的 install 目录,重新点击Configure.。
在这里插入图片描述
在这里插入图片描述

再一次看到 Configuring down 之后点击 Generate 按钮;过程很快就可以看到Generating done,这时候就可以关闭 Cmake 了;
在这里插入图片描述
用VS2019打开build里的Eigen3.sln,在vs2019中菜单栏点击 生成—>批生成,弹出批生成界面,勾选ALL_BuildDebugRelease,然后点击生成按钮;(由于Eigen3只生成头文件,而不生成二进制文件,无所谓Debug和Release,所以也可以只选择其中一个)。

在这里插入图片描述
稍等一会就可以看到编译完成。
在这里插入图片描述
然后再一次点生成—>批生成,弹出批生成界面,取消勾选 ALL_BUILD Debug Release,勾选 INSTALLDebugRelease,然后点击“生成”按钮;(由于Eigen3只生成头文件,而不生成二进制文件,无所谓Debug和Release,所以也可以只选择其中一个)
在这里插入图片描述
这个过程很快结束,找到刚才创建的install目录,可以发现编译生成的文件已经拷贝进来了;
在这里插入图片描述

在这里插入图片描述

注意:Eigen3不需要动态库,只会生成头文件,所以不区分32位还是64位,都可以正常使用。配置VS2019的时候,仅需包含头文件即可,不用包含库文件。

5.安装freeglut3.0.0

下载地址

https://freeglut.sourceforge.net/

在这里插入图片描述
还是需要用到CMake进行编译,首先创建build文件夹[5]
在这里插入图片描述
打开Cmake设置路径
源码路径:
D:/Wlm_Project/MotionSimulated/1.DeepMimic_SIGGRAPH2018/DeepMimic/3rdparty/freeglut-3.0.0/freeglut-3.0.0
构建路径:
D:/Wlm_Project/MotionSimulated/1.DeepMimic_SIGGRAPH2018/DeepMimic/3rdparty/freeglut-3.0.0/freeglut-3.0.0/build

在这里插入图片描述
点击Generate,继续配置如下(用VS2019编译64位的源码)。
在这里插入图片描述
点击Finish

配置完毕后,点击红色箭头的Generate。
在这里插入图片描述
生成完毕。
在这里插入图片描述
打开D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\freeglut-3.0.0\freeglut-3.0.0\build文件夹,打开.sln工程文件。 修改配置管理器为Release x64[12]。右键-重新生成解决方案,开始进行编译
在这里插入图片描述

生成完毕。
在这里插入图片描述

6.安装glew2.1.0

下载地址

https://glew.sourceforge.net/

为了省事,直接下载预编译版本[6]

在这里插入图片描述
下载完成后,直接解压即可。
在这里插入图片描述

7.安装SWIG4.0.0

下载地址

https://www.swig.org/

在这里插入图片描述
在这里插入图片描述

本着尊重作者的原则,要先看README文件,了解怎么安装(事实证明,看README确实不如上网直接查方便!!!)。

Installation
============
Please read the Doc/Manual/Preface.html#Preface_installation for full installation instructions for Windows, Unix and Mac OS X using the release tarball/zip file. The INSTALL file has generic build and installation instructions for Unix users.
Users wishing to build and install code from Github should visit https://swig.org/svn.html to obtain the more detailed instructions required for building code obtained from Github - extrasteps are required compared to building from the release tarball.

好,继续查看 Doc/Manual/Preface.html文件

1.12.1 Windows installation
Please see the dedicated Windows chapter for instructions on installing SWIG on Windows and running the examples. The Windows distribution is called swigwin and includes a prebuilt SWIG executable, swig.exe, included in the top level directory. Otherwise it is exactly the same as the main SWIG distribution. There is no need to download anything else.

简直就像在套娃,继续查看Windows Chapter

3.1 Installation on Windows
SWIG does not come with the usual Windows type installation program, however it is quite easy to get started. The main steps are:
Download the swigwin zip package from the SWIG website and unzip into a directory. This is all that needs downloading for the Windows platform.
Set environment variables as described in the SWIG Windows Examples section in order to run examples using Visual C++.
3.1.1 Windows Executable
The swigwin distribution contains the SWIG Windows 32-bit executable, swig.exe, which will run on both 32-bit and 64-bit versions of Windows. If you want to build your own swig.exe have a look at Building swig.exe on Windows.

原来只需要下载swigwin再解压,接着配置个环境变量即可[7]。而且作者也说了,虽然是32位exe,但是在32和64的win上都可运行。

重新下载也不费事(真的我哭死~~~~)
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
解压,可以看到解压目录中有可执行文件swig.exe。
在这里插入图片描述
接下来将该路径添加到系统环境变量中。环境变量-系统变量-新建。

变量名:SWIG_DIR
变量值(swig.exe所在路径):D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\swigwin-4.0.0\swigwin-4.0.0
在这里插入图片描述

点击确定确定确定,生效环境变量!

在cmd中测试下:

swig –version

输出版本号即可。
在这里插入图片描述

8.安装MPI10.1.1

注意:MPI一定要在MPI4Py之前安装好

下载地址

https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi

在这里插入图片描述
这个作者没说他安装的哪个版本,所以我下载个2019年早期的MS-MPI v10.1.1,太新的版本怕不兼容主程序[8]
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

看一下他的安装指导。
在这里插入图片描述
额,让我执行它的安装程序,然后按照指导安装即可。

我在3rdparty下,新建了一个 MPI-10.1.1 文件夹,把 exe 和 msi 挪进去。又新建一个 setup 和 setupSDK 文件夹供安装。
在这里插入图片描述

双击运行msmpisetup.exe。
在这里插入图片描述
点击next。

在这里插入图片描述
点击I accept,next。
在这里插入图片描述
安装路径改为D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\MPI-10.1.1\setup 点击Next,最后点击Install。
在这里插入图片描述

点击Finish。

setup会有这几个。每个夹下都是exe。
在这里插入图片描述
双击运行msmpisdk.msi,安装SDK。
在这里插入图片描述
点击Next。
在这里插入图片描述
依然是I accept,Next。
在这里插入图片描述

安装路径改为D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\MPI-10.1.1\setupSDK点击Next,最后点击Install。
在这里插入图片描述
最后点击Finish。
在这里插入图片描述
setupSDK会有这几个。安装完毕!

9.配置Anaconda环境

关于python环境作者在github给了这几个提示:

Python 3
PyOpenGL (http://pyopengl.sourceforge.net/)
----pip install PyOpenGL PyOpenGL_accelerate
Tensorflow (https://www.tensorflow.org/) ( Vesrion : 1.13.1 )
-----pip install tensorflow
MPI4Py (https://mpi4py.readthedocs.io/en/stable/install.html)
-----pip install mpi4py

看下项目的requirements.txt,包含了这几个包:

numpy>=1.15.2
PyOpenGL== 3.1.0
tensorflow==1.13.1
mpi4py>=3.0.0

所以直接安装。在conda中执行(确保科学上网vpn已经关闭,才能使用pip安装)

conda activate DeepMimic
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

事实证明,选对python环境,安装包一帆风顺!!
在这里插入图片描述
在这里插入图片描述

注意:pip安装的pyopengl默认是32位的。电脑需要64位的。这个只能手动安装。

输入这个,查看pip支持的whl版本[9]

pip debug --verbose

在这里插入图片描述
接下来去下载PyOpenGL3.1.0和PyOpenGL-accelerate3.1.0的whl文件。

PyOpenGL下载网址(这个网站简直是whl大全)

这个网站有cp36-cp36m-win_amd64后缀的最早版本是这两个:PyOpenGL_accelerate-3.1.5-cp36-cp36m-win_amd64.whlPyOpenGL-3.1.5-cp36-cp36m-win_amd64.whl

所以安装它们。
在这里插入图片描述

将两个whl放在3rdparty新建的PyOpenGL3.1.0文件夹下。
在这里插入图片描述

卸载掉之前安装的32位的[10]

pip uninstall pyopengl

在这里插入图片描述
之前的就没有了
在这里插入图片描述
cd到 PyOpenGL3.1.0 文件夹,手动安装这两个文件:

cd D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\PyOpenGL3.1.0
pip install PyOpenGL_accelerate-3.1.5-cp36-cp36m-win_amd64.whl
pip install PyOpenGL-3.1.5-cp36-cp36m-win_amd64.whl

在这里插入图片描述
在这里插入图片描述

至此,DeepMimic所有依赖环境已经配置完毕。

10.DeepMimic链接第三方库

双击打开DeepMimic.sln(根据右上角提示,需要安装Python开发包以获取完整的开发体验,点击安装即可)
在这里插入图片描述
安装完python扩展后,点击创建虚拟环境。
在这里插入图片描述
点击现有环境,选择DeepMimic环境py的解释器,也就是刚才配置的Anaconda环境。点击添加。
在这里插入图片描述

双击打开DeepMimicCore/DeepMimicCore.sln

重定向,点击确定(未弹出重定向可右键解决方法-重定向项目)
在这里插入图片描述
配置管理器,设置为Release_Swig x64
在这里插入图片描述

右键点开解决方案-DeepMimicCore属性页-配置属性-C/C+±常规-附加包含目录(注意配置要与配置管理器对应同为Release_Swig x64):
在这里插入图片描述

指定以下目录:

Bullet源目录
Eigen include目录
python include目录

本机的这三个目录分别为:

D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\bullet3CMake-2.88\src
D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\eigen-3.3.7\eigen-3.3.7\install\include\eigen3
D:\SOFEWARE_ANZHUANG\Anaconda\setup\envs\DeepMimic\include

此外,我还加了freeglut和glew的头文件目录:

D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\freeglut-3.0.0\freeglut-3.0.0\include
D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\glew-2.1.0-win32\glew-2.1.0\include

将以上五个目录添加到附加包含目录中:

在这里插入图片描述

点击确定即可。

继续更改DeepMimicCore属性页-链接器-常规-附加库目录(注意配置要与配置管理器对应同为Release_Swig x64):
指定Bullet[11],python,glew,freeglut库目录:

本机目录如下(都是编译完成的Realease x64版本):

D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\bullet3CMake-2.88\build\lib\Release
D:\SOFEWARE_ANZHUANG\Anaconda\setup\envs\DeepMimic\libs
D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\glew-2.1.0-win32\glew-2.1.0\lib\Release\x64
D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\freeglut-3.0.0\freeglut-3.0.0\build\lib\Release

在这里插入图片描述

继续更改DeepMimicCore属性页-链接器-输入-附加依赖项(注意配置要与配置管理器对应同为Release_Swig x64):
添加以下静态库[11],并附加freeglut_static.lib,freeglut.lib。
在这里插入图片描述

继续更改DeepMimicCore属性-配置属性-C/C+±预处理器-预处理器定义,将“_USE_MATH_DEFINES”添加进去[11](注意配置要与配置管理器对应同为Release_Swig x64):

在这里插入图片描述

最后点击应用-确定完成配置
在这里插入图片描述
修改DeepMimicCore.cpp,注释掉122行[13]glutPostRedisplay()
在这里插入图片描述

右键解决方案-重新生成解决方案:
在这里插入图片描述
生成成功!!!

编译通过会生成 D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\DeepMimicCore\x64\Release_Swig\_DeepMimicCore.pydD:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\DeepMimicCore\x64\Release_Swig\_DeepMimicCore.py

ctrl+F5运行DeepMimicCore项目,显示如下(会报错,但是不用管):
在这里插入图片描述

在这里插入图片描述

最后,将D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\freeglut-3.0.0\freeglut-3.0.0\build\bin\Releasefreeglut.dllD:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\3rdparty\glew-2.1.0-win32\glew-2.1.0\bin\Release\x64glew32.dll都放到D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic\DeepMimicCore。也就是_DeepMimicCore.pyd的同级目录下。这是为了让 _DeepMimicCore.pyd 文件正常运行[14][15]

如何使用

接下来就是python的操作了。

演示

激活conda环境

conda activate DeepMimic
D:
cd D:\Wlm_Project\MotionSimulated\1.DeepMimic_SIGGRAPH2018\DeepMimic

演示1

python DeepMimic.py --arg_file args/run_humanoid3d_spinkick_args.txt

在这里插入图片描述

演示2

python DeepMimic.py --arg_file args/play_motion_humanoid3d_args.txt

在这里插入图片描述

演示3

python DeepMimic.py --arg_file args/run_dog3d_pace_args.txt

在这里插入图片描述

训练

python mpi_run.py --arg_file args/train_humanoid3d_spinkick_args.txt --num_workers 16

在这里插入图片描述

python mpi_run.py --arg_file args/train_amp_target_humanoid3d_locomotion_args.txt --num_workers 16

在这里插入图片描述

评估

python DeepMimic.py --arg_file args/run_amp_target_humanoid3d_locomotion_args.txt

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

配置环境过程中遇到的问题解决链接

1.WindowsCMake下载与使用
2.TensorFlow的历史版本与对应Python版本
3.bullet安装之——windows下的安装与VS开发
4.Eigen3编译教程
5.参考:20220707另加freeglut
6.3.2安装GLEW
7.Win10下安装swig
8.Win10下Microsoft MPI(MSMPI)的下载安装
9.Windows_ 64位下正确安装Python-pyOpenGL
10.filename.whl is not a supported wheel on this platform
11.win10下DeepMimic学习之DeepMimicCore编译
12.Windows下的DeepMimic配置
13.DeepMimic出现Function <glutPostRedisplay> called without first calling ‘glutInit‘
14.Can’t execute the _DeepMimicCore.pyd
15.Freeglut init failed in python #21

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值