Samples of the dynamics simulations
[
Front page
] [
New
|
List of pages
|
Search
|
Recent changes
|
Help
]
Start:
// The person in charge of this page is Raghav
Up:[[Tutorial]] Next:[[Humanoid agent operations]]
----
#contents
*Creating our first simulation :A falling virtual object ...
In this simulation dynamics is added to a virtual object ...
**Directory Structure [#fea2aba6]
Here we represent the structure of the directories of the...
sigverse-<version>
|
|---bin
|---include
| +----sigverse
+---shared
+----sigverse
+----data
| |----xml
| +----shape
|----etc
|----jar
+----samples
The above directories have important files as core system...
First step is to create a directory that will be your wor...
** Creating your working space [#v539ae53]
A workspace directory will be created by the following co...
$ cd ~/
$ sigcreate.sh MyWorld
Makefile, controller sample file, world file and so on wi...
*** Controller for entity [#k3be7ece]
A controller is one of the main programs which should be ...
This controller determines the behavior of agents, robots...
These 'objects' are called as entities in the SIGVerse.
Let's see the controller sample.
$ cd MyWorld
$ emacs ControllerSample.cpp
ControllerSample.cpp
#gist(t-inamura/0b3381b25934acc18776);
The agent controller creates a class named "MyController"...
In this case, onAction function is called every 1.0 secon...
But, as you can see, this controller does nothing.
** Compiling the controller [#q60191ea]
A shell script for the compilation has been automatically...
$ ./sigmake.sh ControllerSample.cpp
If the compilation succeeded, you can see ControllerSampl...
** World file [#x8e5ecc7]
World file describes the configuration of the virtual wor...
The following world file is already prepared in your work...
$ emacs WorldSample.xml
WorldSample.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld1">
<!--Set Gravity-->
<gravity x="0.0" y="-9.8" z="0.0"/>
<!--Create an instance of the agent seToy_D -->
<instanciate class="seToy_D.xml">
<!--Naming the agent as Toy_D -->
<set-attr-value name="name" value="Toy_D"/>
<!--Specifying the language of agent controller as C++-->
<set-attr-value name="language" value="c++"/>
<!--Specify the created Agent Controller and its locatio...
<set-attr-value name="implementation" value="./C...
<!--Set the flag for Dynamics calculation as True-->
<set-attr-value name="dynamics" value="true"/>
<!--Set the initial position of the agent (x,y,z)-->
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="18.0"/>
<set-attr-value name="z" value="5.0"/>
<!--specify the mass of the agent-->
<set-attr-value name="mass" value="1.0"/>
</instanciate>
</world>
}}
(The actual world file doesn't have the above comments.)
The world file reads thefile seToy_D.xml as an agent. Sha...
Specifying the controller and its location within workspa...
#highlight(xml:firstline[17]){{
<set-attr-value name="implementation" value="./Co...
}}
Since your workspace directory is "MyWorld", the relative...
You may need to write the full path depending on the rela...
** Starting the simulation [#zafcd00a]
The script sigserver.sh is used to run the simulation and...
Type the following command in your working directory.
$ sigserver.sh -w ./WorldSample.xml
:
:
[SYS] waiting for connection...
[SYS] Controller attached to "Toy_D"
[SYS] 127.0.0.1 connected
[SYS] Toy_D : dataport
[SYS] 127.0.0.1 connected
Please specify a world file with -w option. If you don't ...
Since the agent controller is specified in the xml file y...
Start the SIGViewer and enter the host name and port numb...
#ref(toy_1.jpg)
World position for the agent Toy_D is described in the fi...
Start the simulation by using the framework of SIM_CTRL_C...
#ref(toy_2.jpg)
The simulation starts, you can confirm that the agent (to...
*Move agents[#z54adf9a]
We make some changes in the agent controller ControllerSa...
$ cd ~/MyWorld
$ emacs ControllerSample.cpp
Add the following code in agent controller.
ControllerSample.cpp
#highlight(cpp:firstline[13]){{
double MyController::onAction(ActionEvent &evt) {
return 1.0; //returns the time period for next ca...
}
}}
↓
#highlight(cpp:firstline[13]){{
double MyController::onAction(ActionEvent &evt) {
SimObj *obj = getObj(myname()); //obtaining handle to...
obj->addForce(0,0,500); //apply the force 500...
return 1.0; //returns the time period for next ca...
}
}}
*** Compile and Run [#m0f672b0]
$ ./sigmake.sh ControllerSample.cpp
$ sigserver.sh -w ./WorldSample.xml
If you check SIGViewer, you can see agent moving in the z...
#ref(toy_3.jpg)
It would be a fun exercise to use other functions such as...
* Physics for form, size and position settings [#n6779cdb]
We have several visual forms representing shapes of objec...
** Modification of object shape file [#ef9fabb8]
First, copy the original object shape file to your workin...
$ cp ~/sigverse-<version>/share/sigverse/data/xml/seToy_D...
Then, edit the configuration file of the object to observ...
$ emacs seToy_D.xml
in seToy_D.xml
<body filename="dummy-body.xml"/>
please add under the following keywords
***box [#b90fa015]
#highlight(xml:nogutter){{
<!--set the Box Shape。-->
<simpleShape type="box">
<!--The position of the box shape is set。-->
<position x="0" y="0" z="0"/>
<!--The size of the box shape is set-->
<size sx="10" sy="10" sz="10"/>
</simpleShape>
}}
***sphere [#f0404294]
setting the sphere shape below
#highlight(xml:nogutter){{
<simpleShape type="sphere">
<position x="0" y="0" z="0"/>
<size r="10"/>
</simpleShape>
}}
***cylinder [#z94a7687]
#highlight(xml:nogutter){{
<simpleShape type="cylinder">
<position x="0" y="0" z="0"/>
<size r="3" h="10"/>
</simpleShape>
}}
Radius of the bottom is 3 and height of the cylinder is 10.
**On run[#r537a2f8]
When you run the agent controllers ( first that makes age...
*Units [#c72a1e70]
The units in SIGVerse: angle (in radians . For all the qu...
|Amount |Name |Sign|
|Length |centimeter |cm|
|Weight |kilogram |kg|
|Time |seconds |s|
|Angle |radians |rad|
|Velocity |centimeters per second|cm/s|
|Acceleration|centimeters per second per second|cm/s^2|
|Force |kilogram centimeters per second per second|...
|Torque |kilogram centimeters square per second per ...
Up:[[Tutorial]] Next:[[Humanoid agent operations]]
#highlight(end)
#counter
End:
// The person in charge of this page is Raghav
Up:[[Tutorial]] Next:[[Humanoid agent operations]]
----
#contents
*Creating our first simulation :A falling virtual object ...
In this simulation dynamics is added to a virtual object ...
**Directory Structure [#fea2aba6]
Here we represent the structure of the directories of the...
sigverse-<version>
|
|---bin
|---include
| +----sigverse
+---shared
+----sigverse
+----data
| |----xml
| +----shape
|----etc
|----jar
+----samples
The above directories have important files as core system...
First step is to create a directory that will be your wor...
** Creating your working space [#v539ae53]
A workspace directory will be created by the following co...
$ cd ~/
$ sigcreate.sh MyWorld
Makefile, controller sample file, world file and so on wi...
*** Controller for entity [#k3be7ece]
A controller is one of the main programs which should be ...
This controller determines the behavior of agents, robots...
These 'objects' are called as entities in the SIGVerse.
Let's see the controller sample.
$ cd MyWorld
$ emacs ControllerSample.cpp
ControllerSample.cpp
#gist(t-inamura/0b3381b25934acc18776);
The agent controller creates a class named "MyController"...
In this case, onAction function is called every 1.0 secon...
But, as you can see, this controller does nothing.
** Compiling the controller [#q60191ea]
A shell script for the compilation has been automatically...
$ ./sigmake.sh ControllerSample.cpp
If the compilation succeeded, you can see ControllerSampl...
** World file [#x8e5ecc7]
World file describes the configuration of the virtual wor...
The following world file is already prepared in your work...
$ emacs WorldSample.xml
WorldSample.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld1">
<!--Set Gravity-->
<gravity x="0.0" y="-9.8" z="0.0"/>
<!--Create an instance of the agent seToy_D -->
<instanciate class="seToy_D.xml">
<!--Naming the agent as Toy_D -->
<set-attr-value name="name" value="Toy_D"/>
<!--Specifying the language of agent controller as C++-->
<set-attr-value name="language" value="c++"/>
<!--Specify the created Agent Controller and its locatio...
<set-attr-value name="implementation" value="./C...
<!--Set the flag for Dynamics calculation as True-->
<set-attr-value name="dynamics" value="true"/>
<!--Set the initial position of the agent (x,y,z)-->
<set-attr-value name="x" value="0.0"/>
<set-attr-value name="y" value="18.0"/>
<set-attr-value name="z" value="5.0"/>
<!--specify the mass of the agent-->
<set-attr-value name="mass" value="1.0"/>
</instanciate>
</world>
}}
(The actual world file doesn't have the above comments.)
The world file reads thefile seToy_D.xml as an agent. Sha...
Specifying the controller and its location within workspa...
#highlight(xml:firstline[17]){{
<set-attr-value name="implementation" value="./Co...
}}
Since your workspace directory is "MyWorld", the relative...
You may need to write the full path depending on the rela...
** Starting the simulation [#zafcd00a]
The script sigserver.sh is used to run the simulation and...
Type the following command in your working directory.
$ sigserver.sh -w ./WorldSample.xml
:
:
[SYS] waiting for connection...
[SYS] Controller attached to "Toy_D"
[SYS] 127.0.0.1 connected
[SYS] Toy_D : dataport
[SYS] 127.0.0.1 connected
Please specify a world file with -w option. If you don't ...
Since the agent controller is specified in the xml file y...
Start the SIGViewer and enter the host name and port numb...
#ref(toy_1.jpg)
World position for the agent Toy_D is described in the fi...
Start the simulation by using the framework of SIM_CTRL_C...
#ref(toy_2.jpg)
The simulation starts, you can confirm that the agent (to...
*Move agents[#z54adf9a]
We make some changes in the agent controller ControllerSa...
$ cd ~/MyWorld
$ emacs ControllerSample.cpp
Add the following code in agent controller.
ControllerSample.cpp
#highlight(cpp:firstline[13]){{
double MyController::onAction(ActionEvent &evt) {
return 1.0; //returns the time period for next ca...
}
}}
↓
#highlight(cpp:firstline[13]){{
double MyController::onAction(ActionEvent &evt) {
SimObj *obj = getObj(myname()); //obtaining handle to...
obj->addForce(0,0,500); //apply the force 500...
return 1.0; //returns the time period for next ca...
}
}}
*** Compile and Run [#m0f672b0]
$ ./sigmake.sh ControllerSample.cpp
$ sigserver.sh -w ./WorldSample.xml
If you check SIGViewer, you can see agent moving in the z...
#ref(toy_3.jpg)
It would be a fun exercise to use other functions such as...
* Physics for form, size and position settings [#n6779cdb]
We have several visual forms representing shapes of objec...
** Modification of object shape file [#ef9fabb8]
First, copy the original object shape file to your workin...
$ cp ~/sigverse-<version>/share/sigverse/data/xml/seToy_D...
Then, edit the configuration file of the object to observ...
$ emacs seToy_D.xml
in seToy_D.xml
<body filename="dummy-body.xml"/>
please add under the following keywords
***box [#b90fa015]
#highlight(xml:nogutter){{
<!--set the Box Shape。-->
<simpleShape type="box">
<!--The position of the box shape is set。-->
<position x="0" y="0" z="0"/>
<!--The size of the box shape is set-->
<size sx="10" sy="10" sz="10"/>
</simpleShape>
}}
***sphere [#f0404294]
setting the sphere shape below
#highlight(xml:nogutter){{
<simpleShape type="sphere">
<position x="0" y="0" z="0"/>
<size r="10"/>
</simpleShape>
}}
***cylinder [#z94a7687]
#highlight(xml:nogutter){{
<simpleShape type="cylinder">
<position x="0" y="0" z="0"/>
<size r="3" h="10"/>
</simpleShape>
}}
Radius of the bottom is 3 and height of the cylinder is 10.
**On run[#r537a2f8]
When you run the agent controllers ( first that makes age...
*Units [#c72a1e70]
The units in SIGVerse: angle (in radians . For all the qu...
|Amount |Name |Sign|
|Length |centimeter |cm|
|Weight |kilogram |kg|
|Time |seconds |s|
|Angle |radians |rad|
|Velocity |centimeters per second|cm/s|
|Acceleration|centimeters per second per second|cm/s^2|
|Force |kilogram centimeters per second per second|...
|Torque |kilogram centimeters square per second per ...
Up:[[Tutorial]] Next:[[Humanoid agent operations]]
#highlight(end)
#counter
Page: