Coder Social home page Coder Social logo

robocup-ssl / ssl-game-controller Goto Github PK

View Code? Open in Web Editor NEW
18.0 12.0 33.0 5.84 MB

The game controller for matches in the RoboCup Small Size league

License: GNU General Public License v3.0

Go 43.76% JavaScript 0.04% HTML 0.05% Vue 20.01% Shell 0.36% Dockerfile 0.16% SCSS 0.09% TypeScript 35.44% Makefile 0.10%

ssl-game-controller's Introduction

CircleCI Go Report Card Go Doc Release Coverage

ssl-game-controller

The game controller for matches in the RoboCup Small Size league, introduced at RoboCup 2019 as a replacement of the ssl-refbox.

Screenshot of Interface

Add your team name

If you are a new team, please add your team name to internal/app/engine/config.go.

Usage

If you just want to use this app, simply download the latest release binary. The binary is self-contained. No dependencies are required.

You can also use pre-build docker images:

docker pull robocupssl/ssl-game-controller
# Run GC with default configuration
docker run -p 8081:8081 robocupssl/ssl-game-controller -address :8081

Mount local directories

docker run -p 8081:8081 \

Local config dir

-v "$(pwd)"/config:/config \

Local data dir (current state)

-v "$(pwd)"/data:/data
robocupssl/ssl-game-controller


The controller will generate a default config to [config/](./config/) on the first start. Afterwards, you can change all
settings there.

For example, if you want to add a new team name temporarily, you can add it
to [config/engine.yaml](./config/engine.yaml). If you want to add your team persistently, add it to `defaultTeams`
in [internal/app/engine/config.go](internal/app/engine/config.go) and create a pull request on GitHub.

### Runtime Requirements

* No software dependencies (except for development, see below)
* pre-build binaries: 64bit Linux, Windows, OSX
* A reasonable Web-Browser (mostly tested on Chrome)

### External Runtime Dependencies

