Simulate a game against the 01. RFC Berlin

Posted on February 25, 2022

In this blog article we want to give an introduction on how we test our software and how you can simulate a game against the 01. RFC Berlin with your own software stack.

Real-life games

In a real world game your software stack is running on each robot. These robots are connected to a WiFi network which is specifically setup for each field. Inside this network is a software called the “GameController”. It sends the current state of the game. This state includes information about game mode, game time, play phase, who has how many yellow or red cards and so on …. The game state is transmitted multiple times per second via UDP broadcast.

Simulated games

In a simulated RoboCup soccer match, a lot more software components are at play: We use Webots as a simulation software. For each robot a generic robot controller is spawned which acts as a bridge between our robot software and Webots. It is meant as a unified API for teams to communicate with the simulator, without the risk of illegally accessing data not meant for them. On top of this there is also the “referee.py”, which replaces the human referees (yes, finally they are taking our jobs!).

How to use our Docker image

As you can see, there are many pieces of software to setup and many things can go wrong. For this, we created a Docker image that bundles everything together. In the following we go step by step on how we run a game. (We assume that you have a Linux system with Docker installed.)

  1. First of all you need to create a new folder with configurations files for a game (this pulls a ~5GB Docker image):

    mkdir config
    docker run --rm -v $(pwd)/config:/config rfcberlin/webots webots-run --init
    
  2. By default there are no teams configured. Let’s add our team: Download the robot models from 01. RFC Berlin:

    cd config
    git clone https://github.com/01rfcberlin/webots-robot-models.git
    

    Adjust the game.json, such that you use our team.json:

    [...]
      "blue": {
        "id": 1,
        "config": "webots-robot-models/team.json",
    [...]
    

    The id in the team.json refers to the team ID as described by the GameController: https://github.com/RoboCup-Humanoid-TC/GameController/blob/master/resources/config/hl_sim_kid/teams.cfg This is needed so our robots can understand the game state messages. The config field points to the configuration file of our team. It describes how many robots are in our team and where each of them starts playing.

  3. Now we can run the Docker image. The image executes Webots which itself starts the referee.py, several robot controllers, and the GameController:

    docker run --rm -e DISPLAY -v /tmp/.X11-unix/X0:/tmp/.X11-unix/X0 --privileged \
                 -v $(pwd)/config:/config \
                 -ti rfcberlin/webots webots-run --game
    
    

Webots with four RFC Robots model

  1. As a final step we need to start the actual robot software that connects to the robot controllers. To start four RFC robots, you need to start four different terminals and run in each one of the following lines:

    docker run -it --rm -eROBOCUP_SIMULATOR_ADDR=$(cat config/sim_ip):10001 -eROBOCUP_ROBOT_ID=1 -eRFC_ARGS="--record.active false" ghcr.io/01rfcberlin/rfc-robot
    docker run -it --rm -eROBOCUP_SIMULATOR_ADDR=$(cat config/sim_ip):10002 -eROBOCUP_ROBOT_ID=2 -eRFC_ARGS="--record.active false" ghcr.io/01rfcberlin/rfc-robot
    docker run -it --rm -eROBOCUP_SIMULATOR_ADDR=$(cat config/sim_ip):10003 -eROBOCUP_ROBOT_ID=3 -eRFC_ARGS="--record.active false" ghcr.io/01rfcberlin/rfc-robot
    docker run -it --rm -eROBOCUP_SIMULATOR_ADDR=$(cat config/sim_ip):10004 -eROBOCUP_ROBOT_ID=4 -eRFC_ARGS="--record.active false" ghcr.io/01rfcberlin/rfc-robot
    

Robots being controlled by our software stack

If you look closely at the screenshot, you can see that the simulation is only running at a real time factor of 0.12, meaning that 1 game minute, will take 8 mins in the real world. A full game is played for 20 mins which leads to a simulation time of at least 160 mins. For testing purposes we always play with only one or two robots. This can be easily achieved by adjusting the config/webots-robot-models/team.json and removing player 3 and 4.

How can you make your robot play against our robots?

You need to provide a few things:

  • Robot Model description that can be understood by Webots.
    For this you can take a look at our Robot model. You can also find robot models of other teams on the official website. There is also a very detailed description on how to do this in the robocup subdirectory of Webots.
  • Connect your software stack with the robot controller of Webots.
    There exists a small demo program: Client Demo
  • Connect your software stack with the game controller.
    You can find a implementation of the Bit-Bots for ROS in there repositories

Contact

You need any help and/or have question? Join the RoboCup Humanoid League Discord Server.

Resources: