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

NewWorld is the directory in which we create AgentController.cpp

$ cd ~/sigverse-<version>/bin/NewWorld
$ emacs AgentController.cpp

AgentController.cpp

Sample at the start of the simulation my->setJointAngle is used to set the angle to 45 degree for left arm of robot.

Compiling

Lets change the Makefile.

$ emacs Makefile
#The object is modified to incorporate the changes due to new agent controller
OBJS = AgentController.so

Makefile

#The location of the source of header files for SIGVerse
SIG_SRC  = /home/<username>/sigverse-<version>/include/sigverse

#The object 
OBJS     = AgentController.so 

all: $(OBJS)

#Compile
./%.so: ./%.cpp
        g++ -DCONTROLLER -DNDEBUG -DUSE_ODE -DdDOUBLE -I$(SIG_SRC) -I$(SIG_SRC)/comm/controller  -fPIC -shared -o $@   $<

Compile

$ make

Creating world files

Then create a world file

$ cd ~/sigverse-<version>/bin
$ ln -s ../share/sigverse/data/xml/ xml

This glues the link to the directory where the xml file is located

$ emacs xml/AgentWorld.xml

AgentWorld.xml

The file being read is Man-nii.xml, dynamics is set to false.

Starting Sigverse

So let's start SIGVerse.

$ ./sigserver.sh -w AgentWorld.xml -p 9001

Upon connecting to the SimServer in SIGViewer and starting the simulation , the agent's left arm expands with an increased angle of 45 degree .

man_1.jpg

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.

Agent Attributes

Checking Attributes

Click the Attributes tab . You can check the attributes of the agent as a whole and also part attributes by clicking on the part of agent model . The general attributes are location of the agent in SIGViewer (x, y, z), the orientation of the agent (qw, qx, qy, qz), the position of the viewpoint (epx, epy, epz) etc . The value of these attributes are set in the xml file.

#ref(): File not found: "attr_1.jpg" at page "Humanoid agent operations"

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

Last time we introduced the sample code that calls function onAction to raise the hands of agent hands regularly. The following provides sample code to bow to the agent by sending a message from SIGViewer.

Introducing changes to AgentController.cpp

$ cd NewWorld
$ emacs AgentController.cpp

AgetnController.cpp

agent puts its hands down when onAction function is called , onRecvMessage function is to be called when a message is received. The message "Hello" is passed which triggers the function that makes the agent to the bow.

Compile.

$ make

Run

Edit the attributes of the Agent. So let's run.

$ cd ..
$ ./sigserver.sh -w AgentWorld.xml -p 9001

Connect with SIGViewer, and start the simulation by clicking the send button, lower left and right hands go down as the funcion onAction is called first.

man_2.jpg

Send a message

Click the "Command" tab on the right side of GUI and select "General" . Type the name of agent as "man_000" , and write "Hello" , without strings .

man_3.jpg

Click the "Execute" button and check the behavior.

man_4.jpg

You can see the avator bows.

Joint rotation with quaternion

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

AgentController.cpp

   ↓

setJointquaternion function is called to set the joint using quaternions. Then the joint names of the quaternion are specified in argument w, x, y,z.

Please try to make sure the joint is rotated correctly.

Counter: 6104, today: 2, yesterday: 0

Front page   New List of pages Search Recent changes   Help   RSS of recent changes