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

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Matthew Lee
Posts: 52
Joined: Sat Jun 20, 2020 7:46 pm

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

Post by Matthew Lee » Sun Mar 26, 2023 1:13 pm

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

User avatar
Edward Syrett
Posts: 34
Joined: Mon Jan 14, 2019 11:04 am

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

Post by Edward Syrett » Tue Mar 28, 2023 6:03 am

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

User avatar
Ton van den Bogert
Posts: 164
Joined: Thu Apr 27, 2006 11:37 am

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

Post by Ton van den Bogert » Tue Mar 28, 2023 8:40 am

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!

User avatar
Matthew Lee
Posts: 52
Joined: Sat Jun 20, 2020 7:46 pm

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

Post by Matthew Lee » Wed Mar 29, 2023 12:29 pm

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 972 times
partial time node from ik tool.JPG
partial time node from ik tool.JPG (36.48 KiB) Viewed 972 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 972 times
I would appreciate any further help, thanks again for your patience and time.

Best Wishes,
Matthew

User avatar
Mohammadreza Rezaie
Posts: 392
Joined: Fri Nov 24, 2017 12:48 am

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

Post by Mohammadreza Rezaie » Fri Mar 31, 2023 3:41 pm

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 930 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

User avatar
Mohammadreza Rezaie
Posts: 392
Joined: Fri Nov 24, 2017 12:48 am

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

Post by Mohammadreza Rezaie » Wed Apr 19, 2023 7:13 am

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.

User avatar
Giulia Ghielmi
Posts: 9
Joined: Sun Mar 05, 2023 10:40 am

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

Post by Giulia Ghielmi » Mon Nov 20, 2023 10:38 am

Hello! Have you found a solution for this problem? I encountered the same problems.

Thanks in advance.

POST REPLY