Up:Tutorial     Next:Humanoid agent operations


Creating our first simulation :A falling virtual object .

In this simulation dynamics is added to a virtual object which causes it to fall down due to gravity . The virtual object used here is the model of penguin.

Directory Structure

Here we represent the structure of the directories of the SIGVerse package that is installed on your system .

sigverse-<version>

      |
      |---bin
      |---include
      |     +----sigverse       
      +---shared 
            +----sigverse
                    +----data
                    |     |----xml
                    |     +----shape
                    |----etc
                    |----jar
                    +----samples  

The above directories have important files as core system. Please do not edit the files on the above tree structure.

First step is to create a directory that will be your working space.

Creating your working space

A workspace directory will be created by the following command named sigcreate.sh

$ cd ~/ 
$ sigcreate.sh MyWorld

Makefile, controller sample file, world file and so on will be created in this working directory.

Controller for entity

A controller is one of the main programs which should be written by SIGVerse users. This controller determines the behavior of agents, robots and objects in the virtual world. These 'objects' are called as entities in the SIGVerse.

Let's see the controller sample.

$ cd MyWorld 
$ emacs ControllerSample.cpp

ControllerSample.cpp

The agent controller creates a class named "MyController" by inheriting Controller class. In this case, onAction function is called every 1.0 seconds, which is specified as the return value of the onAction. But, as you can see, this controller does nothing.

Compiling the controller

A shell script for the compilation has been automatically prepared in your working space. You can compile the controller by

$ ./sigmake.sh ControllerSample.cpp

If the compilation succeeded, you can see ControllerSample.so.

World file

World file describes the configuration of the virtual world. In the SIGVerse system, world file is described in XML format. The following world file is already prepared in your working space.

$ emacs WorldSample.xml

WorldSample.xml

(The actual world file doesn't have the above comments.)

The world file reads thefile seToy_D.xml as an agent. Shape files of various agents and entities (x3d, wrl files) are placed in sigverse-<version>/share/sigverse/data/shapes. The xml file is prepared to use the shapes. We specify the programming language of the agent controller and attached it to the agent in world file. The flag to simulate "dynamics" was set to "true" .

Specifying the controller and its location within workspace directory

Since your workspace directory is "MyWorld", the relative path of the controller (such as ./ControlerSample.so) could be use. You may need to write the full path depending on the relation between the world file and controller file.

Starting the simulation

The script sigserver.sh is used to run the simulation and it placed in sigverse-<version>/bin directory. But you can run the simulation from anywhere because the PATH for the simulation is already set. 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 use the -w option, MyWorld.xml will be used as default world file.

Since the agent controller is specified in the xml file you just created, the agent "Toy_D" starts automatically with attached controller.

Start the SIGViewer and enter the host name and port number to connect to the SIGServer . Please use the button "Connect to SIGServer" by single click.

toy_1.jpg

World position for the agent Toy_D is described in the file as (0.0, 18.0, 5.0) . You can verify it . The height is in they direction in SIGVerse.

Start the simulation by using the framework of SIM_CTRL_CMD and the menu option START and press the button "Send"

toy_2.jpg

The simulation starts, you can confirm that the agent (toy_D) falls to the ground and bounces.

Move agents

We make some changes in the agent controller ControllerSample.cpp so that agent can move upon application of force.

$ cd ~/MyWorld
$ emacs ControllerSample.cpp

Add the following code in agent controller.

ControllerSample.cpp

     ↓

Compile and Run

$ ./sigmake.sh ControllerSample.cpp
$ sigserver.sh -w ./WorldSample.xml 

If you check SIGViewer, you can see agent moving in the z-direction where force is applied to the agent once every five seconds .

toy_3.jpg

It would be a fun exercise to use other functions such as setLinearVelocity, setTorque, and so on.

Physics for form, size and position settings

We have several visual forms representing shapes of objects like sphere ,cube , cylinder etc . But the shape of the objects for the application of physics is approximated by shape of cylinder. The default is roughly the same shape and appearance, but the size is set, and you can fix them in the configuration file.

Modification of object shape file

First, copy the original object shape file to your working directory.

$ cp ~/sigverse-<version>/share/sigverse/data/xml/seToy_D.xml .

Then, edit the configuration file of the object to observe the change.

$ emacs seToy_D.xml

in seToy_D.xml

 <body filename="dummy-body.xml"/>

please add under the following keywords

box

sphere

setting the sphere shape below

cylinder

Radius of the bottom is 3 and height of the cylinder is 10.

On run

When you run the agent controllers ( first that makes agent fall and the second that applies force on agent to move ) , please please try to see the difference in behaviors .

Units

The units in SIGVerse: angle (in radians . For all the quantities used in this tutorial world standard international (SI) system of units used.

AmountNameSign
Lengthcentimetercm
Weightkilogramkg
Timesecondss
Angleradiansrad
Velocitycentimeters per secondcm/s
Accelerationcentimeters per second per secondcm/s^2
Forcekilogram centimeters per second per secondkg cm/s^2
Torquekilogram centimeters square per second per secondkg cm^2/s^2

Up:Tutorial     Next:Humanoid agent operations

Counter: 2893, today: 4, yesterday: 3

Attach file: filetoy_3.jpg 1198 download [Information] filetoy_2.jpg 1168 download [Information] filetoy_1.jpg 1249 download [Information]

Front page   Edit Freeze Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes
Last-modified: 2016-03-26 (Sat) 18:58:35 (546d)