OpenSim教程五——源码安装OpenSim

OpenSim是开源的生物力学仿真系统,官方提供的GUI软件可以满足一般的模型编辑、运动学数据导入、动力学仿真查看等任务。但如果用户想根据自己需要扩展一些功能(如编写插件、自定义驱动方法、在其他软件中调用OpenSim接口等),就需要源码安装OpenSim了。

跟所有开源C++项目一样,OpenSim的源码安装需要用到git,CMake、MSVC等工具,对于新手来说具有一定难度。我也是根据Github上Readme的指引倒腾了很久才安装成功。先说一下几个需要注意的问题:1、安装的工具要具有相同的位数(32位或64位);2、要把电脑系统语言设置为英文;3、编译安装需要长时间等待。

下面是我根据官方指引在windows 10下源码安装OpenSim 4.0的步骤:
1、下载安装Visual Studio、git、CMake、Chocolatey等工具;
2、以管理员身份打开PowerShell,运行指令

choco install python2 jdk8 swig

3、通过git下载OpenSim源代码

git clone https://github.com/opensim-org/opensim-core.git

4、编译、安装依赖库BTK、docopt和simbody

mkdir opensim_dependencies_build
cd .\opensim_dependencies_build
cmake ..\opensim-core\dependencies                             `
      -G"Visual Studio 15 2017 Win64"                          `
      -DCMAKE_INSTALL_PREFIX="..\opensim_dependencies_install"
cmake --build . --config RelWithDebInfo -- /maxcpucount:8

结束后会在C:\opensim_dependencies_install文件夹中出现三个包含对应内容的子文件夹。

5、生成OpenSim解决方案并编译

cd ..
mkdir opensim_build
cd .\opensim_build
cmake ..\opensim-core                                              `
      -G"Visual Studio 15 2017 Win64"                              `
      -DCMAKE_INSTALL_PREFIX="..\opensim_install"                  `
      -DOPENSIM_DEPENDENCIES_DIR="..\opensim_dependencies_install" `
      -DBUILD_JAVA_WRAPPING=ON                                     `
      -DBUILD_PYTHON_WRAPPING=ON                                   `
      -DWITH_BTK=ON                                  
cmake --build . --config RelWithDebInfo -- /maxcpucount:8

这里的JAVA_WRAPPING设为on是为了在matlab中顺利调用OpenSim画图接口,编译过程中会闪过设置matlab的窗口;PYTHON_WRAPPING设为on是为了用python调用OpenSim接口。

6、单元测试

ctest --build-config RelWithDebInfo --parallel 8

测试主要函数是否能正确使用
test

7、安装到指定文件夹

cmake --build . --config RelWithDebInfo --target install -- /maxcpucount:8

结束后在C:\opensim_install文件夹会包含OpenSim的所有内容
在这里插入图片描述
然后将C:\opensim_install\bin添加到电脑的环境变量PATH中,并将其置顶。
env

至此,OpenSim的安装就结束了。大家可以根据自己的软件版本和安装目录自行修改上面指令,祝顺利!

  • 9
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
以下是基于Windows系统的OpenSim安装教程: 1. 下载OpenSimulator二进制文件 在OpenSimulator的官网(https://opensimulator.org/)上下载最新的Windows二进制文件。选择“Download”页面上的“Windows Binaries”链接,然后选择你需要的版本进行下载。 2. 解压缩OpenSimulator文件 将OpenSimulator文件解压缩到你想要存放它的文件夹中。你可以选择将其解压缩到C:\Program Files\OpenSimulator目录下,但这需要管理员权限。 3. 配置OpenSimulator文件 进入解压缩后的OpenSimulator文件夹,找到“bin”目录下的“OpenSim.ini.example”文件,并将其重命名为“OpenSim.ini”。 4. 配置OpenSimulator数据库 如果你想要使用MySQL数据库,请确保已经安装了MySQL服务器,并设置了正确的用户名和密码。在“OpenSim.ini”文件中,找到以下内容: ```[Startup] ; default is to use BasicData.ini as the data source, but you can choose ; to use a different one here. ; DataSource = "BasicData.ini" DataSource = "MySQL" ``` 将“DataSource”设为“MySQL”,并在下面添加以下内容: ```[DatabaseService] ; Connect string for the MySQL database server. ; This assumes you have a database called "opensim" which ; you have granted rights to the user specified below. ConnectionString = "Database=mysql;Server=localhost;Port=3306;Uid=root;Pwd=mypassword;Database=opensim;" ``` 将“Uid”和“Pwd”修改为你的MySQL用户名和密码,将“Database”修改为你想要使用的数据库名称。 5. 启动OpenSimulator 双击“bin”目录下的“OpenSim.exe”文件,OpenSimulator将会启动。如果出现错误,请检查“OpenSim.ini”文件中的配置是否正确。 6. 连接到OpenSimulator 用一个Second Life兼容的客户端(比如Firestorm、Singularity等),连接到OpenSimulator。在登录界面中,输入你的用户名和密码,以及OpenSimulator的IP地址和端口号(默认为“localhost:9000”),然后点击“连接”按钮。 7. 开始使用OpenSimulator 现在你可以在OpenSimulator中创建一个虚拟世界,并开始构建你的虚拟环境了!
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值