Accessing GPS- and LPS-based Velocity and Acceleration Efforts

How to access velocity and acceleration efforts.

Table of Contents


Introduction

Perhaps you are interested in learning more about the acceleration and velocity efforts made by athletes. For more information about these efforts, see the following link.

Validate User Credentials

If enabled on your account, you can also generate an API token string in OpenField Cloud. If you would like this feature enabled on your OpenField account, please speak with your Catapult Sports Customer Success Representative.

For this example, we will extract all Rugby Union IMA events from a game in our Men’s Rugby Union demo account. First we have to get the token corresponding to this account.

All data presented along with account credentials have been anonymized, removing and changing identifiable characteristics that can be traced back to an account, team, or athlete. Typical token strings created in OpenField Cloud will be much longer.


# first, load a few packages
library(catapultR)
library(tidyverse)
library(lubridate)

token <- ofCloudCreateToken(sToken = "8SyAJZonGYUH5adDgINl1re7WkOPXhB0EtbVzcMp",  sRegion = "America")

Getting Athletes and Activities

Now, we can see which athletes and activities are associated with this account. Typically, you will want to identify specific athletes or activities for which you want more information. Once you know when these Activities occurred and the Device IDs that you’re interested in, you can access IMA Event data, Generation 2 Effort data, 10 Hz Sensor Data, or even 100 Hz high frequency data if the necessary modules are enabled on the account.

In order to maintain anonymity, no identifiable data will be shared for the following examples.

Athletes:


athletes <- ofCloudGetAthletes(token)
# glimpse(athletes)
glimpse(athletes)

