You opened this file on Sun, Sep 27 2015 and the time is currently 6:58:15 PM. ## Introduction to the IMU Sensor The IMU sensor containsa variety of sensors and is therefore crucial to having a robot… [continue]

Imported Libraries

Here are the libraries that were installed for this r program. The “data. table”" library helps us organize our data, and the “tidyr” and “dplyr” libaries help us process and analyze our data more efficiently.

library(data.table)
library(tidyr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## 
## The following objects are masked from 'package:data.table':
## 
##     between, last
## 
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Renaming Sensor Names and Date Formatting

fixSensorNames = function(zte, prefixName) {
  setnames(zte, "ACCELEROMETER X (m/s²)", paste0(prefixName, "Accel_x_mps2"))
  setnames(zte, "ACCELEROMETER Y (m/s²)", paste0(prefixName, "Accel_y_mps2"))
  setnames(zte, "ACCELEROMETER Z (m/s²)", paste0(prefixName, "Accel_z_mps2"))
  setnames(zte, "Time since start in ms ", paste0(prefixName, "TimeSinceStart_ms"))
  setnames(zte, "YYYY-MO-DD HH-MI-SS_SSS", paste0(prefixName, "DateTime"))
}


fixDateTime = function(zteDateTime) {
  op = options(digits.secs = 3)
  options(op)
  temp3 = gsub("[:](\\d\\d\\d)", ".\\1", zteDateTime)
  temp4 = strptime(temp3, "%Y-%m-%d %H:%M:%OS")
  return(as.numeric(temp4)*1000)
}

fixNames = function(oldnames, prefix) {
  # print(paste("length: ",length(oldnames)))
  for (i in 1:length(oldnames)) {
    oldnames[i] = paste0(prefix, oldnames[i], ".")
  }
  temp = gsub("/", "p", oldnames)
  temp = gsub("²", "2", temp)
  temp = gsub("°", "deg", temp)
  
  temp = gsub(": ", "", temp)
  temp = gsub("[(] ", "", temp)
  temp = gsub("μ", "u", temp)
  
  #  temp = gsub("(\\ )+$",".", temp)
  #  temp = gsub("[ ]", ".", temp)
  return(gsub("[(|)]","", temp))
}

Reading the Data from Excel

The r code here reads the excel data file and converrts the time to 100ms. The code here also gets the sensor data and the time ready to be joined into a data table for analysis.

setwd("C:/Users/Simon/Documents/R/Data")

rob2 = fread("RobotoC2_Sensor_record_20150703_112039_AndroSensor.csv")
fixSensorNames(rob2, "r2.")
rob2$r2.EpochTime_ms = fixDateTime(rob2$r2.DateTime)
rob2$epoch_100ms = round(rob2$r2.EpochTime_ms / 100) # convert epoch time to 100ms, prepare to join

rob3 = fread("RobotoC3_Sensor_record_20150703_112040_AndroSensor.csv")
fixSensorNames(rob3, "r3.")
rob3$r3.EpochTime_ms = fixDateTime(rob3$r3.DateTime)
rob3$epoch_100ms = round(rob3$r3.EpochTime_ms / 100) # convert epoch time to 100ms, prepare to join

IMU Data

Here, the epoch time and the sensor data are combined together into a data table called “x”.

x = full_join(rob2, rob3, by="epoch_100ms")
ra = data.table(x)
setorder(ra, epoch_100ms)

Before proceeeding to further analysis, we first decided to get a summary of the data in order to get a rough idea of what our data table is like.

summary(ra$r2.Accel_x_mps2)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 
## -19.4900  -7.1110  -2.0490  -2.8950   0.3304  18.7700        2

IMU Graph

Below is the graph of the IMU data. [describe data]

Conclusion

Based on… [write this]