Page 1 of 1

How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?

Posted: Sun Mar 26, 2023 1:13 pm
by luckyme
Dear OpenSim development team and OpenSim users,

Thank you all for your contributions to the biomechanics community! I have some questions as follows, I would appreciate it if anyone could give me some advice.

Given a trc file containing marker trajectories, after running inverse kinematics (IK) tool, what we actually get is joint angle data at several discrete time points (assuming these points belong to set A). If I want to obtain joint angle data at a time point that is not belong to set A, interpolation is required to obtain it. May I ask which type of spline curve is used by default in OpenSim to interpolate the results of inverse kinematics?

Since the mot file output by inverse kinematics only contains coordinate (joint angle) information,if I want to further obtain joint angular velocity and joint angular acceleration information, is there an easy way in OpenSim to do this directly?

Can the inverse kinematics tool output both joint angular velocities and joint angular accelerations to the result .mot file?

I would be very grateful if someone could give me some advice.

Best Wishes,
Matthew

Re: How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?

Posted: Tue Mar 28, 2023 6:03 am
by syretted
Hi Matthew,
I don't know anything about the spline that is used in OpenSim, but I can help you with the second question you have. After you have generated an IK file, you can use that file as the input for the Analyze tool, and select the "Kinematics" analysis. This should give you three outputs: one with the joint angles, one with speeds, and one with accelerations.

see here: https://simtk-confluence.stanford.edu:8 ... h+Analyses

Give that a try and see if that works!

Dan

Re: How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?

Posted: Tue Mar 28, 2023 8:40 am
by bogert
I support Edward's suggestion.

Although the SimmSpline can be differentiated to give velocities and accelerations, I would not recommend this. Interpolating splines are sensitive to noise and will give unreliable derivatives.

To see an example, run my test code with these knots:

Code: Select all

x = 0:10;
y = x + randn(size(x));
This is a function with a derivative of 1, plus some noise. The spline overestimates the first derivative a lot.

Smoothing splines (which don't pass exactly through the knots) can be used, and this capability is available as GCVSpline in OpenSim.

In AnalyzeTool, you can set the cutoff frequency of the low pass filter. The API documentation does not specify how it does the filtering. It may be GCVSpline.

If someone has this information (or a link to the information), please let us know!

Re: How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?

Posted: Wed Mar 29, 2023 12:29 pm
by luckyme
Many thanks to Edward for advice. Thanks very much for further guidance from Professor Ton.

I ran scaling and inverse kinematics using the gait2392 model and the corresponding example setup file from the file path 'OpenSim4.2\model\Models\Gait2392_Simbody'. Then I used the result file 'subject01_walk1_ik.mot' obtained by inverse kinematics as the input of the 'Analyze tool' to perform kinematics analysis. Through the operation I encountered the following problem which confuses me a lot:

1.After opening the 'Analyze tool', in the section for 'Input' of 'Main Settings' panel, I checked the 'Filter coordinates' option and specified the cutoff frequency as 6HZ. By looking at the joint angle file 'subject01_Kinematics_q.sto' obtained by running the 'Analyze tool', I found that the time node in the time column is not the same as the time node in 'subject01_walk1_ik.mot'.Furthermore,the first time node in 'subject01_Kinematics_q.sto' is 0.492s,which is outside the time range of 'subject01_walk1_ik.mot'(0.5s-2.5s).
partial time node from analyze tool.JPG
partial time node from analyze tool.JPG (20.83 KiB) Viewed 1204 times
partial time node from ik tool.JPG
partial time node from ik tool.JPG (36.48 KiB) Viewed 1204 times
2.By looking at the obtained coordinate acceleration file 'subject01_Kinematics_dudt.sto', I found that the acceleration value is very large, which seems unreasonable.
partial acceleration from analyze tool.JPG
partial acceleration from analyze tool.JPG (227.58 KiB) Viewed 1204 times
I would appreciate any further help, thanks again for your patience and time.

Best Wishes,
Matthew

Re: How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?

Posted: Fri Mar 31, 2023 3:41 pm
by kernalnet
Hi,

The type of filtering in Analyze tool can be found here:
3rd ORDER LOWPASS IIR BUTTERWORTH DIGITAL FILTER
https://github.com/opensim-org/opensim- ... l.cpp#L391
https://github.com/opensim-org/opensim- ... l.cpp#L161

Regarding the differences in time frame before and after filtering, the issue is that the marker data in that example were recorded at 60 Hz, so, the time intervals would be 1/60 (i.e., 0.01666666666...). However, if you check the time intervals in the TRC (and the IK output), you will find that they are not consistent (almost 0.017 but sometimes 0.016). That's the source of issue. A simple fix would be to change it manually in excel and see how it works:
Screenshot 2023-04-01 013642.jpg
Screenshot 2023-04-01 013642.jpg (59.27 KiB) Viewed 1162 times
Regarding the acceleration values, that's weird to me too. I'd like to know why this is happening in this case. Perhaps it requires state file to be calculated properly.

Best,
Mohammadreza

Re: How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?

Posted: Wed Apr 19, 2023 7:13 am
by kernalnet
Hi, I found this which might be helpful: https://simtk-confluence.stanford.edu:8 ... n+Concepts
The Cartesian coordinates of each body generally need to be known before the forces can be calculated, and the forces need to be known before the internal coordinate accelerations can be calculated.

Re: How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?

Posted: Mon Nov 20, 2023 10:38 am
by giuliaghielmi
Hello! Have you found a solution for this problem? I encountered the same problems.

Thanks in advance.