Rows: 297
Columns: 30
$ id                         <fct> 7pkjvzc2-pf7x-si7l-jldg-axb2lf7vw~
$ first_name                 <chr> "Orin", "Alana", "Nadheera", "Dus~
$ last_name                  <chr> "Evans", "Littlejohn", "Watts", "~
$ jersey                     <chr> "123", "DM5", "JC", "EO1", "EE9",~
$ nickname                   <chr> "The Answer", "The Accountant", "~
$ height                     <dbl> 173.123156545, 176.824081411, 176~
$ weight                     <dbl> 71.2977938251, 64.8735286409, 74.~
$ date_of_birth              <dbl> 706326895, 965711438, 816298330, ~
$ velocity_max               <dbl> 10.00, 10.00, 9.50, 9.50, 10.00, ~
$ acceleration_max           <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10~
$ heart_rate_max             <int> 0, 0, 200, 196, 200, 199, 0, 200,~
$ player_load_max            <int> 0, 0, 500, 0, 500, 0, 0, 0, 500, ~
$ image                      <chr> "", "", "", "", "", "", "", "", "~
$ icon                       <chr> "circle", "circle", "circle", "tr~
$ stroke_colour              <chr> "#030303", "#030303", "#030303", ~
$ fill_colour                <chr> "#ff0000", "#ff0000", "#ff0000", ~
$ trail_colour_start         <chr> "", "", "", "", "", "", "", "", "~
$ trail_colour_end           <chr> "", "", "", "", "", "", "", "", "~
$ is_synced                  <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ~
$ is_deleted                 <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ~
$ created_at                 <chr> "2015-06-22 10:04:02", "2015-07-0~
$ modified_at                <chr> "2015-07-31 08:38:44", "2016-09-1~
$ date_of_birth_date         <chr> "1970-01-01", "1970-01-01", "1970~
$ tag_list                   <list> <>, <>, <>, <>, <>, <>, <>, <>, ~
$ tags                       <list> [<data.frame[0 x 0]>], [<data.fr~
$ current_team_id            <chr> "49tkpvsr-z4hc-dp5q-jlgk-9xqit3dz~
$ max_player_load_per_minute <int> 12, 12, 15, 15, 15, 15, 12, 12, 1~
$ position                   <chr> "SH", "S", "C", "FB", "SH", "S", ~
$ position_id                <chr> "b93eae54-7071-11e4-afbc-0afe0c90~
$ position_name              <chr> "Scrum-Half", "Second Row", "Cent~


Activities:


# Get data for each activity (Demo Account) ----------------------------------------------
to <- as.integer(as.POSIXct(as.Date("2020-02-02")))
from <- as.integer(as.POSIXct(as.Date("2019-10-02"))) # 20 weeks
activities <- ofCloudGetActivities(token, from = from, to = to)
glimpse(activities)
nrow(activities)

Rows: 180
Columns: 19
$ id             <chr> "pkjv7c2u-pf7x-si7l-jldg-axb2lf7vw9c8", "pdvz~
$ name           <chr> "Rehab", "Training", "Training", "Rehab", "Ma~
$ start_time     <dbl> 1584697281, 1584611296, 1584522199, 158447928~
$ end_time       <dbl> 1584699565, 1584612900, 1584524248, 158448302~
$ modified_at    <chr> "2020-01-31 17:15:48", "2020-01-31 17:15:48",~
$ game_id        <chr> "pkjv7c2u-pf7x-si7l-jldg-axb2lf7vw9c8", "pdvz~
$ owner_id       <chr> "efcb4474-22a6-41fc-95ce-8389d6e8fd36", "efcb~
$ owner          <df[,10]> <data.frame[23 x 10]>
$ periods        <list> [<data.frame[1 x 4]>], [<data.frame[1 x 4~
$ tags           <list> <"Friday", "Compressed", "GPS", "Compressed"~
$ tag_list       <list> [<data.frame[4 x 5]>], [<data.frame[2 x 5]>]~
$ athlete_count  <int> 1, 1, 1, 1, 1, 1, 27, 1, 2, 2, 7, 34, 1, 2, ~
$ period_count   <int> 1, 1, 1, 1, 1, 1, 46, 1, 2, 1, 6, 7, 1, 1, 1,~
$ venue_name     <chr> "Training Pitch 2", "Training Pitch 3", "Trai~
$ venue_width    <int> 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 7~
$ venue_length   <int> 105, 105, 105, 105, 105, 105, 105, 105, 105, ~
$ venue_rotation <int> 169, 169, 169, 169, 169, 169, 169, 169, 169, ~
$ venue_lat      <dbl> 71.7755572, 71.7755572, 71.7755572, 71.775557~
$ venue_lng      <dbl> -19.3345743, -19.3345743, -19.3345743, -19.33~

[1] 180

The column names for the activities dataframe are printed above. We can see that each row contains information for a single activity. Between October 2, 2019 and February 2, 2020, there were 180 activities associated with the account.


We can use the activities data frame above to identify an activity or period from which we would like to extract the velocity or acceleration efforts We also need the athlete_id for each athlete, and the corresponding name of each athlete will also be helpful. For this example, I will just select a random activity. To get the athlete_ids and athlete_names for this activity, we can use the function ofCloudGetAthleteDevices().

Get Device Info for the Activity


# We want athlete name, athlete_id, and device_id
# we can match the name using the device id from the info returned by ofCloudGetAthleteDevices()
device_info <- ofCloudGetAthleteDevicesInActivity(
  token, 
  activity_id = activities$id[27])

glimpse(device_info)

Rows: 32
Columns: 12
$ device_id          <int> 3904, 1083, 8903, 8558, 7337, 9171, 6702,~
$ athlete_id         <chr> "dnc3ystx-mvfe-d2ey-cx14-25i14qtmaglo", "~
$ athlete_name       <chr> "Dao Ibarra", "Dillon Lovato", "Cindy Kea~
$ athlete_first_name <chr> "Dao", "Dillon", "Cindy", "Joshua", "Ange~
$ athlete_last_name  <chr> "Ibarra", "Lovato", "Keasling", "Tree", "~
$ mapping_start_time <dbl> 1581406289, 1581406180, 1578641056, 15829~
$ mapping_end_time   <dbl> 1583481593, 1641898572, 1583416017, 15832~
$ is_current_mapping <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,~
$ jersey             <chr> "CH5", "AC8", "KP2", "DT2", "SM4", "TL3",~
$ team_id            <chr> "iuctbanw-twg7-rqwc-ijzc-icbfwuv5z89p", "~
$ team_name          <chr> "Ravenclaw", "Ravenclaw", "Ravenclaw", "R~
$ player_id          <chr> "", "", "", "", "", "", "", "", "", "", "~

The column names for device_info have been printed above. The device_id column can be used to join athlete names to the event data.


Accessing GPS or LPS-Based Velocity and Acceleration Efforts

If Gen2 Efforts are enabled for the account, you can extract them with the function ofCloudGetActivityEfforts(). You must specify a specific athlete and activity (or period if using ofCloudGetPeriodEfforts()), and you can also isolate your selections to a specific time period using the from and to arguments. You can restrict the query to specific bands using the bands argument. This may be helpful if you only want higher band velocity efforts, or if you’d like to look at decelerations only. See the function help for more information.

The velocityOrAcceleration argument should be set to TRUE for velocity efforts and FALSE for acceleration efforts.

Velocity:


# velocity efforts
vel_efforts <- ofCloudGetActivityEfforts(
           token, 
           athlete_id = device_info$athlete_id[1], 
           activity_id = activities$id[27], 
           velocityOrAcceleration = TRUE, 
           bands = 1:8,
           stream_type = "gps")

rmarkdown::paged_table(vel_efforts)

Acceleration:


# acceleration efforts
accel_efforts <- ofCloudGetActivityEfforts(
             token, 
             athlete_id = device_info$athlete_id[1], 
             activity_id = activities$id[27], 
             velocityOrAcceleration = FALSE, 
             bands = -3:3,
             stream_type = "gps")

rmarkdown::paged_table(accel_efforts)

Conclusion

You have now accessed some velocity and acceleration effort data for a single athlete. You can extend the logic for multiple athletes and multiple activities if you wish. For other types of data requests, proceed to another section of the Quick Start Tutorial.

Contact: (email) | #ask_catapultR (Slack)