# Estimating joint angles using accelerometer data

the question I'm working on is the following: three IMU sensors have been placed on the lower limb, one of the hip, one on the thigh and one on the shank.

The IMU sensors collect acceleration data in x/y/z directions, and gyroscope data for the three axes.

I want to use this data to estimate joint angles: hip angle and knee angle.

Starting point will be to align the sensor coordinate systems. Assume two separate systems: to estimate the hip angle, work with sensor on the hip (1) and on the thigh (2). To estimate knee angle, work with data from sensor on the thigh (2) and the shank (3).

So, need to align (1) and (2), and (2) and (3).

However, struggling to work the rotation matrix. How to do this? Once rotation matrix calculated, then what are the next steps?

Thank you.

## 1 Answer

Making the hypothesis that you can fix the rotation between sensors during the calibration phase (having joints fixed somehow), you can measure the gravity vector in several positions. Then the gravity vector in frame $$(1)$$: $$^{(1)}\mathbf g$$ and gravity vectors in frame $$(2)$$: $$^{(2)}\mathbf g$$ are related by the equation: $$^{(1)}\mathbf g = \,^{(1)} \mathbf R _{(2)} \cdot \, ^{(2)} \mathbf g$$ with the matrix $$^{(1)} \mathbf R _{(2)}$$ being your rotation matrix between the two frames. (So here the rotation of sensor 2 with regard to sensor 1).

You can have a look here for a method finding the rotation matrix between two vectors. If you use Matlab, you can directly use the function vrrotvec (help here).

You can do this every sampling time to retrieve the rotation of each joints. In case of "rapid" motion however, the gravity vector might not be so clear (acceleration from motion also measured by the accelerometer), hence making this solution not so feasible. A solution might be to use a Kalman filter with your first rotation and then track it with the gyroscope as a motion model (integrate angular velocities over time) and the gravity vector as a correction measure. This can be very tedious and I would strongly advise going for an IMU that already does the integration job for you (such as this one on a DYI level).

Good luck :-).