Giter Site home page Giter Site logo

johannesfriedrich / hyperimu Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 2.0 1.02 MB

Reading sensor data from Android app HyperIMU

Home Page: https://play.google.com/store/apps/details?id=com.ianovir.hyper_imu&hl=de

License: GNU General Public License v3.0

R 100.00%
sensors android visualization

hyperimu's Introduction

Build Status Build status Coverage Status Project Status: Active – The project has reached a stable, usable state and is being actively developed.

HypeRIMU is an R-package for reading sensor data from the Android app HyperIMU. Supported are transfers via TCP and File in version v.3.0.4.4.

Installation

if(!require("devtools"))
  install.packages("devtools")
devtools::install_github("JohannesFriedrich/HypeRIMU")

Motivation

Modern smartphones include a lot of sensors, e.g. for gravity or linear acceleration. Some apps provide the data collected from these sensors. One famous android app is “HyperIMU” (IMU: Inertial measurement unit). There are other apps available, but HyperIMU has some advantages:

  • Choose which sensor data should be collected
  • Choose different streaming protocols: SD-card (locally on the smarphone), UDP, or TCP
  • The sampling rate can be adjusted

The R-package HypeRIMU provides some handy functions to visualise sensor data. Different streaming protocolls are supported (a local .csv file and TCP).

Usage

For using the smartphone app, see HIMUServer and HyperIMU Android and install the app on your smartphone.

Read sensor data

Until now two different methods to read the sensor data are supported: TCP and a local file.

TCP

The TCP protocol is also supported. Using this method needs to know your IP address to sumbit in the smartphone app, see HIMUServer. It´s recommended to submit the names of the sensors, see setting in the Android app HyperIMU.

data <- execute_TCP(port = 5555)

JSON

Also JSON is supported viaTCP protocol is. The usage is very smilar to TCP but the submitted data packages look different, see HyperIMU homepage. Nevertheless, the returned object is a data.frame. Using the argument return_JSON = true will return the JSON object for further analysis.

data <- execute_JSON(port = 5555)

data <- execute_JSON(port = 5555, return_JSON = TRUE)

File

The recommended way to read the data is to save the records on your smartphone and submit them locally to your PC as a .csv file. The advantage from this method is the appropriation of sensor names.

The following code shows an example of using a local file. The file can be imported via the function execute_file(). If your data provide a timestamp, choose TRUE for the argument timestamp. The functions tries to guess if a timestamp is available even when you set the timestamp argument wrong.

When a timestamp is available in the file, the function changes the UNIX format to as POSIXct format.

library(magrittr)

data <- system.file('extdata', 'short_y_impulse.csv', package = 'HypeRIMU') %>% 
  execute_file()
## 
## [execute_file()]: Timestamp detected. Used first coloumn as timestamp.

Analyse sensor data

HypeRIMU provides a function to extract some specific sensor data, see next code. When a sumbitted sensorName is not available in the data, an error message is printed.

MPL_Accelerometer <- get_specificSensor(data, sensorName = "MPL_Accelerometer")

MPL_Linear_Acceleration <- get_specificSensor(data, sensorName = "MPL_Linear_Acceleration")

Plot sensor data

Visulasing the data is one of the main advantages of this R-package. With some extra libraries a nice plot can be created in just a few lines. NOTE: It is recommended to use data with a timestamp.

library(ggplot2)
library(reshape2)
library(scales)

melt(MPL_Linear_Acceleration, id.vars = "Timestamp", variable.name = "Sensor") %>% 

ggplot(aes(x = Timestamp, y = value, color = Sensor)) + 
  geom_line() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  scale_x_datetime(labels = date_format("%H:%M:%S", tz = Sys.timezone()))

MPL_Accelerometer_melt <- melt(MPL_Accelerometer, id.vars = "Timestamp", variable.name = "Sensor") %>% 

ggplot(aes(x = Timestamp, y = value, color = Sensor)) + 
  geom_line() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  scale_x_datetime(labels = date_format("%H:%M:%S", tz = Sys.timezone()))  

Related projects

To Do

  • support UDP stream
  • make examples
  • write function to get IP adress of server

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.