Giter VIP home page Giter VIP logo

gamecontroller's Introduction

Build Status

RoboCup SPL and Humanoid League GameController

This is the GameController further developed by the Humanoid League based on the GameController from the SPL Team B-Human

If there are any questions, please contact [email protected]. Please read this README carefully to avoid questions that are already answered within the document or the TCM.

For questions regarding the protocol please check the Wiki.

The sources mentioned in some sections of this document are available at https://github.com/RoboCup-Humanoid-TC/GameController.

Upcoming changes (2018)

  • Removal of Illegal Defense and Illegal Attack
  • Allow Adult league to play drop in 2 vs. 2
  • Skip extra time in knockout games
  • Fix point counting on drop in challenge
  • Fix "GameController goes to extended time even in normal mode"
  • Highlight and make "current goalkeeper" changeable in UI

See CHANGELOG for more details and history.

Acknowledgement

The development was partially supported by the RoboCup Federation within the calls for Support for Projects for League Developments for 2013, 2015 and 2017.

1. Building from Source

To build it from the source code you may use Apache Ant. Just call "ant" in the main directory.

Building the source code requires the JDK 1.8 or newer.

2. GameController

Executing the Jar

Double-click GameController.jar or run

Usage:

cd build/jar
java -jar GameController.jar {options}
(-h | --help)                   display help
(-t | --test)                   use test-mode - currently only disabling the
                                delayed switch to playing in SPL
(-i | --interface) <interface>  set network interface (default is a
                                connected IPv4 interface)
(-l | --league) (spl | spl_dropin | hl_kid | hl_teen | hl_adult)
                                select league (default is spl)
(-w | --window)                 select window mode (default is fullscreen)

Start Dialog

Select your league. The default can be specified as a command line parameter (see above).

Pick the two teams that are playing. They have to be different teams. If you are practicing alone, use the "Invisibles" as second team.

SPL: The GameController automatically selects the jersey colors as defined in the file "teams.cfg". The left teams jersey color is picked first regardless if it has a custom jersey or not. For both teams, the first jersey color that they have and, if picking second, that does not conflict with the jersey color of the opponent is selected in the following sequence:

  • Left team: custom 1, custom 2, blue, red
  • Right team: custom 1, custom 2, red, blue

The GameController operator can switch each teams color to their secondary color if it is necessary to distinguish the jersey colors.

You also have to select whether you play a game in the preliminaries or a play-off game. In the preliminaries the clock will continue to run during game stoppages and there will be no penalty shootout in case of a draw. In play-off games, the clock will be stopped and there may be penalty shootout.

HL: You also have to select whether you play a normal game or a knock-out game. A knock-out game will continue after a draw with two halves of extra time (if goals were scored before) and then a penalty shoot-out if necessary. You can also select whether teams exchange their colors in the halftime.

You can select whether the GameController should run in fullscreen mode or in windowed mode. Note that the fullscreen mode does not work correctly on some Linux desktops, because although they report to Java that they would support this feature, they do not.

Main Screen

The use of the main screen should be rather obvious in most cases. Therefore, we only focus on the specialties.

When ever you made a mistake, use the undo history at the bottom of the screen to correct it. You cannot correct individual decisions (except for the last one). Instead, you can only roll back to a certain state of the game. Click the oldest decision in the history you want to undo. After that all decisions that would be undone will be marked. Click the decision again to actually undo it together with all decisions that followed.

To penalize a robot, first press the penalty button, then the robot button. The only exception is the state "Set" in playoff games, in which the "Motion in Set" penalty is preselected and robots can be penalized by simply clicking on them (selecting other penalties is still possible). For unpenalizing a robot, just press the robot button. A robot can only be unpenalized, when its penalty time is over or when the game state changes (SPL only). Ten seconds before the penalty time is over, the robot's button starts flashing yellow. For regular penalties, it continues to flash until the button is pressed. Only buttons of robots that were requested for pickup stop flashing after ten seconds and simply stay yellow until they are pressed, as a reminder that the robot can return as soon as it is ready. Robots with a "Motion in Set" penalty stay on the field and will be automatically unpenalized 15 seconds after pressing the button "Play".

Before unpenalizing a robot that was taken off the field, please make sure that it was put back on the field by the assistant referees. For that reason, robots are never unpenalized automatically.

To substitute a robot, press "Substitute" and then the robot that should leave the field. Afterwards, any of the substitutes can be activated. If the robot that is replaced is already penalized, its substitute inherits the penalty. If it is not, the substitute can immediately enter the field in the HL, but gets a "request for pickup" penalty before it can enter the field in the SPL.

When pressing the big "+" (goal), "Timeout", or "Global Game Stuck", the other team gets the next kick-off.

SPL: When the referee decides that too much game time has been lost, use the thin "+" next to the clock to increase the game time in one-minute steps. This is only available during stoppages of play.