[ssl-vision](https://github.com/RoboCup-SSL/ssl-vision) - Receive Geometry packages for correct field dimensions.   
If not available, make sure to configure the correct dimensions
in [config/ssl-game-controller.yaml](config/ssl-game-controller.yaml).

tracker-source implementation that produces
[TrackerWrapperPacket](https://github.com/RoboCup-SSL/ssl-vision/blob/master/src/shared/proto/messages_robocup_ssl_wrapper_tracked.proto) -
Get ball and robot positions.      
Required for:
 * Check ball placement progress
 * Check for correct number of robots per team
 * Check if game can continue (ball and robots prepared)
 * Check for "no progress"
 * Check if keeper may be changed via team protocol

The [TIGERs AutoRef](https://github.com/TIGERs-Mannheim/AutoReferee) and
the [ER-Force AutoRef](https://github.com/robotics-erlangen/autoref) are tracker-source implementations.
If no tracker-source is available, the above features will not work.

### Reference Clients
There are some reference clients:
 * [ssl-ref-client](./cmd/ssl-ref-client): A client that receives referee messages
 * [ssl-auto-ref-client](./cmd/ssl-auto-ref-client/README.md): A client that connects to the controller as an autoRef
 * [ssl-team-client](./cmd/ssl-team-client/README.md): A client that connects to the controller as a team
 * [ssl-remote-control-client](./cmd/ssl-remote-control-client/README.md): A client that connects to the controller as a remote-control
 * [ssl-ci-test-client](./cmd/ssl-ci-test-client/README.md): A client that connects to the CI interface of the controller
 
### Integration into your own framework
The game-controller is designed to be integrated into your own AI framework, if you do not want to implement your own controller for testing purposes.

Download the release binary from the Github release and run it from inside your framework.
You can adapt the `ssl-game-controller.yaml` config file that is generated on first startup,
like changing the default ports. Some parameters can also be passed via command line.
Find the available parameters with the `-h` option.
Make sure to use non-standard ports whenever possible to avoid any interference with a real field setup.

There are three modes that you can run the ssl-game-controller with:

1. `system` (default): Use system time
2. `vision`: Receive messages from ssl-vision and use the timestamps from these messages as the time source. This is mostly useful, when you produce your own ssl-vision frames from simulation.
3. `ci`: Connect your software directly to the GC via TCP. You send the current timestamp and tracker packets and will receive the resulting referee message.

It is highly recommended using the `ci` mode when you integrate the GC with your own simulator.
It has the following advantages:

1. No multicast network traffic is required that might be published to your local network (make sure to unset `network.publish-address`)
2. You have full control of the data flow. The GC will not do anything asynchronously in the background
3. You define the time and thus the speed.
4. You provide the ssl-vision tracking data directly.

If you use external simulators like grSim, you can consider using the `vision` mode instead.
That way, the game-controller uses the time and speed of the simulator, even if it is not
running in real time. You then still need to run a tracking-source implementation like an AutoRef
if you require the additional features described in [External Runtime Dependencies](#External Runtime Dependencies).

When you enable `ci` mode, referee messages will still be published via multicast,
unless the address is unset (set to an empty string). That way, you can still integrate
an autoRef or other software. Have a look at [Auto-referee CI](doc/AutoRefCi.md) for details on how to integrate the auto-referees in a CI way as well.

When the `ci` mode is enabled (via `ssl-game-controller.yaml` -> `time-acquisition-mode`),
a TCP port is opened (default: 10009). The protocol is defined in [proto/ssl_gc_ci.proto](./proto/ssl_gc_ci.proto).
You send `CiInput` messages and receive `CiOutput` messages. The protocol is the same as for the [team-client](./cmd/ssl-team-client/README.md).
Each input will produce one or more outputs.
This is, because some changes will generate multiple messages.
`CiOutput` messages will also be pushed to the CI client for manual changes from the UI or UI API.

The GC requires some input data, see [External Runtime Dependencies](#External Runtime Dependencies).
In the `ci` mode, you have to provide the geometry statically in [config/ssl-game-controller.yaml](config/ssl-game-controller.yaml) or send it through `CiInput`.
The ball and robot positions must be sent with the `CiInput`.
It is sufficient to fill in the required fields and keep the optional empty.

A small sample test client for the `ci` mode can be found here: [ssl-ci-test-client](./cmd/ssl-ci-test-client/README.md)

If you can not use the `ci` mode, you can alternatively connect to the GC using the UI WebSocket API.
The API is defined in [proto/ssl_gc_api.proto](./proto/ssl_gc_api.proto) and available at the path `/api/control`
under the same port as the UI.

#### Examples
 * Integration of the binary: https://github.com/TIGERs-Mannheim/AutoReferee/blob/master/modules/moduli-referee/src/main/java/edu/tigers/sumatra/referee/SslGameControllerProcess.java
 * WebSocket API in Java: https://github.com/TIGERs-Mannheim/AutoReferee/blob/master/modules/moduli-referee/src/main/java/edu/tigers/sumatra/referee/control

## Development

### Requirements

You need to install following dependencies first:

* Go
* Node

See [.circleci/config.yml](.circleci/config.yml) for compatible versions.

### Frontend

See [frontend/README.md](frontend/README.md)

### Build

Build and install all binaries:

```bash
make install

Run

go run cmd/ssl-game-controller/main.go

Test with autoRefs

To quickly run the GC together with autoRefs and other popular components, run:

docker compose up

Update generated protobuf code

Generate the code for the .proto files after you've changed anything in a .proto file with:

make proto

ssl-game-controller's People

Contributors

akito914 avatar andreaswendler avatar barulicm avatar bollos00 avatar conancom avatar dependabot[bot] avatar etienneschmitz avatar g3force avatar mame98 avatar oliverobst avatar rarecentipede avatar renovate-bot avatar renovate[bot] avatar tamagoham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssl-game-controller's Issues

error occured in release binary at v3.0.0

OS: Ubuntu20.04

The error is following

$ ./ssl-game-controller_v3.0.0_linux_amd64 
./ssl-game-controller_v3.0.0_linux_amd64: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./ssl-game-controller_v3.0.0_linux_amd64)
./ssl-game-controller_v3.0.0_linux_amd64: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./ssl-game-controller_v3.0.0_linux_amd64)

Feature: Add a filter option for the protocol

The match protocol can be quite long and it may be desirable to search for a specific entry, e.g. by protocol type, game event, command, etc.

Such filters could be added to the protocol view (not the side bar).

Name Conflicts When Importing Protobuf Definitions

Context: Recently, we tried importing the new protobuf definitions from this repo into our repo, namely ssl_gc_common.proto, ssl_gc_game_event.proto, ssl_gc_geometry.proto, and ssl_gc_referee_message.proto. We wanted to do this because https://github.com/RoboCup-SSL/ssl-refbox/ has been deprecated, and this repo's definitions has some updated documentation.

Problem: We encountered name conflicts between our internal Team and RobotId classes and the ones defined in ssl_gc_common.proto. This is a change from defining them inside the GameEvent message as in https://github.com/RoboCup-SSL/ssl-refbox/. We also noticed that SSL_Referee has been renamed to Referee, which might cause name conflicts in the future (but currently don't in our repo). We're curious why these changes were made as it causes problems for easily updating these protobufs in our code and other teams would probably encounter the same issues.

Suggested solution: Prefix protobuf messages with SSL_ or embed them in other message definitions, as was done in https://github.com/RoboCup-SSL/ssl-refbox/

Entering numbers on numpad triggers commands

The num-Pad Shortcuts can not be disabled temporary, so if a number is entered on the num-pad somewhere, this will also trigger the assigned commands.

Either need to change the shortcuts, or have a look into the shortcut library.

The game controller crashes without internet connection

If I start the game controller as described in the readme.md, but the computer doesn't have an active internet connection (i.e. wifi disabled, no LAN), the game controller crashes with the following stack trace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x68 pc=0x78f4f0]

goroutine 26 [running]:
github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller.(*RefMessage).setState(0xc420080908, 0xc42018c200, 0x431ce0)
/home/andi/go/src/github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller/publisher.go:106 +0x70
github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller.(*RefMessage).Publish(0xc420080908, 0xc42018c200)
/home/andi/go/src/github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller/publisher.go:85 +0x35
github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller.(*Publisher).Publish(0xc420080900, 0xc42018c200)
/home/andi/go/src/github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller/publisher.go:80 +0x3b
github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller.(*GameController).publishNetwork(0xc420080800)
/home/andi/go/src/github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller/controller.go:251 +0x5e
created by github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller.(*GameController).Run
/home/andi/go/src/github.com/RoboCup-SSL/ssl-game-controller/internal/app/controller/controller.go:215 +0x1a3
exit status 2

Unit documentation in GameEvent

Currently there's no documentation for a large part of the fields of what units they have for GameEvent, particularly the locations. Are these in meters? or millimiters (ssl-vision standard?)?

Aborting a placement with a force start causes side effects

Find a Sumatra Recording attached:

2024-01-30_13-33-02.zip

What happens in the recording? Note both AIs are set to off.

  1. The ball is placed manually inside the blue defense area.
  2. After 5s a Keeper Held Ball Foul is issued
  3. The ball placement is done manually by just placing the ball
  4. After the successful ball placement the game is continued with a force start
  5. The ball is placed back into the defense area
  6. After 5s a Keeper Held Ball Foul is issued
  7. Yet again ball placement, but this time the ball placement is interrupted with a manual force start
  8. The ball is placed back into the defense area
  9. Now it takes more than 20s for the Keeper Held Ball Foul to be issued.

Note the 30s ball placement timer is still counting down, although the ball placement was already aborted with the force start.

Unset GameEvent type in referee message

I was testing with the latest release (2.0.7)

To reproduce:
-Run the gamecontroller without vision available:
-Run a penalty (Stop->Penalty->NormalStart)
-Let the time (10 seconds) run out

After this happens, we get the following error on our system receiving the referee messages:

[libprotobuf ERROR google/protobuf/message_lite.cc:122] Can't parse message of type "proto.Referee" because it is missing required fields: game_events[0].type

In any case, I don't think the GameController should send unparseable messages so I think this is a valid issue.

When ball placement fails, it is not always clear why

Problem

Ball placement can fail for different reasons. The most obvious one is, when the ball is not yet on the placement position. If it is, the placing robot still needs to bring some distance to the ball, see: https://robocup-ssl.github.io/ssl-rules/sslrules.html#_ball_placement
The PLACEMENT_FAILED event only includes the remaining_distance. If it is close to zero, it is not obvious, for which reason the placement failed.

Current situation

Currently, the autoRefs are responsible to create PLACEMENT_SUCCESSFUL events, when all conditions are met.
The GC will create a PLACEMENT_FAILED event, when no successful event was sent by the autoRefs in time.
The GC will include the remaining distance from ball to placement position in the failed event.

Proposed solution

Easy short-term solution

  • Add a nearest_own_bot_distance property to the PLACEMENT_FAILED event.
  • Calculate the value in the GC and add it to the event

Better solution

The above proposed solution does not solve the problem reliably: There could still be an inconsistency between how an autoRef judges the success / failure of the placement. Specifically, if using majority voting and a majority is not reached, the placement would be counted as failed, without reporting additional information about why it failed.

A better solution could be to report success and failure consistently at only one place: Either the autoRefs or the GC:

  • The responsibility of sending the PLACEMENT_FAILED event could be transferred to the autoRefs. However, especially with the current majority implementation, there is no guaranty, that all autoRefs report the failure, so the timeout mechanism of placement may not work.
  • The responsibility of sending the PLACEMENT_SUCCESSFUL event could be transferred to the GC. The majority mechanism would be lost. However, the detection is not that complicated. This could also solve another corner case: If multiple autoRefs report the success at different times, the current majority implementation would not accept it.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Update module github.com/go-test/deep to v1.1.1
  • Update module github.com/gorilla/websocket to v1.5.3
  • Update alpine Docker tag to v3.20
  • Update cimg/base Docker tag to v2024.07
  • Update cimg/go Docker tag to v1.22.5
  • Update golang Docker tag to v1.22
  • Update module github.com/google/uuid to v1.6.0
  • Update module google.golang.org/protobuf to v1.34.2
  • Update robocupssl/ssl-log-player Docker tag to v1.6.0
  • Update robocupssl/ssl-remote-control Docker tag to v1.3.2
  • Update robocupssl/ssl-status-board Docker tag to v2.11.2
  • Update robocupssl/ssl-vision-client Docker tag to v1.8.0
  • Update tigersmannheim/auto-referee Docker tag to v1.4.1

Detected dependencies

circleci
.circleci/config.yml
  • cimg/go 1.21.6
  • cimg/go 1.21.6
  • cimg/go 1.21.6
  • cimg/base 2024.01
  • cimg/base 2024.01
docker-compose
docker-compose.yaml
  • robocupssl/ssl-vision-client 1.7.3
  • robocupssl/ssl-status-board 2.10.4
  • robocupssl/ssl-remote-control 1.1.3
  • robocupssl/ssl-remote-control 1.1.3
  • tigersmannheim/auto-referee 1.2.0
  • robocupssl/ssl-log-player 1.5.2
  • robocupssl/ssl-simulation-controller 0.12.1
dockerfile
cmd/ssl-game-controller/Dockerfile
  • node 20-alpine
  • golang 1.21-alpine
  • alpine 3
cmd/ssl-ref-client/Dockerfile
  • golang 1.21-alpine
  • alpine 3
cmd/ssl-team-client/Dockerfile
  • golang 1.19-alpine3.15
  • alpine 3.19
gomod
go.mod
  • go 1.21
  • github.com/go-test/deep v1.1.0
  • github.com/google/uuid v1.5.0
  • github.com/gorilla/websocket v1.5.1
  • github.com/pkg/errors v0.9.1
  • google.golang.org/protobuf v1.33.0
  • gopkg.in/yaml.v3 v3.0.1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.