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
How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?
- Matthew Lee
- Posts: 52
- Joined: Sat Jun 20, 2020 7:46 pm
- 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?
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
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
- 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?
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:
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!
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));
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!
- 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?
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). 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. I would appreciate any further help, thanks again for your patience and time.
Best Wishes,
Matthew
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). 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. I would appreciate any further help, thanks again for your patience and time.
Best Wishes,
Matthew
- Mohammadreza Rezaie
- Posts: 393
- Joined: Fri Nov 24, 2017 12:48 am
Re: How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?
Hi,
The type of filtering in Analyze tool can be found here:
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: 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
The type of filtering in Analyze tool can be found here:
https://github.com/opensim-org/opensim- ... l.cpp#L3913rd ORDER LOWPASS IIR BUTTERWORTH DIGITAL FILTER
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: 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
- Mohammadreza Rezaie
- Posts: 393
- Joined: Fri Nov 24, 2017 12:48 am
Re: How to obtain joint angular velocity and joint angular acceleration by inverse kinematics tool?
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.
- 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?
Hello! Have you found a solution for this problem? I encountered the same problems.
Thanks in advance.
Thanks in advance.