imu: Create an IMU Object

View source: R/imu.r

imuR Documentation

Create an IMU Object

Description

Builds an IMU object that provides the program with gyroscope, accelerometer, and axis information per column in the dataset.

Usage

imu(
  data,
  gyros = NULL,
  accels = NULL,
  axis = NULL,
  freq = NULL,
  unit = NULL,
  name = NULL
)

Arguments

data

A vector which contains data, or a matrix or data.frame which contains the data in each column.

gyros

A vector that contains the index of columns where gyroscope data (such as Gyro. X, Gyro. Y and Gyro. Z) is placed.

accels

A vector that contains the index of columns where accelerometer data (such as Accel. X, Accel. Y and Accel. Z) is placed.

axis

A vector that indicates the axises, such as 'X', 'Y', 'Z'. Please supply the axises for gyroscope data before that for accelerometer data, if gyroscope data exists.

freq

An integer that provides the frequency for the data.

unit

A string that contains the unit expression of the frequency. Default value is NULL.

name

A string that provides an identifier to the data. Default value is NULL.

Details

data can be a numeric vector, matrix or data frame.

gyros and accels cannot be NULL at the same time, but it will be fine if one of them is NULL. In the new implementation, the length of gyros and accels do not need to be equal.

In axis, duplicate elements are not alowed for each sensor. In the new implementation, please specify the axis for each column of data. axis will be automatically generated if there are less than or equal to 3 axises for each sensor.

Value

An imu object in the following attributes:

sensor

A vector that indicates whether data contains gyroscope sensor, accelerometer sensor, or both.

num.sensor

A vector that indicates how many columns of data are for gyroscope sensor and accelerometer sensor.

axis

Axis value such as 'X', 'Y', 'Z'.

freq

Observations per second.

unit

String representation of the unit.

name

Name of the dataset.

Author(s)

James Balamuta and Wenchao Yang

Examples

## Not run: 
if(!require("imudata")){
   install_imudata()
   library("imudata")
}

data(imu6)

# Example 1 - Only gyros
test1 = imu(imu6, gyros = 1:3, axis = c('X', 'Y', 'Z'), freq = 100)
df1 = wvar.imu(test1)
plot(df1)

# Example 2 - One gyro and one accelerometer
test2 = imu(imu6, gyros = 1, accels = 4, freq = 100)
df2 = wvar.imu(test2)
plot(df2)

# Example 3 - 3 gyros and 3 accelerometers
test3 = imu(imu6, gyros = 1:3, accels = 4:6, axis = 
                       c('X', 'Y', 'Z', 'X', 'Y', 'Z'), freq = 100)
df3 = wvar.imu(test3)
plot(df3)

# Example 4 - Custom axis
test4 = imu(imu6, gyros = 1:2, accels = 4:6, axis = 
                       c('X', 'Y', 'X', 'Y', 'Z'), freq = 100)
df4 = wvar.imu(test4)
plot(df4)

## End(Not run)

SMAC-Group/simts documentation built on Sept. 4, 2023, 5:25 a.m.