Penalty Shootout

In the penalty shootout, press "Set" and place the robots in their correct locations. Press "Play" to start a single shot. The penalty shot is ended by either pressing "+" for the penalty taker or by pressing "Finish" if the shot failed. In both cases, a penalty shot ends in the state "Finished". Press "Set" again to start the next shot.

Shortcuts

While the GameController is running, you may use the following keys on the keyboard instead of pushing buttons:

Esc       - press it twice to close the GameController
Delete    - toggle test-mode (everything is legal, every button is visible
            and enabled)
Backspace - undo last action

only SPL

B    - out by blue
R    - out by red
Y    - out by yellow
K    - out by black
     - the new team colors implemented for RoboCup 2016 do not yet have a key
       assigned

P    - pushing
L    - leaving the field
I    - fallen / inactive / local game stuck
D    - illegal defender
G    - kickoff goal 
O    - illegal ball contact
U    - request for pickup
C    - coach motion
T    - teammate pushing
S    - substitute

only Humanoid-League

B    - out by blue
R    - out by red

M    - ball manipulation
P    - physical contact
A    - illegal attack
D    - illegal defense
I    - service / incapable
S    - substitute

Adding teams to the GameController

The teams registered in the GameController are determined using the config file located at config/<league name>/teams.cfg relative the the GameController.jar. To add teams to it, lines composed of <team number>=<team name> may be added to this file. Optionally, the primary and secondary team colors may be added behind the team name, separated by commas.

Team logos lie in the same directory as the config file with the corresponding team number as the file name.

3. GameStateVisualizer

As of the 2017 RoboCup competitions, the GameStateVisualizer has been replaced by the GameStateVisualizer mode of the TeamCommunicationMonitor.

To start it, run

java -jar TeamCommunicationMonitor.jar --gsv.

4. TeamCommunicationMonitor

The TeamCommunicationMonitor (TCM) is a tool for visualizing the data communicated by robots during SPL games.

It serves two main purposes:

  1. offering diagnostic data such as which robots are communicating on which team ports and whether the data that is sent by these conforms to the SPLStandardMessage, which is the standard communication protocol in the SPL
  2. visualizing the data that was sent via SPLStandardMessages in both textual and graphical form.

For more info see TCM.

5. libgamectrl (SPL)

libgamectrl automatically provides the GameController packets in ALMemory. It also implements the return channel of the GameController. It handles the buttons and LEDs according to the rules (with a few additions).

Installation

Put the file libgamectrl.so somewhere on your NAO and add the library to your file "autoload.ini" so that NAOqi can find it. The binary provided was built for NAOqi 2.1.

It is also possible to build the library from source using Aldebaran's qibuild framework. The qiproject.xml and CMakeList.txt have been placed in libgamectrl's source folder. Just follow the instructions of the README file there.

Usage

In your NAOqi module, execute the following code at the beginning (only once):

