Software

Software is applied in between the fields of AI and the Control logic.

This section of the documentation will mostly cover the way on how the internal networking within the central software has been implemented, which is further explained within the topic of Networking and the transmission of the AI commands to the Basestation in RobotHub.

The AI is dependent on multiple programmes in order to function: ssl-vision or a simulator, world, robothub and AI itself. The interaction within these programmes is written in such a way that they are able to run on completely different systems.

These systems interact with each other over a protocol named Google Protobuf. These protobuf messages are comparable to other encoding standards like JSON and XML. The difference with these two standards is however, that protobuf uses pre-defined packages. One of these packages is shown below:

syntax = "proto3";

import "Vector2f.proto";
import "RobotProcessedFeedback.proto";

package proto;

message WorldRobot {
    uint32 id = 1;
    Vector2f pos = 2;
    float angle = 3;
    Vector2f vel = 4;
    float w = 5;
    RobotProcessedFeedback feedbackInfo = 6;
}

All the defined protobuf packages that are used can be found in roboteam_networking. More specifically inside roboteam/roboteam_networking/proto.

N.B.: Be aware when you're encoding or decoding your messages in order to send or receive them over the network that you do this into direct bytes. Some flavours of the Protobuf library do not support this out-of-the-box. I couldn't get this to work for example on Python. But it does work on the C++ and Java versions.

In order to actually send the packages that Protobuf creates over the (interal) network. We make use of TCP connections. Since we do not want to reinvent networking by ourselves we use the ZeroMQ library. One of the advantages of this libraries is that it has support for the idea of subscribers and publishers, which allows for multiple devices to listen to the same port at the same time.

An example on how to connect with ZeroMQ in Java is given below:

try (ZContext context = new ZContext()) {
    // Setup the socket as a subscriber
    ZMQ.Socket socket = context.createSocket(ZMQ.SUB);
 
    // We want to listen to all the topics send over this network.
    // If you want only a specific topic, then you can enter its name, instead of an empty string.
    socket.subscribe("");
    socket.connect("tcp://" + IP_ADDRESS + ":" + PORT);
 
    System.out.println("Waiting for messages...");
    while (!Thread.currentThread().isInterrupted()) {
        byte[] msg = socket.recv();
        // Message received! 
        // Now you can proceed decoding it with the help of Protobuf if it is such a package
    }
}

These messages are sent over internal network channels of which the following are being used:

Title IP Address Port number Description
World 127.0.0.1 5558 Used to sent the latest world information from observer to AI, using the state.proto packages
Robot feedback 127.0.0.1 5561 Used to send the feedback from the robots back to the AI
Robot command 127.0.0.1 5559 (blue) / 5560 (yellow) Used to send the commands to each team
Settings 127.0.0.1 5564 ?
Interface to AI 127.0.0.1 16970 Used to send the commands from the AI interface to the AI
AI to interface 127.0.0.1 16971 Used to send the commands from the AI to the AI interface
Simulation configuration 127.0.0.1 5562 Used to send the configuration for the current simulation to the AI

Just as vision can help us form a picture of what the exact state of a game is at any time, the robots themselves can also help with this. Data like the current performance of a robot and sensor data should be fed back into the decision making.