Closed sBrook3 closed 5 months ago
Can you share a file? In my experience FIT files contain quite a bit of undocumented data, and I choose to throw away anything that I don't know what it is. I think the most likely thing is that torque is somehow being discarded internally, which I should be able to fix with an example file to debug.
new_project.fit.zip It wouldn't let me upload a .fit directly so hopefully that will work.
thanks
Thanks for that file. Can I ask what you use to convert to CSV? I've tried a few tools like Garmin's FitCSVTool
and the perl fitdump
tool, but there doesn't seem to be any mention of torque in the files those tools create.
I'm using this: https://bluecattechnical.shinyapps.io/EnDuRA/ you have to create a login but its free.
Thanks for the link. My guess is that they are calculating the torque value using the power and rpm data that are already in the file using the following equation:
Torque (nM) = Power (W) ∗ 60 / (2 ∗ pi ∗ RPM)
Here's some code that get's a plot similar to that produced by EnDuRA:
library(FITfileR)
library(dplyr)
library(ggplot2)
library(lubridate)
library(hms)
## download and extract the example file
destfile = tempfile(fileext = ".zip")
url = "https://github.com/grimbough/FITfileR/files/15011268/new_project.fit.zip"
dl = download.file(url = url, destfile = destfile)
example_file = unzip(destfile, exdir = tempdir())
## read and extract the records
fitFile <- readFitFile(example_file[1])
laps <- laps(fitFile) %>%
bind_rows() %>%
arrange(timestamp)
lap_intervals <- interval(laps$start_time, laps$timestamp)
records <- records(fitFile) %>%
bind_rows()%>%
arrange(timestamp)
records <- mutate(records,
## find the time elapsed since the
elapsed_time = as_hms(timestamp - min(timestamp)),
## calculate the torque at each second
torque = (power * 60) / (2 * pi * cadence),
## assign each record to a lap - this is a bit slow
lap = as.factor(
sapply(timestamp, FUN = \(x) which(x %within% lap_intervals)[1])
)
)
## create a plot
ggplot(records, aes(x = elapsed_time, y = torque)) +
geom_line(aes(color = lap)) +
scale_x_time() +
theme_minimal() +
ylim(0,100)
Thanks so much for digging into that. I'd completely assumed the torque would be coming directly from the power meter. I've tried it on a few rides and it seems to work.
Thanks!
Hello,
Thankyou for building and sharing this, its been very useful. I think probably the issue I'm having is lacking experience with R, but I've tried reading a number of different fit files (from different types of bike computer), and in all of them I'm seeing a much reduced range of variables than I can see when converting them to csv first or viewing through eg. training peaks. I can do without most of it but unfortunately torque is missing and I need that for what I'm trying to do.
Here's what I'm doing:
which gives me
and the session Info:
Thanks again, and any suggestions you can offer would be much appreciated! Sarah