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.

The camera position is the relative position to the link.

The camera direction and position can be set. In the sample below, camera direction is set to 45 degrees downward.

The camera aspect ration and fov can be set as well.

If these parameters are not set the default values are used.

ParametersValues
position"0 0 0"
direction"0 0 1"
link"(Root link name)"
aspectRatio"1.5"
fov"45" (degree)

If some cameras are set to one agent, IDs 1,2,3 ... are assigned.

起動

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

$ 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