Up:Tutorial?     Previous:エージェント間のメッセージのやりとり?     Next:サービスプロバイダの使用方法


Control method for vision sensor

※This tutorial is compatible with v2.1.0 or later. I will explain how to use the vision sensor.

Environment scanning by vision sensor

I will introduce the sample file for scanning the environment using the vision sensor.

Creation of the controller

$ cd ~/MyWorld
$ emacs WatchController.cpp

WatchController.cpp

This sample is used to rotate the body with an angle which is received as message. I will define the angle in z-axis direction, the angle that can be specified is between -180° and 180°.

Compiling

I will compile the cpp file

$ ./sigmake.sh  WatchController.cpp

XML file for living room

I will create a new world file.

$ emacs WatchWorld.xml

WatchWorld.xml

This is a world file of living room with humanoid robot (Robot-nii.xml), it includes also television and armchair.

In this world file the camera is attached to the robot's head. The direction and the position of the camera set as follows:

You can attach the camera to a specific part of the robot by using link parameter. In this sample, "HEAD_LINK" is used. You can find all parts name of the humanoid robot in this page Joint定義一覧?. If you attach the camera to the entity that doesn't have part or joint, the link cannot be used.

カメラの位置はlinkを設定した場合はlinkの位置からの相対位置となります。

direction, position でカメラの方向ベクトル、位置を設定します。このサンプルではまっすぐ前を向いた方向から、下方向45°に目線があるということになります。

同様にaspectRatio, fov でカメラのアスペクト比、視野角(y方向)なども設定できます。

これらのパラメータを設定しなかった場合はデフォルト値が設定されます。

パラメータ名デフォルト値
position"0 0 0"
direction"0 0 1"
link"(Root link name)"
aspectRatio"1.5"
fov"45" (degree)

1エージェントに複数個のカメラを設置する場合は以下のようにidを1,2,3と順番につけていきます。

起動

それでは起動してみましょう。

$ sigserver.sh -w ./WatchWorld.xml

SIGViewerでサーバに接続して、シミュレーションを開始します。リビングルームに立っているヒューマノイドロボット型のエージェントが見えると思います。

watch_1.PNG

次に、ヒューマノイドロボットをクリックすると、左上の小さい画面にロボットの目線から見た映像が表示されます。

watch_2.PNG

さらにその枠の右上にあるボタンを押すとロボットから見た映像がメイン画面に切り替わります。

watch_3.PNG

元に戻したい場合はもう一度左上のサブウィンドウの右上にあるボタンを押します。

カメラの位置や視線方向を確認したい場合はビューワーの右下のトレイにあるEntityDataをクリックし、エンティティをクリックします。

Watch_7.PNG

カメラの位置とカメラの視線方向がオレンジ色で示されています。

次に右下のトレイにある"Message"ボタンをクリックして、ヒューマノイド型ロボットのエージェントに回転する角度を指定して、メッセージを送信します。例えば90を送信します。

watch_4.PNG

するとロボットが90°回転してロボットの視線からはオレンジやペンギンのおもちゃが見えているのがわかります。

watch_5.PNG

Old Version


Up:Tutorial?     Previous:エージェント間のメッセージのやりとり?     Next:サービスプロバイダの使用方法


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