Jump to the communication Package Index .
The RoboComm API is implemented in TBSim for robot communication in simulation. It is also implemented using TCP/IP sockets for communication between mobile robots. To aid rapid prototyping, the APIs are implemented so that a user process (usually a robot control system) cannot distinguish between the simulated and TCP/IP versions.
Sending and receiving messages is easy. Here is a code snippet illustrating how a string message can be sent to robot 2:
t.unicast(2, new StringMessage("hello!"));The process on robot 2 receives the message using code like this:
new_message = r.getNextElement();RoboComm is composed of a server application and client software. Client software is included in the EDU.gatech.cc.is.communication package. Installation
Once you have installed the software, you can test it using the included demonstration program. First, open a window and start the server:
java RoboComm.RoboCommOpen another window and start client number 1:
java RoboComm.Client 1Open another window and start client number 2:
java RoboComm.Client 2The text output in the server window should look like this:
RoboComm 0.91 (c)1998 Tucker Balch RoboComm.run: started on pilot.cc.gatech.edu Listening for connections on port 7462 RoboComm: client 1 registered RoboComm: client 2 registeredThere will also be several messages printed in the client windows. The RoboComm server
To start the server, type:
java RoboComm.RoboCommThe server will start up and wait for robots to request a connection. It will print informative messages when important events occur, like when a new robot connects, or a connection is lost.
Usually, you can just start the server once and forget about it. Note: you do not need to start the server if you only need communication in simulation. Sending and receiving messages
To communicate, the first thing to do is to create a Transceiver object:
Transceiver t = new TransceiverHard("desoto.cc.gatech.edu", 2);This will open a connection to the RoboComm server on desoto and register the process as robot number 2. A thread to monitor for incoming messages is automatically started up. All messages transmitted to robot 2 will be handled by the thread. As messages are received, they are inserted into a buffer and made available for processing by the higher level software. To access received messages, you need to ask for a ``receive channel'' as follows:
Enumeration messages_in = new t.getReceiveChannel();You can allocate as many receive channels as you like; all incoming messages will be duplicated and inserted in a queue for each receive channel. You can test to see if any messages are queued by calling the hasMoreElements() method. In this example, we loop while messages are available and print them:
while (messages_in.hasMoreElements()) System.out.print(messages.nextElement());Sending messages is also fairly straightforward. RoboComm supports broadcast, unicast, and multicast transmissions. Here are examples of broadcast and unicast:
t.broadcast(message); t.unicast(1,message);A broadcast call will send a copy of message to all registered processes. Unicast just sends one message to the specified robot.
Look at Client.java for a complete example client program. Sending your own message types