Inverse Kinematics Angle Calculation

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Andrew Su
Posts: 2
Joined: Wed Aug 05, 2020 10:25 am

Inverse Kinematics Angle Calculation

Post by Andrew Su » Mon Nov 02, 2020 1:12 pm

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.)!

Tags:

User avatar
Carmichael Ong
Posts: 387
Joined: Fri Feb 24, 2012 11:50 am

Re: Inverse Kinematics Angle Calculation

Post by Carmichael Ong » Mon Nov 02, 2020 2:48 pm

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.

User avatar
Radhakrishnan Vignesh
Posts: 104
Joined: Tue Jun 01, 2021 8:09 am

Re: Inverse Kinematics Angle Calculation

Post by Radhakrishnan Vignesh » Tue Jun 27, 2023 8:35 am

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

User avatar
Thomas Uchida
Posts: 1790
Joined: Wed May 16, 2012 11:40 am

Re: Inverse Kinematics Angle Calculation

Post by Thomas Uchida » Tue Jun 27, 2023 5:42 pm

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).

User avatar
Radhakrishnan Vignesh
Posts: 104
Joined: Tue Jun 01, 2021 8:09 am

Re: Inverse Kinematics Angle Calculation

Post by Radhakrishnan Vignesh » Tue Jun 27, 2023 11:27 pm

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

User avatar
Thomas Uchida
Posts: 1790
Joined: Wed May 16, 2012 11:40 am

Re: Inverse Kinematics Angle Calculation

Post by Thomas Uchida » Wed Jun 28, 2023 10:58 am

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.

User avatar
Radhakrishnan Vignesh
Posts: 104
Joined: Tue Jun 01, 2021 8:09 am

Re: Inverse Kinematics Angle Calculation

Post by Radhakrishnan Vignesh » Wed Jun 28, 2023 11:11 am

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

User avatar
Thomas Uchida
Posts: 1790
Joined: Wed May 16, 2012 11:40 am

Re: Inverse Kinematics Angle Calculation

Post by Thomas Uchida » Wed Jun 28, 2023 1:30 pm

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.).

User avatar
Radhakrishnan Vignesh
Posts: 104
Joined: Tue Jun 01, 2021 8:09 am

Re: Inverse Kinematics Angle Calculation

Post by Radhakrishnan Vignesh » Wed Jun 28, 2023 1:37 pm

Thanks a lot

Regards,
Vignesh

User avatar
Radhakrishnan Vignesh
Posts: 104
Joined: Tue Jun 01, 2021 8:09 am

Re: Inverse Kinematics Angle Calculation

Post by Radhakrishnan Vignesh » Wed Jul 05, 2023 11:26 pm

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

POST REPLY