3

I am trying to make an app has a reset button and displays how much phone has moved linearly as well as angularly. It has been difficult because I don't know much about accelerometer and gyroscope or even android programming. So I have been thinking about just using these data I got from the app called Sensor Kinetic first to do the calculation to measure how much phone moved linearly and angularly.

The two images below are the sample data (time, X, Y, Z). I believe it can be done with these data should be but I haven't progressed for the past few hours researching. I know they are not syncing in term of time but I only the starting point and the last point to measure.

gyroscope_sample_data rad/s :

enter image description here

accelerometer_sample_data m/s^2 :

enter image description here

I have been trying too look up how to measure the distance angularly and linearly but I found a lot of work talking about it but nothing seems to have done it this way or measure both linear and angular distance.


Edited: I wrote this to calculate the distance the phone move linearly with the accelerometer but I received around 103 meter for only rotating the phone around me. I am also not sure about the gyroscope for angular distance either so let me know what you all think.

def acc_calculation(dataset):
    dx, dy, dz = 0.0, 0.0, 0.0
    vx, vy, vz = 0.0, 0.0, 0.0
    acceleration_x, acceleration_y, acceleration_z = dataset['X_value'], dataset['Y_value'], dataset['Z_value']
    for i in range(1, len(dataset['time'])):
        dt = float(dataset['time'][i]) - float(dataset['time'][i-1])
        print(dt)
        vx += (float(acceleration_x[i-1]) + float(acceleration_x[i]))/2.0*dt
        vy += (float(acceleration_y[i-1]) + float(acceleration_y[i]))/2.0*dt
        vz += (float(acceleration_z[i-1]) + float(acceleration_z[i]))/2.0*dt
        dx += vx*dt;
        dy += vy*dt;
        dz += vz*dt;
    dl = math.sqrt(dx**2 + dy**2 + dz**2)
    return dl

I am trying to post more related links but stackoverflow doesn't let me. If anyone has any leads and especially detailed information about it for apps or work that already done it, I would really appreciate.

Accelerometer & Gyro Tutorial :

http://www.instructables.com/id/Accelerometer-Gyro-Tutorial/step3/Combining-the-Accelerometer-and-Gyro/#intro

How can I find distance traveled with a gyroscope and accelerometer?

Community
  • 1
  • 1
HQT7
  • 41
  • 4

0 Answers0