Correct way of calculating the roll of an animal using 3d acceleration?

不羁岁月 提交于 2020-03-05 00:35:16

问题


I placed an accelerometer to several fishes in a field experiment to understand some of their behaviours. What I got was values of raw acceleration (X, Y, Z) of the fishes. This raw acceleration is decomposed into a part that is static (due to the gravity. I call it rmX, rmY and rmZ) and a dynamic part (due to the movement of the fish. I call it diX,diY and diZ). What I would like is to calculate the roll of my fishes in different circumstances (while swimming, resting, etc) since this information could be relevant from an ecological point of view.

The most complicated aspect in my case is that the accelerometers do not stay perfectly aligned with all the gravity acceleration on the Y-axis and being X and Z = 0. I always placed the accelerometer with the same orientation but static acceleration differs among fishes due to the impossibility of placing the accelerometer exactly in the same way in all fishes. For all individuals, in their natural position (belly down and dorsal fin up), the gravity acceleration is on all 3 axes.

What I had done to calculate the roll was this:

FR <- 12.0 # Recording frequency. 12 Hz in my case.
RM <- 2 * FR # Running mean (to calculate static and dynamic acceleration)

Individual1$rmX <-runmean(Individual1$X,RM) # To calculate static acceleration
Individual1$rmY <-runmean(Individual1$Y,RM)
Individual1$rmZ <-runmean(Individual1$Z,RM)

Individual1$disurge <- abs(Individual1$X-Individual1$rmX) # To calculate dinamic acceleration
Individual1$diheave <- abs(Individual1$Y-Individual1$rmY)
Individual1$disway <- abs(Individual1$Z-Individual1$rmZ)

Individual1$roll <- (asin(Individual1$rmZ))*180/pi # To calculate Roll!!

summary(Individual1$roll)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
-90.000 -53.953 -42.423 -26.456  -9.004  66.924    2186 

However, I get NAs for the variable roll. I think it is due to the formula I am using. If I use the formula that appears in this post in StackOverflow I get the following:

foo$roll<- atan2(foo$rmY, foo$rmZ) * 180/pi

summary(foo$roll)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-179.97  100.45  113.13   96.76  143.81  179.97 

As you can see, the result differs substantially between I used to do and what I have seen that is being used for other colleagues. I think it makes more sense what I saw in the post (foo$roll<- atan2(foo$rmY, foo$rmZ) * 180/pi) since the range of values for the roll is -180/ +180. I have seen that the formula I used to use only take into account the Z-axis, but the formula mentioned in the post uses also the value of the Y-axis to calculate the roll.

Does anyone know how to proceed in my particular case? Which formula takes more sente?


回答1:


this link has a good explanation of how co calculate pitch, yaw and roll: http://students.iitk.ac.in/roboclub/2017/12/21/Beginners-Guide-to-IMU.html

In your case, roll would be:

roll = 180 * atan2(accelY, sqrt(accelX*accelX + accelZ*accelZ))/PI;

I found in practice this is not enough because the accelerometer data is noisy, and looking at several articles on building e-compasses I found the solution I describe here

But if you are stuck because you get conflicting information from different sources what you can always do is validate the formulas in an controlled environment. e.g. place your accelerometer at a 30 degree roll (measure the angle before reading the output of your program) and see what output you get. Try this for several angle values before you decide what works for you. It's advisable to run calibration externally before placing your device in an uncontrolled environment, like on a fish that moves erratically.



来源:https://stackoverflow.com/questions/60174039/correct-way-of-calculating-the-roll-of-an-animal-using-3d-acceleration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!