Up:Tutorial?     Previous:Samples of the dynamics simulations     Next:Exchange of messages between agents

Operations on the movement of agents

Describes how to operate the joints of agents or anthropomorphic robots.

Operations of joints of robots

Here is the sample code to change the angle of joint of human hand.

Creating the Controller

Let's create a controller file AgentController.cpp in the MyWorld workspace.

$ emacs AgentController.cpp


In this controller, the avatar agent bend the left arm to 45 degree by the my->setJointAngle function.


The same script sigmake.sh should be used for the compilation as well as the previous example.

$ ./sigmake.sh AgentController.cpp

Creating world files

Then create a world file in the same workspace.

$ emacs AgentWorld.xml


The file specifies Man-nii.xml as humanoid avatar. Dynamics mode is set to false to specify concrete joint angle value to change the posture of the avatar. Please be careful that you cannot specify such concrete joint angle values in dynamics On mode.

Starting SIGVerse

So let's start SIGVerse.

$ sigserver.sh -w ./AgentWorld.xml

Connect to the SIGServer and push the "START" button to start the simulator. You can see that the agent holds the left arm to 45 degree.


We use setJointAngle to set the angle of "LARM_JOINT2" to 45 degree."LARM_JOINT2" is the name of the joint defined for rotation of the left shoulder on Z axis.

Joint names of these files are defined in sigverse-x3d <version> / share / sigverse / data / shape / (nii_man.x3d) .

Joint names and join definitions of the sample model described in current Agentworld.xml file are read from file Man_nii.xml which in turn is reading the file nii_man.x3d describing the shape of a human-type agent.

Man-nii humanoid agent is an object that inherits from the Agent class. The default value of the Agent class attribute is set in Agent.xml. Let's see the file Agent.xml

$ less xml/Agent.xml

Furthermore, Agent class has inherited the Entity class. Entity class is the class of objects that do not behave autonomously.

Agents, basic attributes of an entity

Entities introduces the basic properties of the agent.

Attribute of an entity

Attribute NameMeaningRemarks
x, y, zposition of the entityglobal coordinates. green arrow from the origin for x-axis, yellow arrow for y-axis red arrow is shown for z-axis
fx, fy, fzforce on the entity
vx, vy, vzspeed of the entity
qw, qx, qy, qzdirection of the entityQuaternion notation
scalex, scaley, scalezthe size of the entity

Agent attributes

Attribute NameMeaningRemarks
vpx, vpy, vpzposition of the viewpoint of the agent (non-humanoid)agents coordinate origin is the position of the agent
vvx, vvy, vvzgaze direction (non-humanoid)vector notation
elnk1, elnk2, ... elnk9viewpoint (camera) to establish a link name (humanoid only)elnk1 HEAD_LINK are installed by default.
epx1, epy1, epz1, ... epx9, epy9, epz9viewpoint (camera) position (humanoid only)origin is specified by the position of the link elnk
evx1, evy1, evz1, ... evx9, evy9, evz9viewpoint (camera) direction (humanoid only)
FOVAgent viewing angle (height)
voiceReachRadiusAgent voices reach

These attributes can be set in all the world files.

Operating agents with a Command

In the above example, a function onAction was used to raise the hands of the agent. Next sample code uses message sending function in order to control the avatar from SIGViewer.

Let's create another controller file named AgentController2.cpp

$ emacs AgentController2.cpp


agent puts its hands down when onAction function is called , The onRecvMessage function will be called when a message is sent to the controller. In this example, the agent will bows when a message "Hello" comes.

Compile the new controller file.

$ ./sigmake.sh AgentController2.cpp

World file

You should modify the world file to use the new controller file.


Execute the server

Input the following command to execute the SIGVerse server.

$ sigserver.sh -w ./AgentWorld.xml

Start the SIGViewer, and connect to the SIGServer. When you push the start button, the avatar agent down its both hands with onAction function.


Sending a message

Click the "Message" button on the right bottom of the SIGViewer. A new subwindow "SendMessage" will appear. Select the target agent "man_000" in the TargetEntity field. Next, input a message "Hello" in the following Message: field as shown in the figure.


Click the "Send" button if you input the message.


You can see the avator bows.

Joint rotation with quaternion

Rotation of the joint can also be set by the quaternion.



setJointquaternion function sets the joint angle using quaternions. The joint names of the quaternion are specified in argument w, x, y, z.

Please try to make sure the joint is rotated correctly.

Up:Tutorial?     Previous:Samples of the dynamics simulations     Next:Exchange of messages between agents

Counter: 6031, today: 1, yesterday: 0

Attach file: fileman_4.PNG 2067 download [Information] fileman_3.PNG 2148 download [Information] fileman_2.PNG 2162 download [Information] fileman_1.PNG 2122 download [Information] fileman_4.jpg 1600 download [Information] fileman_3.jpg 1496 download [Information] fileman_2.jpg 1488 download [Information] fileman_1.jpg 1504 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) 19:00:01 (2808d)