12 Generating a trajr
Route From the Telemetry Data
With a large number of points available, we can cast the dataset directly to a trajr
route.
The trajr
R package was originally developed for use analysing animal tracks, but it’s also really handy for analysing rally routes…
= function(telem_df_full){
telemetry_full_trajectory
= st_transform(telem_df_full,
utm_telem_full crs=utm_proj4_string) %>%
mutate(lat = st_coordinates(.)[,1],
lon = st_coordinates(.)[,2])
<- TrajFromCoords(utm_telem_full %>% select(lon, lat, utc),
trj xCol="lon", yCol="lat", timeCol="utc")
# We assume that the first location is the first location on the route
$distance = Mod(trj$displacement)
trj
$cum_dist = cumsum(trj$distance)
trj
$speed = telem_df_full$speed
trj$brk = telem_df_full$brk
trj$throttle = telem_df_full$throttle
trj$rpm = telem_df_full$rpm
trj
$lon = telem_df_full$lon
trj$lat = telem_df_full$lat
trj
$accx = telem_df_full$accx
trj$accy = telem_df_full$accy
trj
$driver = telem_df_full$driver
trj$stage = telem_df_full$stage
trj
trj }
The data includes:
lat
/lon
coordinates;- a sample timestamp;
speed
in km/h;throttle
andbrk
(brake) as percentage values;rpm
revs;accx
andaccy
acceleration forces.
If we plot these values against the distance into stage, generated from the location data and cross-referenced to the nearest point on the official stage route, we can generate an idealised basis for comparison between different drivers. However, given that drivers typically follow a very similar line, and hence complete a similar distance over the stage, using their actual distance into the route should provide a reasonable, if approximate, basis for comparison most of the time.
The trajr
route actually calculates a distance into the route assuming an origin based on the first point in the route.
="df_telemetrymergeddata_SS7_Evans.csv"
evans_fn= telemetry_full_trajectory(get_full_telem(file.path(path, evans_fn)))
trj_evans
="df_telemetrymergeddata_SS7_Ogier.csv"
ogier_fn= telemetry_full_trajectory(get_full_telem(file.path(path, ogier_fn)))
trj_ogier
="df_telemetrymergeddata_SS7_Breen.csv"
breen_fn= telemetry_full_trajectory(get_full_telem(file.path(path, breen_fn))) trj_breen