AL::ALMemoryProxy *memory = new AL::ALMemoryProxy(pBroker);
memory->insertData("GameCtrl/teamNumber", <your team number>);
memory->insertData("GameCtrl/teamColour", <your default team color>);
memory->insertData("GameCtrl/playerNumber", <your robot's player number>);

The team number must be non-zero. Setting the team number will reset libgamectrl (i.e. go back to the initial state). libgamectrl will also set "GameCtrl/teamNumber" back to zero, so it will recognize the next time your application is started.

Setting the default team color can actually be omitted now. In that case, it is black, i.e. the corresponding foot LED is switched off.

You can receive the current GameController packet with:

RoboCupGameControlData gameCtrlData; // should probably zero it the first time it is used
AL::ALValue value = memory->getData("GameCtrl/RoboCupGameControlData");
if (value.isBinary() && value.getSize() == sizeof(RoboCupGameControlData))
    memcpy(&gameCtrlData, value, sizeof(RoboCupGameControlData));

Deviations from the Rules

The first time the chest button is pressed it is ignored, because many teams will use it to let the robot get up.

In the Initial state, it is also possible to switch between "normal", "penalty taker" (green LED), and "penalty goalkeeper" (yellow LED) by pressing the right foot bumper. The state is shown by the right foot LED, and only in the Initial state. An active GameController will overwrite these settings.

6. Coach Messages

The coach broadcasts messages as defined in SPLCoachMessage.h to the UDP port SPL_COACH_MESSAGE_PORT through the wireless network. Players are not permitted to listen to this port. The GameController will integrate the coach messages into the RoboCupGameControlData packet and forward them to the players according to the SPL rules. Since coach messages must be human readable, it is assumed that they are a zero-terminated string and all data after the first zero character is zeroed, too.

The GameStateVisualizer also displays the coach messages.

Please note that the field "team" now contains the team number, not the color.

7. Protocol

For questions regarding the protocol please check the Wiki.

8. Known Issues

There are still a number of issues left:

  • The qibuild file for libgamectrl is untested.

  • The alignment of button labels is bad if the buttons are small.

  • The GameController is not displaying properly on Windows-High-Res-Systems.

gamecontroller's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

gamecontroller's Issues

Manually penalized

Hello,
In the game controller return data, the robot can "manually penalize" itself
I don't really understand what does it means regarding the rules, is it a way that the robot can signal its own malfunctioning for instance?

Pushing used SPL code

The physical contact penalty used the code from the SPL and therefore had the problem of giving 45 instead of 30 seconds penalty.

Free Kick

The goal is to introduce Free Kicks into the Game Controller.

In order to to that - the Game controller needs two new buttons for each team:

The following should happen when the button is clicked:

  • The game enters into a secondary state: FREE_KICK_PREP
  • The game pauses and a timer runs down to indicate when the 15 seconds are over
  • After that the according penalties (removing robots can be dealt with)
  • When pressing the button again the game goes back to normal
    (There is the open question here whether a second sub state should be active for the 10 seconds or if the players need to realize themselves that there is the logical transition back from FREE_KICK_PREP)

Drop-In: Customizable number of players

We should show up to six players for each team as in the regular games. It should be possible to mark either one or two of them as (sub), meaning they are not active in the game. Currently all five are always active, even if only five players participate.

Check if penalty is removed too quickly

I'm not sure about this one, but today it seemed like the robots got the information that their penalty was removed already when the 30 seconds were finished counting down without the necessity for the GameController assistant to manually "free" the robot by clicking on it again. That shouldn't be the case - the robot should only get the signal after the button was pressed and is not blinking yellow anymore. This might not actually be the case and only observed by mistake, but please just confirm that this is not the case.

Timeout does not count down

If teams or the referee take a timeout, the game time should stop (which works), but the timeout time should count down. However, the counter of the timeout does not go down.

Changes in free-kick secondary state order

Currently, the GameController goes to "prepare free kick" first and counts down the 15 seconds and then goes to "freeze free kick". This is the wrong order! The following changes should therefore be made without changing the protocol (for direct, indirect free-kick and penalty kick):

  1. In the UI, have the "freeze free-kick" first (without secondary game time) and then "prepare free kick"
  2. Change the labels on the UI - instead of "freeze" have just "Free Kick" / "Indirect Free Kick" / "Penalty Kick"
  3. Once you click on the button - instead of "prepare" have "Free Kick Ready" (the others accordingly)
  4. Execute Free Kick stays as is.
  5. Please change the description in the protocol and wiki as well, but do NOT change the actual bits that are send in each case.

Regular games: Opening Dialogue

Since a game can never start with both teams having the same color, it would be convenient if they are by default one blue and one read. Right now they are both blue by default.

2 yellow card -> 1 red card

If a second yellow card is added for a robot, a red card should automatically be assigned as well. Right now, this has to be done manually.

Kick-Off is switched after Timeout

Currently the kick-off switches if the team has taken a timeout. Instead, it should remain the same as it was before. This was a bug in the previous version already.

Make clear which team is on which side

Currently in the re factored version it is not entirely clear which team is which in the GameController during the game. There should be some beauty added again.

Drop-In: Opening Dialogue

Drop-In games cannot be knock-out games. So the checkbox should be removed. Since there is only one half time, automated color switching doesn't apply either. Checkbox can be removed as well.

Mercy rule

It appear that the mercy rule (game stopped when score difference is more than 10) is not present anymore in the official 2017 rules for kid size, however it is still implemented in the official game controller

Robot Penalty Cards

The robot should get the information how many yellow and red cards it has.

Drop-In: Exception thrown

Exception in thread "main" java.lang.StackOverflowError at controller.ui.ui.HL_DropIn.dispose(Unknown Source)

Unfortunately not easy to reproduce, but thrown at some point and then very often in a row. Doesn't seem to affect the functionality, only printed in the console.

Align Adult League Screen

As a referee the games in the Adult League will be 'normal' games in a similar fashion as in the
Kid and Teen Size League.

  • Make the adult siye screen a normal game screen like the other two sizes

Original Email Text:
No dribbel and kick competiciton anymore, they should get the same interface as Kid and Teen, but with only one active player at a time

Add a team logo

It is easier to differentiate the teams if the logos would be shown next to the team names as in the old GameController.

GameController doesn't end correctly in Windows

We are running the GameController in Windows. When you close the GameController, you can't open it again because it says there is another instance already running. You have to manually end the javaw process in the Task Manager before you can start it again. It looks like when you close it by clicking on the "x" on the top right it doesn't shut down the process correctly. Would be excellent if that could be fixed.

Refereee Timeout

The SPL features a referee timeout that can be activated for humanoid league as well.

Allow to start GameController from within Eclipse

May be I did something wrong, but for me it did not work to clone the game controller, import it in eclipse and run it. It is not able to find the resources like config/spl/teams.cfg

The typical cure for this is to add the resources folder as source folder in eclipse. This has two problems here:

  1. The dropins folder will then show compilation errors. Not sure if dropins is really properly located in the resources folder since it contains source files.

  2. The files are still not found. To be able to have both, finding resources in source and jar, one should use getResourceAsStream() method. This would have to be changed at least at:
    TeamsLoader.java (71)
    InputStream stream = getClass().getClassLoader().getResourceAsStream(PATH+dir+"/"+CONFIG); Scanner s = new Scanner(stream);
    Teams.java (83)
    InputStream inStream = getClass().getClassLoader().getResourceAsStream(PATH+dir+"/"+CONFIG); // InputStream inStream = new FileInputStream(PATH+dir+"/"+CONFIG);
    Teams.java (142)
    Helper dummy = new Helper(); InputStream inStream = dummy.getClass().getClassLoader().getResourceAsStream(PATH+Rules.league.leagueDirectory+"/"+CONFIG);

With 2 changed the files are still not found when running as jar. The build process in build.xml would have to be changed to include the config folder in the classpath. I stopped here.

3 State Phase on Penalty Kick

As in the Direct and Indirect Free Kicks also the penalty kick needs a 3-phase protocol with the secondary game state byte being set.

Drop-In game: Counting of individual points

If a goal is scored by team A, only robots from team A who are not suffering from a penalty and are not in service should receive a point. Currently all of them receive a point.

Last action in time-line is shown in reverse order

In previous GameController versions, the last action was always displayed on the right most end of the screen. Now it's the left most end of it. Would be good to have that as in previous years again.

Compilation problem in Helper

When cloning we get a compilation error in eclipse in class Helper.java on line

import org.junit.Rule;

The import is not needed and can be removed.

Secondary time in Free Kick state 1 (old "freeze") changes randomly

It was reported that the secondary clock when you first click on "free kick" (which was the old "freeze state") keeps changing randomly and takes crazy values. This is not good, because even though it is not important in this game state, there might be teams listening to it and getting confused still. So if there is a fix for this (even a hot fix that just sets it to 0 hard coded) would be very helpful.

Team names are not swapped for half time

During half time, the teams switch to the other half of the field. In the GameController, only the red and blue labels on the robot buttons switch, but not the team names and colors on the top.

Free Kick timeout

Hello,
From the official rules:

the ball is in play when it is kicked directly out of the penalty area (new): or 10 seconds after the referee gave the signal

If we want this rule to be applied, I think we need the 10 seconds counter to be visible in the Game Controller, and maybe also broadcasted

Add a third state for free-kicks

Currently the free-kicks have two states - "Prepare free kick" and "Execute free kick". We need a third state before the current first one which is just called "Free kick". This has to be added in the UI and send to the robots. This issue is rather critical.

Disable free-kicks in penalty shoot-out

In penalty-shoot out mode, it is not possible to get free-kicks. In order to not make mistakes when operating the GameController, this option should be disabled.

Dynamic CoachMessage Size

Check if it is a good design decision to add a field coachMessageLength that expresses how long the
following coachMessage is.

Penalty Kick

The goal is to introduce Penalty Kicks into the Game Controller.

In order to to that - the Game controller needs two new buttons for each team:

The following should happen when the button is clicked:

  • The game enters into a secondary state: PENALTY_KICK_PREP
  • The game pauses and a timer runs down to indicate when the 15 seconds are over
  • After that the according penalties (removing robots can be dealt with)
  • When pressing the button again the game goes back to normal

Drop In Games with Robot Points

In the start interface, allow to select drop-in as a game type.

The interface then looks the same as for regular games, except that it has up to five regular players for Kid and up to four regular players for TeenSize, no supplement players.

Only one ten minute half exist, no penalty shoot-outs

Behind each player’s number on the button is shown the total point count for this game. This is automatically calculated like this:

-- If a goal is scored, all robots from the team scoring a goal who are active (not suffering from a removal penalty, are in pick-up or service) automatically receive one point

-- All robots from the opposite team receive -1 point

-- For each robot, there is a plus and minus sign allowing to manually add or remove points in case they were awarded points by mistake (for example, they just got a removal penalty when the goal was scored, so the removal penalty was not pressed in the game controller yet)

-- The robot scoring the goal gets one point awarded manually by the assistant referee (with the plus button at the respective robot)

Dynamic RobotInfo Size

Check if it is a good design decision to add a field numRobots in the TeamInfo that specifies how many robots the team has. Additionally one can add a field isFirstRobotCoach that is true or false whether the
first robot in the array is the coach.

What Benefit: Smaller package size

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.