Vision sensor
[
Front page
] [
New
|
List of pages
|
Search
|
Recent changes
|
Help
]
Start:
Up:[[Tutorial]] Previous:[[Exchange of messages ...
#contents
*Control method for vision sensor [#q54c34b0]
※This tutorial is compatible with v2.1.0 or later.
I will explain how to use the vision sensor.
//I will explain some functions after. It is not supporte...
**Environment scanning by vision sensor [#ee622eab]
I will introduce the sample file for the environment scan...
***Creation of the controller [#d49f13ea]
$ cd ~/MyWorld
$ emacs WatchController.cpp
WatchController.cpp
#highlight(cpp){{
#include "Controller.h"
#include "Logger.h"
#include "ControllerEvent.h"
#define PI 3.141592
#define DEG2RAD(DEG) ( (PI) * (DEG) / 180.0 )
class WatchController : public Controller
{
public:
void onRecvMsg(RecvMsgEvent &evt);
};
void WatchController::onRecvMsg(RecvMsgEvent &evt)
{
SimObj *my = getObj(myname());
// Convert the received message into integer type
const char *value = evt.getMsg();
int angle = atoi(value);
if (angle <= 180 && angle >=-180){
// Rorate the body around z-axis with angle[deg]
my->setAxisAndAngle(0, 1.0, 0, DEG2RAD(angle));
}
}
extern "C" Controller * createController ()
{
return new WatchController;
}
}}
This sample is used to rotate the body with an angle whic...
I will define the angle in z-axis direction, this angle m...
*** Compiling [#o5d13342]
$ ./sigmake.sh WatchController.cpp
*** A world file of a living room [#r7ff3041]
$ emacs WatchWorld.xml
WatchWorld.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld5">
<gravity x="0.0" y="-980.7" z="0.0"/>
<!-- Configuration of the agent Robot-nii -->
<instanciate class="Robot-nii.xml">
<!-- Name of the avatar agent -->
<set-attr-value name="name" value="robot_000"/>
<!-- Specify the C++ language for controller -->
<set-attr-value name="language" value="c++"/>
<!-- Controller file -->
<set-attr-value name="implementation" value="./WatchC...
<!-- Set dynamics mode Off -->
<set-attr-value name="dynamics" value="false"/>
<!-- Set the initial position of the agent(x,y,z)-->
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="54.0"/>
<set-attr-value name="z" value="-40.0"/>
<!-- Set ID, link name, direction, position of the ca...
<camera id="1"
link="HEAD_LINK"
direction="0 -1 1"
aspectRatio="1.5"
fov="45"
position="0.0 0.0 5.0"/>
</instanciate>
<!-- Environment of a living room -->
<instanciate class="seTV.xml">
<set-attr-value name="name" value="TV_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-20.0"/>
<set-attr-value name="y" value="87.5"/>
<set-attr-value name="z" value="-250.0"/>
<set-attr-value name="visStateAttrName" value="switch...
<set-attr-value name="switch" value="on"/>
</instanciate>
<instanciate class="seDoll_Bear.xml">
<set-attr-value name="name" value="kuma_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="9.9"/>
<set-attr-value name="z" value="0.0"/>
</instanciate>
<instanciate class="seToy_D.xml">
<set-attr-value name="name" value="penguin_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="50.0"/>
<set-attr-value name="y" value="6.15"/>
<set-attr-value name="z" value="-40.0"/>
</instanciate>
<instanciate class="seSofa_2seater.xml">
<set-attr-value name="name" value="sofa_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-200.0"/>
<set-attr-value name="y" value="31.85"/>
<set-attr-value name="z" value="-100.0"/>
<set-attr-value name="qw" value="0.707"/>
<set-attr-value name="qx" value="0.0"/>
<set-attr-value name="qy" value="0.707"/>
<set-attr-value name="qz" value="0.0"/>
</instanciate>
<instanciate class="seTVbass_B.xml">
<set-attr-value name="name" value="TVdai_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-20.0"/>
<set-attr-value name="y" value="25.1"/>
<set-attr-value name="z" value="-250.0"/>
</instanciate>
<instanciate class="sePlant_B.xml">
<set-attr-value name="name" value="ki_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="100.0"/>
<set-attr-value name="y" value="56.5"/>
<set-attr-value name="z" value="-250.0"/>
</instanciate>
<instanciate class="seSidetable_B.xml">
<set-attr-value name="name" value="sidetable_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-100.0"/>
<set-attr-value name="y" value="16.0"/>
<set-attr-value name="z" value="-100.0"/>
<set-attr-value name="qw" value="0.707"/>
<set-attr-value name="qx" value="0.0"/>
<set-attr-value name="qy" value="0.707"/>
<set-attr-value name="qz" value="0.0"/>
</instanciate>
<instanciate class="seApple.xml">
<set-attr-value name="name" value="apple_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-50.0"/>
<set-attr-value name="y" value="3.875"/>
<set-attr-value name="z" value="30.0"/>
</instanciate>
<instanciate class="seOrange.xml">
<set-attr-value name="name" value="orange_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="70.0"/>
<set-attr-value name="y" value="2.215"/>
<set-attr-value name="z" value="-30.0"/>
</instanciate>
</world>
}}
This is a world file of living room with humanoid robot (...
In this world file the camera is attached to the robot's ...
#highlight(xml:firstline[28]){{
<camera id="1"
link="HEAD_LINK"
direction="0 -1 1"
aspectRatio="1.5"
fov="45"
position="0.0 0.0 5.0"/>
}}
You can attach the camera to a specific part of the robot...
The camera position is the relative position to the link.
The camera direction and position can be set. In the samp...
The camera aspect ration and fov can be set as well.
If these parameters are not set the default values are us...
|Parameters|Values|
|position| "0 0 0"|
|direction| "0 0 1" |
|link | "(Root link name)" |
|aspectRatio | "1.5" |
|fov | "45" (degree)|
If several cameras are set to one agent, IDs 1,2,3 ... ar...
#highlight(xml:firstline[28]){{
<camera id="1"
:
<camera id="2"
:
}}
***Start [#ne91c343]
Let's start SIGVServer.
$ sigserver.sh -w ./WatchWorld.xml
The SIGViewer connects to the server and the simulation w...
#ref(視覚に関する操作(v2.0系)/watch_1.PNG,40%)
If you click on the robot, you will see the view of the v...
#ref(視覚に関する操作(v2.0系)/watch_2.PNG)
If you click on the top right button in the sub-window, m...
#ref(視覚に関する操作(v2.0系)/watch_3.PNG,40%)
If you want to replace the sub-window, you have to click ...
If you want to check the camera's position and rotation, ...
#ref(./Watch_7.PNG,40%)
Camera's position and direction are shown as orange vector.
Next, you have to click on the message button on the righ...
#ref(視覚に関する操作(v2.0系)/watch_4.PNG,80%)
Then, the agent rotates with 90 degrees and you can see t...
#ref(視覚に関する操作(v2.0系)/watch_5.PNG,40%)
#highlight(end)
Up:[[Tutorial]] Previous:[[Exchange of messages ...
#counter
End:
Up:[[Tutorial]] Previous:[[Exchange of messages ...
#contents
*Control method for vision sensor [#q54c34b0]
※This tutorial is compatible with v2.1.0 or later.
I will explain how to use the vision sensor.
//I will explain some functions after. It is not supporte...
**Environment scanning by vision sensor [#ee622eab]
I will introduce the sample file for the environment scan...
***Creation of the controller [#d49f13ea]
$ cd ~/MyWorld
$ emacs WatchController.cpp
WatchController.cpp
#highlight(cpp){{
#include "Controller.h"
#include "Logger.h"
#include "ControllerEvent.h"
#define PI 3.141592
#define DEG2RAD(DEG) ( (PI) * (DEG) / 180.0 )
class WatchController : public Controller
{
public:
void onRecvMsg(RecvMsgEvent &evt);
};
void WatchController::onRecvMsg(RecvMsgEvent &evt)
{
SimObj *my = getObj(myname());
// Convert the received message into integer type
const char *value = evt.getMsg();
int angle = atoi(value);
if (angle <= 180 && angle >=-180){
// Rorate the body around z-axis with angle[deg]
my->setAxisAndAngle(0, 1.0, 0, DEG2RAD(angle));
}
}
extern "C" Controller * createController ()
{
return new WatchController;
}
}}
This sample is used to rotate the body with an angle whic...
I will define the angle in z-axis direction, this angle m...
*** Compiling [#o5d13342]
$ ./sigmake.sh WatchController.cpp
*** A world file of a living room [#r7ff3041]
$ emacs WatchWorld.xml
WatchWorld.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld5">
<gravity x="0.0" y="-980.7" z="0.0"/>
<!-- Configuration of the agent Robot-nii -->
<instanciate class="Robot-nii.xml">
<!-- Name of the avatar agent -->
<set-attr-value name="name" value="robot_000"/>
<!-- Specify the C++ language for controller -->
<set-attr-value name="language" value="c++"/>
<!-- Controller file -->
<set-attr-value name="implementation" value="./WatchC...
<!-- Set dynamics mode Off -->
<set-attr-value name="dynamics" value="false"/>
<!-- Set the initial position of the agent(x,y,z)-->
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="54.0"/>
<set-attr-value name="z" value="-40.0"/>
<!-- Set ID, link name, direction, position of the ca...
<camera id="1"
link="HEAD_LINK"
direction="0 -1 1"
aspectRatio="1.5"
fov="45"
position="0.0 0.0 5.0"/>
</instanciate>
<!-- Environment of a living room -->
<instanciate class="seTV.xml">
<set-attr-value name="name" value="TV_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-20.0"/>
<set-attr-value name="y" value="87.5"/>
<set-attr-value name="z" value="-250.0"/>
<set-attr-value name="visStateAttrName" value="switch...
<set-attr-value name="switch" value="on"/>
</instanciate>
<instanciate class="seDoll_Bear.xml">
<set-attr-value name="name" value="kuma_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="9.9"/>
<set-attr-value name="z" value="0.0"/>
</instanciate>
<instanciate class="seToy_D.xml">
<set-attr-value name="name" value="penguin_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="50.0"/>
<set-attr-value name="y" value="6.15"/>
<set-attr-value name="z" value="-40.0"/>
</instanciate>
<instanciate class="seSofa_2seater.xml">
<set-attr-value name="name" value="sofa_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-200.0"/>
<set-attr-value name="y" value="31.85"/>
<set-attr-value name="z" value="-100.0"/>
<set-attr-value name="qw" value="0.707"/>
<set-attr-value name="qx" value="0.0"/>
<set-attr-value name="qy" value="0.707"/>
<set-attr-value name="qz" value="0.0"/>
</instanciate>
<instanciate class="seTVbass_B.xml">
<set-attr-value name="name" value="TVdai_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-20.0"/>
<set-attr-value name="y" value="25.1"/>
<set-attr-value name="z" value="-250.0"/>
</instanciate>
<instanciate class="sePlant_B.xml">
<set-attr-value name="name" value="ki_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="100.0"/>
<set-attr-value name="y" value="56.5"/>
<set-attr-value name="z" value="-250.0"/>
</instanciate>
<instanciate class="seSidetable_B.xml">
<set-attr-value name="name" value="sidetable_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-100.0"/>
<set-attr-value name="y" value="16.0"/>
<set-attr-value name="z" value="-100.0"/>
<set-attr-value name="qw" value="0.707"/>
<set-attr-value name="qx" value="0.0"/>
<set-attr-value name="qy" value="0.707"/>
<set-attr-value name="qz" value="0.0"/>
</instanciate>
<instanciate class="seApple.xml">
<set-attr-value name="name" value="apple_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-50.0"/>
<set-attr-value name="y" value="3.875"/>
<set-attr-value name="z" value="30.0"/>
</instanciate>
<instanciate class="seOrange.xml">
<set-attr-value name="name" value="orange_0"/>
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="70.0"/>
<set-attr-value name="y" value="2.215"/>
<set-attr-value name="z" value="-30.0"/>
</instanciate>
</world>
}}
This is a world file of living room with humanoid robot (...
In this world file the camera is attached to the robot's ...
#highlight(xml:firstline[28]){{
<camera id="1"
link="HEAD_LINK"
direction="0 -1 1"
aspectRatio="1.5"
fov="45"
position="0.0 0.0 5.0"/>
}}
You can attach the camera to a specific part of the robot...
The camera position is the relative position to the link.
The camera direction and position can be set. In the samp...
The camera aspect ration and fov can be set as well.
If these parameters are not set the default values are us...
|Parameters|Values|
|position| "0 0 0"|
|direction| "0 0 1" |
|link | "(Root link name)" |
|aspectRatio | "1.5" |
|fov | "45" (degree)|
If several cameras are set to one agent, IDs 1,2,3 ... ar...
#highlight(xml:firstline[28]){{
<camera id="1"
:
<camera id="2"
:
}}
***Start [#ne91c343]
Let's start SIGVServer.
$ sigserver.sh -w ./WatchWorld.xml
The SIGViewer connects to the server and the simulation w...
#ref(視覚に関する操作(v2.0系)/watch_1.PNG,40%)
If you click on the robot, you will see the view of the v...
#ref(視覚に関する操作(v2.0系)/watch_2.PNG)
If you click on the top right button in the sub-window, m...
#ref(視覚に関する操作(v2.0系)/watch_3.PNG,40%)
If you want to replace the sub-window, you have to click ...
If you want to check the camera's position and rotation, ...
#ref(./Watch_7.PNG,40%)
Camera's position and direction are shown as orange vector.
Next, you have to click on the message button on the righ...
#ref(視覚に関する操作(v2.0系)/watch_4.PNG,80%)
Then, the agent rotates with 90 degrees and you can see t...
#ref(視覚に関する操作(v2.0系)/watch_5.PNG,40%)
#highlight(end)
Up:[[Tutorial]] Previous:[[Exchange of messages ...
#counter
Page: