Page 1 of 2

Inverse Kinematics Angle Calculation

Posted: Mon Nov 02, 2020 1:12 pm
by andrewsu98
Hello everyone. Apologies if this is a dumb question or if it's been answered before, but I couldn't find an answer. How do I determine how the different joint angles are calculated when running inverse kinematics (i.e. which markers are used)? For example, I'm using Dr. Lerner's OpenSim Musculoskeletal Model of a Sheep Hind Limb (https://simtk.org/projects/sheep_hind_limb) with a custom markerset and I want to know how the hock angle is calculated. Any help is appreciated (previous forum posts, OpenSim documentation, etc.)!

Re: Inverse Kinematics Angle Calculation

Posted: Mon Nov 02, 2020 2:48 pm
by ongcf
Check out the documentation for inverse kinematics here: https://simtk-confluence.stanford.edu/d ... tics+Works

The key here is that it does an optimization using weighted least squares. So, each joint angle cannot be directly correlated to specific markers, but rather, all joint angles are chosen at the same time to minimize all of the joint marker errors.

Re: Inverse Kinematics Angle Calculation

Posted: Tue Jun 27, 2023 8:35 am
by vigneshrk
Hi,

Sorry I have a question regarding how joint angles are calculated using the least squares equation.

1) If no coordinate is specified, how are the virtual marker data converted to joint angles?

Thanks,
Vignesh

Re: Inverse Kinematics Angle Calculation

Posted: Tue Jun 27, 2023 5:42 pm
by tkuchida
If no coordinate is specified, how are the virtual marker data converted to joint angles?
I presume you mean that no coordinates are "enabled" in the "weights" pane. Some information about the "weights" pane can be found on the "How to Use the IK Tool" page in the documentation (https://simtk-confluence.stanford.edu:8 ... he+IK+Tool). If no coordinates are "enabled", then the weighted least squares problem will be solved at each time step considering only the weighted marker errors (please see the "How Inverse Kinematics Works" page for details: https://simtk-confluence.stanford.edu:8 ... tics+Works).

Re: Inverse Kinematics Angle Calculation

Posted: Tue Jun 27, 2023 11:27 pm
by vigneshrk
Hi Thomas,

Thank you. I would like to get some more detail in how the angles are calculated. Once the virtual markers positions are adjusted, how are the joint angles then computed? Are the new positions of the markers used to calculate a new transformation matrix etc?
Also, which function in inversekinematicsTool, computes the joint angles?

Thanks

Re: Inverse Kinematics Angle Calculation

Posted: Wed Jun 28, 2023 10:58 am
by tkuchida
Once the virtual markers positions are adjusted, how are the joint angles then computed?
The IK Tool solves a weighted least squares problem in which values for the model's coordinates are sought so as to minimize the weighted sum of squared marker errors (distance between each marker on the model and its corresponding experimental marker). The optimizer works by guessing values for the model's coordinates, calculating the weighted sum of squared marker errors, and repeating until this weighted sum is sufficiently small. If a good guess for the model's coordinates is not known (e.g., for the first time step of a simulation), then the "optimizer will choose LBFGS for unconstrained (or just bounds-constrained) problems, InteriorPoint for constrained problems" (https://github.com/simbody/simbody/blob ... r.cpp#L754). If a good guess is known (e.g., for time steps after the first one, assuming that the model does not move substantially between consecutive time steps), then a straightforward projection is attempted first; failing that, a more expensive optimization will be performed. More detail can be found in the Simbody Theory Manual (https://github.com/simbody/simbody/blob ... Manual.pdf) and in the doxygen comments for the AssemblySolver::assemble() and AssemblySolver::track() methods.

Re: Inverse Kinematics Angle Calculation

Posted: Wed Jun 28, 2023 11:11 am
by vigneshrk
Hello Thomas,

Thanks a lot. That makes a lot of sense. I shall look into the assemble and track functions. Just to confirm, is there any calculation of angles done in the Kinematics class in InverseKinematicsTool or is it just used for reporting angles?

Regards
Vignesh

Re: Inverse Kinematics Angle Calculation

Posted: Wed Jun 28, 2023 1:30 pm
by tkuchida
Most of the calculations can be found in the InverseKinematicsSolver class (https://simtk.org/api_docs/opensim/api_ ... ml#details) and the Assembler class in Simbody (https://simtk.org/api_docs/simbody/3.5/ ... ml#details). The InverseKinematicsTool class is just an interface (setup, reporting, etc.).

Re: Inverse Kinematics Angle Calculation

Posted: Wed Jun 28, 2023 1:37 pm
by vigneshrk
Thanks a lot

Regards,
Vignesh

Re: Inverse Kinematics Angle Calculation

Posted: Wed Jul 05, 2023 11:26 pm
by vigneshrk
Hi Thomas,

Sorry I have a follow-up question:

1) Based on my understanding, if I do not have any experimental coordinates, the residual at each frame would just contain the marker residuals. There would not be any influence of calculated unprescribed coordinates in the residual error. Is my understanding wrong ? Would there be an influence of calculated unprescribed coordinates in subsequent frames?

Thanks