# Cyclus Measurements cyclus <- read.csv("cyclusintervals.csv") # Mechanisches Gangverhältnis gear_ratio <- cyclus$ErgoFrontGear[1]/cyclus$ErgoBackGear[1] # SRM Measurements # 0: Cadence # 1: Torque srm <- read.csv("srmintervals.csv") srm_cadence <- plyr::rename(subset(srm, Type==0, select=c("Time", "Value")), c("Value"="Cadence")) srm_torque <- plyr::rename(subset(srm, Type==1, select=c("Time", "Value")), c("Value"="Torque")) # Arduino Measurements # 0: Photo Sensor (back, 25 teeth, Value: time difference) # 1: Reed Switch (front, Value: time difference) # 2: Reed Switch (back, Value: time difference) arduino <- read.csv("arduinointervals.csv") arduino_photoBack <- plyr::rename(subset(arduino, Type==0, select=c("Time", "Value")), c("Value"="TimeDiff")) arduino_photoBack$Cadence <- 1/25 / arduino_photoBack$TimeDiff / gear_ratio * 60 arduino_reedFront <- plyr::rename(subset(arduino, Type==1, select=c("Time", "Value")), c("Value"="TimeDiff")) arduino_reedFront$Cadence <- 1 / arduino_reedFront$TimeDiff * 60 arduino_reedBack <- plyr::rename(subset(arduino, Type==2, select=c("Time", "Value")), c("Value"="TimeDiff")) arduino_reedBack$Cadence <- 1 / arduino_reedBack$TimeDiff / gear_ratio * 60 # Plot Cadence library(ggplot2) source("defines.R") # visible window xmin <- 195 xmax <- 205 ymin <- 65 ymax <- 76 ggplot() + geom_line(data=arduino_reedFront, aes(x=Time, y=Cadence, color="Reed Front"), size = 2) + geom_line(data=arduino_reedBack, aes(x=Time, y=Cadence, color="Reed Back"), size = 2) + geom_line(data=arduino_photoBack, aes(x=Time, y=Cadence, color="Photo Sensor"), size = 2) + geom_line(data=cyclus, aes(x=Time, y=Cadence, color="Cyclus"), size = 2) + geom_line(data=srm_cadence, aes(x=Time, y=Cadence, color="SRM"), size = 2) + scale_colour_manual(name = "Sensors", values = c("Cyclus" = "blue", "SRM"="black", "Photo Sensor"="red", "Reed Front"="green", "Reed Back"="yellow"), labels = c("Cyclus"=paste0("Cyclus2 (mean=",round(mean(cyclus$Cadence),2),")"), "Photo Sensor"=paste0("Photo Sensor (mean=",round(mean(arduino_photoBack$Cadence),2),")"), "SRM"=paste0("SRM (mean=",round(mean(srm_cadence$Cadence),2),")"), "Reed Front"=paste0("Reed Front (mean=",round(mean(arduino_reedFront$Cadence),2),")"), "Reed Back"=paste0("Reed Back (mean=",round(mean(arduino_reedBack$Cadence),2),")"))) + plot_style + # xlim(xmin,xmax) + ylim(ymin,ymax) + # "zoom" coord_cartesian(xlim = c(xmin, xmax), ylim = c(ymin, ymax)) + labs(title = "Cadence")