How can I calculate kinematics of ankle joint after calculating local coordinates of the foot and shank from the 3D position of markers?
13 views (last 30 days)
Show older comments
Hi all,
I have a human 3D motion data (walking straight).
I want to calculate ankle joint kinematics.
I have calculated the local coordinates of the foot and shank segments using the XYZ coordinates (in meters) of 3 markers from each segment. Code for shank coordinate system ( as suggested by ChatGPT):
% The shank coordinate system axes (lateral malleoli, medial malleoli, head of fibula)
l_shank_x = (llmal - lmmal) / norm(llmal - lmmal);
l_shank_y = cross(l_shank_z, l_shank_x);
l_shank_z = cross(lfib - lmmal, llmal - lmmal) / norm(cross(lfib - lmmal, llmal - lmmal));
% Ensure axis vectors are normalized
l_shank_x2 = l_shank_x / norm(l_shank_x);
l_shank_y2 = l_shank_y / norm(l_shank_y);
l_shank_z2 = l_shank_z / norm(l_shank_z);
% Create the shank rotation matrix
lshank_rotation_matrix = [l_shank_x2', l_shank_y2', l_shank_z2'];
These coordinates are attached for both the foot and the shank (both 868x9 double).
I have also calcuted ankle joint center (attached):
l_ankle_cent = lcal + lmet5/2;
I wonder what is the general framework to follow to calculate ankle joint 3D kinematics (in degrees) from here?
0 Comments
Accepted Answer
Suraj Kumar
on 27 Sep 2024
Hi Tomaszzz,
To compute the ankle joint angles, you can refer the following steps and the attached code snippets:
1. Compute the relative rotation matrix between the shank and the foot by multiplying the inverse of shank’s rotation matrix and foot rotation matrix.
for i = 1:num_frames
% Extract rotation matrices for the current frame
shank_rot = lshank_rotation_matrix(:, :, i);
foot_rot = lfoot_rotation_matrix(:, :, i);
% Calculate relative rotation matrix
relative_rotation_matrix = shank_rot' * foot_rot;
2. Then, you can extract the Euler angles using the ‘rotm2eul’ function and iterate over each frame, performing the above calculations for all frames in the dataset.
% Convert to Euler angles using ZYX sequence
euler_angles = rotm2eul(relative_rotation_matrix, 'ZYX');
3. Plot the calculated ankle joint angles over time to visualize the results.
figure;
subplot(3, 1, 1);
plot(ankle_angles_degrees(:, 1));
title('Ankle Joint Yaw Angle');
xlabel('Frame');
ylabel('Degrees');
subplot(3, 1, 2);
plot(ankle_angles_degrees(:, 2));
title('Ankle Joint Pitch Angle');
xlabel('Frame');
ylabel('Degrees');
subplot(3, 1, 3);
plot(ankle_angles_degrees(:, 3));
title('Ankle Joint Roll Angle');
xlabel('Frame');
ylabel('Degrees');
You may check the output below for a better understanding:
To know more about the ‘rotm2eul’ function in MATLAB, you can refer to the following documentation:
Happy Coding!
0 Comments
More Answers (0)
See Also
Categories
Find more on Biological and Health Sciences in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!