Page 1 of 1

How to add weights to the coordinates of a model using C++ API

Posted: Thu Sep 03, 2020 7:20 am
by docvi
Hi,

I am using the C++ API to build and solve a model.
I would like to assign weights to the coordinates of my model.
I saw that it is possible when I look at the detailed description section of the InverseKinematicsSolver class (https://simtk.org/api_docs/opensim/api_ ... olver.html). I can see W_qj which contains the weights for the coordinates.

Unfortunately, I did not find a proper way to do it as compared with marker weights (there is a method to update the marker weights in the InverseKinematicsSolver class).
I found that one can create a CoordinateReference and set weights to it and include it as a third input argument of the InverseKinematicsSolver class (https://simtk.org/api_docs/opensim/api_ ... rence.html). However, one has to specify a Function for the desired value of this CoordinateReference which is not what I want because I do not know what the value should be (this is what I am trying to find actually by using the InverseKinematicsSolver class).

So I am a bit confused and any help to clarify how i can set weights to the coordinates of my model will be appreciated.

Thank you

Vincent

Re: How to add weights to the coordinates of a model using C++ API

Posted: Fri Sep 04, 2020 3:50 am
by tkuchida
The Coordinates are handled by the AssemblySolver class (parent to InverseKinematicsSolver), which may provide the functionality you're looking for.

Re: How to add weights to the coordinates of a model using C++ API

Posted: Fri Sep 04, 2020 4:49 am
by docvi
Thanks Thomas. I will look into it

Re: How to add weights to the coordinates of a model using C++ API

Posted: Fri Sep 04, 2020 6:32 am
by docvi
Hi again,

I had a look at the AssemblySolver class but the problem remains the same.
I still cannot add only a weight to a Coordinate without giving a value to it.
This approach is therefore not appealing to me since the Coordinate values is what I am trying to get through the inverse kinematics process.
I would like to give a weight to each coordinate so it has more or less importance when the solver is trying to find a solution (minimising the error).
I really thought it was possible

Thanks anyway

Vincent

Re: How to add weights to the coordinates of a model using C++ API

Posted: Fri Sep 04, 2020 6:06 pm
by tkuchida
Please see the description of the algorithm on the "How Inverse Kinematics Works" page in the documentation (https://simtk-confluence.stanford.edu/d ... tics+Works). If the InverseKinematicsSolver class doesn't meet your specific needs, you could extend it (e.g., by creating a C++ plugin), or suggest an enhancement on the GitHub page (https://github.com/opensim-org/opensim-core/issues).

Re: How to add weights to the coordinates of a model using C++ API

Posted: Sun Sep 06, 2020 11:31 pm
by docvi
Thank you Thomas.
This webpage has more information and explains the weights on the coordinates.
I was misled by the previous documentation page of the C++ API.
I understand now that this is doing something different from what I thought.
I will reflect and see if I want to investigate the other options you mentioned.

Regards

Vincent