- The added line is THIS COLOR.
- The deleted line is THIS COLOR.
Up:[[Tutorial]] Previous:[[物体を持つ動作]] Next: [[ロボット・ダイナミクス(単純モデル)]]
Up:[[Tutorial]] Previous:[[Grasping Function]] Next: [[Wheeled mobile robot]]
----
#contents
*BVHファイルの読み込み [#x19ad21f]
ここではBVH形式のモーションデータをSIGVerseで読み込むサンプルを紹介します。
**サンプルコードの取得 [#r8a2a8f0]
まずSIGVerseがインストールされたディレクトリに移動します。
$ cd ~/sigverse-<version>/bin
* Control of humanoid agent by BVH file [#r2c7c34b]
次にsoicoまたはsocio2サーバの以下のディレクトリからサンプルコードを取得し、展開します。
※This tutorial is valid for later than SIGVerse v2.1.0
↓こちらからも取得できます。
#ref(readBVH.tar.gz)
** Download sample programs [#k63d8bb9]
$ cp /home/SIGVerse/samples/readBVH.tar.gz .
$ tar zxvf readBVH.tar.gz
Make working directory.
$ cd ~
$ mkdir readBVH
$ cd readBVH
このパッケージの中には以下のファイルが含まれています。
***サンプルコントローラ [#i7f05989]
-BVH.cpp
-BVH.h
-BVHController.cpp
-BVHController.h
***世界ファイル [#p6149a98]
-BVHWorld.xml
***エージェント設定ファイル [#uc5845c1]
-Man-bvh.xml
***bvhファイル読み込み用人間型サンプルモデル [#z8b70ad2]
-bvh_man.x3d
***Makefile [#vbdf38d6]
-Makefile
Please download the programs from below link.
**コンパイル [#dc0eecc8]
それでは早速コンパイルをしてみましょう。
https://github.com/SIGVerse/samples/tree/master/controllers/AgentControllerByBVHfile
$ make
BVHController.soが作成されたらコンパイルは成功です。
>You can download all sample controllers from [[this page>https://github.com/SIGVerse/samples]].
**設定 [#fe62edb4]
***ファイルの移動 [#fb87d967]
次にbvhファイル読み込み用のサンプル形状モデルをパスが通ったshapeディレクトリに置きます。
The package includes the following files.
$ cp bvh_man.x3d ../../share/sigverse/data/shape/
- Controller
-- srcs/BVH.cpp
-- srcs/BVH.h
-- srcs/BVHController.cpp
-- srcs/BVHController.h
- World file
-- BVHWorld.xml
- Agent configuration file
-- Man-bvh.xml
- Shape model for the humanoid agent
-- bvh_man.x3d
- other
-- Makefile
** Compilation [#s8798c81]
次に世界ファイルとエージェント設定ファイルをxmlディレクトリに置きます。
$ make
$ cp BVHWorld.xml ../xml/
$ cp Man-bvh.xml ../xml/
(※コピー先 ../../share/sigverse/data/xml/)
BVHController.so will be output.
***bvhファイルの取得 [#v7e3fd25]
読み込ませたいbvhファイルを取得してカレントディレクトリ(~/sigverse-<version>/bin/readBVH)に置きます。本ページのサンプルでは[[PV STUDIO>http://www.privatestudio.co.jp/down.htm]]から取得したbvhのサンプルデータAction_Kick_bvh.bvhを読み込ませます。
*** Getting bvh file [#ac1a5058]
***世界ファイルの設定 [#w8dc6fa2]
次に読み込ませたいbvhのファイル名を世界ファイルに記述します。
$ cd ..
$ emacs xml/BVHWorld.xml
Put your favority bvh file on the current directory (~/readBVH). This tutorial uses Action_Kick_bvh.bvh provided by [[PV STUDIO>http://www.privatestudio.co.jp/down.htm]]
*** Configuration of world file [#a07173c4]
Specify the target bvh file in the world file
$ emacs BVHWorld.xml
BVHWorld.xml
old
#highlight(xml:firstline[19]){{
<!--BVHファイル名の指定-->
<set-attr-value name="BvhFile" value="./readBVH/filename.bvh"/>
<!--specification of bvh file-->
<set-attr-value name="BvhFile" value="./filename.bvh"/>
}}
↓
new
#highlight(xml:firstline[19]){{
<!--BVHファイル名の指定-->
<set-attr-value name="BvhFile" value="./readBVH/Action_Kick_bvh.bvh"/>
<!--specification of bvh file-->
<set-attr-value name="BvhFile" value="./Action_Kick_bvh.bvh"/>
}}
bvhファイルはSIGVerseを実行するディレクトリからのパスを指定します。
The path for the bvh file should be relative path from the directories to execute.
BVHWorld.xml
#highlight(xml){{
<?xml version="1.0" encoding="UTF-8"?>
<world name="newworld">
<!--重力の設定-->
<gravity x="0.0" y="-9.8" z="0.0"/>
<!--エージェントMan-niiの設定-->
<instanciate class="Man-bvh.xml">
<!--エージェント名-->
<set-attr-value name="name" value="man_000"/>
<!--C++言語の指定-->
<set-attr-value name="language" value="c++"/>
<!--オブジェクトファイルBVHController.soの指定-->
<set-attr-value name="implementation" value="./readBVH/BVHController.so"/>
<!--BVHファイル名の指定-->
<set-attr-value name="BvhFile" value="./readBVH/Action_Kick_bvh.bvh"/>
<!--動力学演算をfalseに設定-->
<set-attr-value name="dynamics" value="false"/>
<!--エージェントの位置(x,y,z)-->
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="50.0"/>
<set-attr-value name="z" value="0.0"/>
</instanciate>
</world>
}}
**実行 [#l9a95abd]
#gist(sigverse-git/e53ded9d0f882fd716c4);
これで準備は整いました。それでは実行してみましょう。
$ ./sigserver.sh -p 9001 -w BVHWorld.xml
** Execution [#fcb6abdd]
SIGViewerでサーバに接続するとエージェントが手を広げて立っているのが見えます。
Sendボタンを押してシミュレーションを開始するとbvhファイルの読み込みが開始され、エージェントが動き始めます。
$ sigserver.sh -w ./BVHWorld.xml
#ref(./motion_1.PNG,40%)
エージェントがキックします。
**サンプルモデル [#f5ec3378]
bvh読み込みサンプルモデル(bvh_man.x3d)で定義された関節名は以下のようになっています。すべての関節がローカル座標系におけるx,y,z軸を中心に回転するように定義されています。
You can see an avator agent is standing with its hands opened.
Push the start button to start the simulation. The bvh file will be read after the simulation start.
#ref(./motion_kick.PNG,40%)
The agent will perform kick motion.
** sample model [#z588d3da]
Joint names used in the sample model (bvh_man.x3d) is as shown in the following picture.
All of the joints is configured to rotate around x,y,z axis of local coordinate.
#ref(./joint_name.jpg)
**参考ページ [#a4b2f90f]
** reference [#p7ab5310]
-[[Real animation software PV STUDIO>http://www.privatestudio.co.jp/down.htm]]
-[[尾下研究室 BVH モーションファイル 読み込み&表示 プログラム>http://www.oshita-lab.org/software/bvh/index-j.html]]
#highlight(end)
Up:[[Tutorial]] Previous:[[Grasping Function]] Next: [[Wheeled mobile robot]]
*Old Version [#la5c5120]
-[[BVHファイルの読み込み(v2.0系)]]
-[[BVHファイルの読み込み(v120330, v1.4.8)]]
#counter
Up:[[Tutorial]] Previous:[[物体を持つ動作]] Next: [[ロボット・ダイナミクス(単純モデル)]]