mad-lab-fau / gaitmap

The Gait and Movement Analysis Package
https://gaitmap.readthedocs.io
Other
38 stars 2 forks source link

Direction of two synchronized sensors #55

Closed Alx2203 closed 6 months ago

Alx2203 commented 8 months ago

Hi,

I'm having a problem with rotation to sensor frame definition. My sensors are placed in the same orientation as in the example you give, so I apply this as in the example:

# rotate left_sensor first by -90 deg around the z-axis, followed by a -90 deg rotation around the x-axis. As the rotation matrix is multiplied from the left, the rotation matrix  results in:
left_rot = rotation_from_angle(np.array([1, 0, 0]), np.deg2rad(-90)) * rotation_from_angle(
    np.array([0, 0, 1]), np.deg2rad(-90)
)

# rotate right_sensor first by +90 deg around the z-axis, followed by a +90 deg rotation around the x-axis
right_rot = rotation_from_angle(np.array([1, 0, 0]), np.deg2rad(90)) * rotation_from_angle(
    np.array([0, 0, 1]), np.deg2rad(90)
)

rotations = dict(left_sensor=left_rot, right_sensor=right_rot)

The problem is that when I reconstruct the trajectory, my 2 sensors seem to be pointing in opposite directions, whereas they are mounted on a person walking with both legs in the same direction.

traj_reconstruction

Is this a problem you've experienced before?

AKuederle commented 7 months ago

Hi, thank you for opening this issue! This looks indeed like some issue with the initial orientation.

Just for general information:

However, in your case it looks like something might be wrong with your initial assumption of the sensor directions. Can you compare your signals (before and after to rotation) with the example singals for a stride shown here?

https://gaitmap.readthedocs.io/en/latest/source/user_guide/coordinate_systems.html

This should give some indication, if you rotated everything correcly.

Alx2203 commented 7 months ago

Hello, Thanks for your answer. Yes indeed, I use the Kalman filter for the reconstruction. I checked and it seems that I didn't make a mistake concerning the directions of my sensors. I tried to recalibrate my sensors but I couldn't correct the problem. Here's the result I get for a straight line: straigt_line

AKuederle commented 7 months ago

Mmh this looks like a problem with the initial orientation. We don't have any knowledge about the inittial orientation. Hence we initialize the initial orientation, under the assumption that the local sensor frame aligns with the directions of the global frame at t=0. If the x-axis of the sensors don't align with the forward direction of the movement at t=0, then this could explain the deviation you are seeing.

The paths of both sensors look "straight", hence I don't assume this is integration drift (which usually amplifies itself exponentially). So I assume that it is simply a case of "the x-axis of the two sensors are not pointing in the same direction at t=0".

Depending on your application, what you could try to do is, to estimate the direction of travel (if you know people are walking forward and rotate both trajectories accordingly. Unfortunately, I don't think there is a universal solution to perfectly initialize the orientation of both sensors in the same coordinate frame, in particular, when they are not perfectly aligned with the shoe/walking direction

Alx2203 commented 7 months ago

Ok thanks for the advice, I'll try to rotate the trajectories :)

AKuederle commented 6 months ago

@Alx2203 I will close the issue for now. Feel free to reopen, in case you have further questions regarding this topic