Up:Tutorial? Previous:Humanoid agent operations Next:Vision sensor
※This tutorial is valid only for later than v2.1.0.
Create a controller for sending messages.
$ cd ~/MyWorld $ emacs SendController.cpp
SendController.cpp
This controller send a message "Hello!" to the robot agent every second.
If you want to send a message to all of the agents in the world, you should use broadcastMsg instead of sendMsg.
Old
New
Create a controller to receive messages.
$ emacs RecvController.cpp
RecvController.cpp
This controller put the agent's hand up if a message "Hello!!" comes. The agent will put the hand down every 0.5 second.
Compiling the controller.
$ ./sigmake.sh SendController.cpp RecvController.cpp
$ emacs MessageWorld.xml
MessageWorld.xml
In this controller, a human avator will send a message to a humanoid agent.
$ sigserver.sh -w ./MessageWorld.xml
First, the avatar agent put a hand down and turn back by onInit function. Then, you can see that the agent put it's hand up every second with receiving a message.
This part explains how to specify the maximum length of the reachable area of the message sending function.
Create another controller to send messages.
$ emacs SendController2.cpp
SendController2.cpp
The second argument of the broadcastMsg, 300, means that the maximum distance of the message reachable area is 3 meters. If you omit the secnod argument, the message will be reached to all of the agents irrespective of the distance.
This agent keeps on sending a message and moving to z-axis.
$ ./sigmake.sh SendController2.cpp
$ emacs MessageWorld.xml
Modify the MessageWorld.xml to change the controller for sending agent
Old
New
$ sigserver.sh -w ./MessageWorld.xml
You can see the agent sending messages with backing away from the receiver. Please check how far the message reaches to the receiver.
If the broadcastMsg is used, the message will be reached to all of the agents, SIGViewer and SIGVerse services. The SIGViewer will show the received message as log message.
You can send messages to the SIGViewer using sendMsg. In this case, you should specify a service name which is determined when the SIGViewer connected to the SIGverse server. If the service name is "SIGViewer", the following modification will change the sending target from the agent to the SIGViewer.
SendController.so
Old
New
Up:Tutorial? Previous:Humanoid agent operations Next:Vision sensor