iphone - Find distance using accleremoter, gyroscope and Device motion and also use double integration -
i want calculate distance 1 point point, when start capturing accelerometer data, , till stop that, should gather samples , should give me distance based on velocity, roll, pitch, yaw , displacement.
i have tried following code based on link1 , link2 double integration.
(int = 1; < [arrxdata count]; i++) { //======================================================================== //old velocity double v0 = [[arrvelocity objectatindex:(i-1)] doublevalue]; //time data double t0 = [[arrtimedata objectatindex:(i-1)] doublevalue]; double t1 = [[arrtimedata objectatindex:(i)] doublevalue]; //acceleration data double x0 = [[arrxdata objectatindex:(i-1)] doublevalue]; double x1 = [[arrxdata objectatindex:(i)] doublevalue]; //newvelocity double v1 = v0 + (t1 - t0) * (x0 + x1)/2; //======================================================================== //old distance double d0 = [[arrdistance objectatindex:(i-1)] doublevalue]; //new distance double d1 = d0 + (x1 - x0) * (v0 + v1)/2; //======================================================================== //store distance & velocity [arrvelocity addobject:[nsnumber numberwithdouble:v1]]; [arrdistance addobject:[nsnumber numberwithdouble:d1]]; //======================================================================== }
but above code gives negative values sometimes, , not sure, whether gives 100% correct result based on x acclearation values. here used x acceleration values after applying filter on it. used high pass filter reducing noise on x acceleration.
does know algorithm on can rely?
any appreciated.
Comments
Post a Comment