Soccer Example

Last updated for release 1.9.4


This example introduces RBB concepts using an example database of soccer play. The data is from simulated games from the Robocup 2011 finals.

To follow along, download and unzip the RBB and optional jarfiles. Also download and unzip the Robocup Finals RBB. This example will assume the example RBB (robocup2011finals.h2.db) and the jar files are in the current directory (so that short relative pathnames can be used).

Launch the example:

cd <rbbjars>; java -jar rbbexamples-1.9.4.jar jdbc:h2:file:robocup2011finals
Select the "Show" dropbox and select one of the games:
Move the Time scrollbar at the bottom and the players and ball will appear:

Press Play and the replay will begin.

The soccer example introduces several RBB concepts:

A tagset is a list of name=value pairs, e.g. game=HELIOS2011-vs-MarliK,type=position. RBB applications typically assign several tags to each piece of information, which allows the data to be grouped and retrieved flexibly. To see the tags for the soccer ball or a player, right-click near it and select the Tags submenu.
RBB Events represent discrete events. In RBB the concept of an Events is very generic - for example, the existence of the soccer ball for a period of time is an Event. Each Event consists of:
Many Events have associated information - for example, the position of the soccer ball at each moment. A position over time is an example of an RBB Timeseries, which is a time-varying multi-dimensional value that is observed at discrete times. A Timeseries is a type of Event (but not vice-versa).
In addition to time series data, RBB Events may have attachments of any type, and a few types (e.g. images) are specifically supported.

Selecting Data with Tagsets

While Play is running, select the Show drop-down and choose id=Ball. (You can also type this tagset, or any other, into the Show bar). You will see no players, but up to 3 balls moving around. This is because the database contains 3 games, and no game=<name> tag was specified, so any tagset including id=Ball matches.

Drawing Timeseries Data

While Play is still running and leaving Show set to id=Ball, from the menu select "Settings / Specify Tags for Hand-Drawn Timeseries..." and enter id=Ball. Then click the pencil icon in the toolbar. Click and drag on the soccer field, and a new Ball Timeseries will be created and follow your mouse. Move time back using the scrollbar at the bottom of the window, and you will notice the new Ball you created is now in the RBB (even if you quit and re-start the program). You can delete it from the context menu that appears if you right-click near it.

Start / End Times

While Play is running you will notice the balls disappear occasionally. This happens when no position is available, for example because the ball was out of bounds. Each continuous period for which the position is available is a separate Event with a unique ID, and the separate Events representing the same object are linked by having been assigned the same tagset.

The following command will show when the ball was in play for each game in the database.

java -jar rbb-1.9.4.jar ui timeline -multiTimeline id=Ball,game -endTime 600000 jdbc:h2:tcp:localhost/robocup2011finals

Example Queries

Determine When All of Several Data Streams Are Available

Instead of assuming information is always available, most operations in RBB start with finding the periods of time during which the necessary data were reported. For on-line applications, processing is triggered when this condition is met.

The following get command find time periods when all 3 balls in the database were active, and output them in a text file:

java -jar rbb-1.9.4.jar get -tagsOnly jdbc:h2:tcp:localhost/robocup2011finals id=Ball id=Ball id=Ball > all.rbb
  • Note: Without the -tagsonly option, get would also output the Timeseries data (the positions of the balls).
  • Note: By opening all.rbb in a text editor, you can see that each line is an Event.

    Next put the new events into the rbb:

    java -jar rbb-1.9.4.jar put -setTags game=all jdbc:h2:tcp:localhost/robocup2011finals < all.rbb

    Re-running the timeline command above shows the time periods when all 3 balls were active (notice the new all line):

    Deleting Events from an RBB

    You can remove these newly created events, because they are the only events with the tag game=all. In the Draw program, use the menu: "Edit / Select / By Tags..." and enter game=all. Then use "Edit / Delete..." or press the Delete icon in the toolbar. Alternately, use the command line:
    java -jar rbb-1.9.4.jar delete jdbc:h2:tcp:localhost/robocup2011finals game=all

    Ball Possessions

    Here is a command to create an Event for each ball possession (defined as a distance of <= 2 from any player to the ball).
    It uses the ml package getFeatures command, in which sets of Timeseries can be selected, named, and passed through a sequential processing chain:

    java -jar rbb-1.9.4.jar ml getFeatures -rbb jdbc:h2:tcp://localhost/robocup2011finals \
      -input ballpos type=position,id=Ball      `: get the ball position and label it 'ballpos'  `\
      -input playerpos type=position,game=      `: get any other co-occurring position from the same game the ball is in, and label it 'playerpos'  `\
      -DistanceFE distance:ballpos:playerpos:SCALAR  `: calculate the distance from the ball to the player and label it 'distance'  `\
      -BetweenFE distance:0:2                   `: stop here unless the distance is between 0 and 2  `\
      -CreateEventFE *=playerpos.*,type=possession:true:true  `: create an event in the RBB, inheriting tags from playerpos but overwriting 'type=position' with 'type=possession' `
    Here is the same command in a single line without comments for easier copy/paste and Windows compatibility:

    java -jar rbb-1.9.4.jar ml getFeatures -rbb jdbc:h2:tcp://localhost/robocup2011finals -input ballpos type=position,id=Ball -input playerpos type=position,game= -DistanceFE distance:ballpos:playerpos:SCALAR -BetweenFE distance:0:2 -CreateEventFE *=playerpos.*,type=possession:true:true

    To find all the ball possessions by player 7 on the HELIOS team in their game against Marlik:

    java -jar rbb-1.9.4.jar get jdbc:h2:tcp:localhost/robocup2011finals type=possession,shirtNum=7,team=HELIOS2011,game=HELIOS2011-vs-MarliK
    The output:


    This example builds on the previous one - it looks for patterns in the sequence of ball possessions. The command findEventSequences retrieves a time-ordered set of Events, normally on the basis of shared tag values. It can also create a string representing each sequence and select only those matching a regular expression.

    A "give and go" is a play in which the player with the ball gets around a defender by passing to a team-mate who then returns the ball (hopefully after the defender is left behind). In this example it is defined as two possession events by the same player with one intervening possession by a team-mate:

    java -jar rbb-1.9.4.jar findEventSequences -filter type=possession -group game -regextag id '(.)(\d)\1(?!\2).\1\2' -summarize type=give-and-go,parentEvent -put jdbc:h2:tcp:localhost/robocup2011finals

    Use the timeline to display all give-and-go plays by one team in one game:

    java -jar rbb-1.9.4.jar ui timeline -multiTimeline type=give-and-go,game=HELIOS2011-vs-MarliK,team=HELIOS2011,id -endTime 6000000 jdbc:h2:tcp:localhost/robocup2011finals

    Each give-and-go event is shown on the timeline of two different players because each one is a sequence of 3 possession events by two players. To see the give-and-go plays in action using the Draw program, select game=HELIOS2011-vs-MarliK,type=position from the Show drop-down box. As you use the playback controls in the Draw program (the Play button and time scrollbar along the bottom edge), the orange current-time vertical bar in the Timeline tracks the time. The players involved in the give-and-go are the names of the rows in the Timeline.