Up:[[Tutorial]]    Previous:[[物体を持つ動作]]     Next: [[ロボット・ダイナミクス(単純モデル)]]  
Up:[[Tutorial]]    Previous:[[Grasping Function]]     Next: [[Wheeled mobile robot]]  

----

#contents

*BVHファイルの読み込み [#x19ad21f]
* Control of humanoid agent by BVH file [#r2c7c34b]

※SIGVerse v2.1.0以降で動作します。
※This tutorial is valid for later than SIGVerse v2.1.0

ここではBVH形式のモーションデータをSIGVerseで読み込むサンプルを紹介します。
**サンプルコードの取得 [#r8a2a8f0]
まずホームディレクトリに移動します。
 
 $ cd ~

こちらからコントローラサンプルを取得します。
** Download sample programs [#k63d8bb9]

#ref(readBVH_2.1.0.tar.gz)

展開します。
 $ tar zxvf readBVH_2.1.0.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

>You can download all sample controllers from [[this page>https://github.com/SIGVerse/samples]]. 

The package includes the following files.

- 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]

 $ make
BVHController.soが作成されたらコンパイルは成功です。

BVHController.so will be output.

***bvhファイルの取得 [#v7e3fd25]
読み込ませたいbvhファイルを取得してカレントディレクトリ(~/readBVH)に置きます。本ページのサンプルでは[[PV STUDIO>http://www.privatestudio.co.jp/down.htm]]から取得したbvhのサンプルデータAction_Kick_bvh.bvhを読み込ませます。
*** Getting bvh file [#ac1a5058]

***世界ファイルの設定 [#w8dc6fa2]
次に読み込ませたいbvhのファイル名を世界ファイルに記述します。
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ファイル名の指定-->
 <!--specification of bvh file-->
        <set-attr-value name="BvhFile" value="./filename.bvh"/>
}}
    ↓

new
#highlight(xml:firstline[19]){{
 <!--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="./BVHController.so"/>
 
 <!--BVHファイル名の指定-->
         <set-attr-value name="BvhFile" value="./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="60.0"/>
        <set-attr-value name="z" value="0.0"/> 
 
  </instanciate>
</world>
}}
**実行 [#l9a95abd]
#gist(sigverse-git/e53ded9d0f882fd716c4);

これで準備は整いました。それでは実行してみましょう。

** Execution [#fcb6abdd]

 $ sigserver.sh -w ./BVHWorld.xml

SIGViewerでサーバに接続するとエージェントが手を広げて立っているのが見えます。
Sendボタンを押してシミュレーションを開始するとbvhファイルの読み込みが開始され、エージェントが動き始めます。
You can see an avator agent is standing with its hands opened.

#ref(BVHファイルの読み込み(v2.0系)/motion_1.PNG,40%)
エージェントがキックします。
**サンプルモデル [#f5ec3378]
bvh読み込みサンプルモデル(bvh_man.x3d)で定義された関節名は以下のようになっています。すべての関節がローカル座標系におけるx,y,z軸を中心に回転するように定義されています。
#ref(BVHファイルの読み込み(v2.0系)/joint_name.jpg)
Push the start button to start the simulation. The bvh file will be read after the simulation start.

**参考ページ [#a4b2f90f]
#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)

** 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: [[ロボット・ダイナミクス(単純モデル)]] 


Front page   New List of pages Search Recent changes   Help   RSS of recent changes