Page 1 of 1

Jacobian matrix derived from SimbodyMatterSubsystem

Posted: Tue May 28, 2024 7:17 am
by lijunnan
Hi everyone,

I have a problem when I use 'calcFrameJacobian()' to calculate the Jacobian matrix in MATLAB API. It seems that the coordinate indexes from the CoordinateSet are different from those of the SimbodyMatterSubsystem.

For example, I import a hand model with all fingers and calculate the Jacobian matrix according to the middle fingertip.
Capture.PNG
Capture.PNG (8.87 KiB) Viewed 1095 times
However, the columns in Jacobian that refer to the middle finger joints derived from CoordinateSet are all zeros and some other columns that refer to other fingers have values.

Jacobian matrix in which the columns are arranged finger by finger (columns 10,11,18,23 are for middle fingers )
Jacobian.PNG
Jacobian.PNG (19.34 KiB) Viewed 1095 times
Coordinate list derived from CoordinateSet in which the coordinates for the middle finger are 15-18.
CoordinateSet.PNG
CoordinateSet.PNG (10.71 KiB) Viewed 1095 times
I am wondering if this issue is due to the mismatch of the Coordinate index system of OpenSim and Simbody or something else.

Thanks for the help!

Best,
Junnan

Re: Jacobian matrix derived from SimbodyMatterSubsystem

Posted: Tue May 28, 2024 11:06 am
by ongcf
Check out `Model::getCoordinatesInMultibodyTreeOrder` (documentation, code) which could be helpful your use case.

This is used, for instance, in Inverse Dynamics: https://github.com/opensim-org/opensim- ... s.cpp#L169

Re: Jacobian matrix derived from SimbodyMatterSubsystem

Posted: Wed May 29, 2024 2:48 am
by lijunnan
Great! this is exactly the function that i am looking for.
I have another problem regarding the coordinate setting. As I understand, once I create a joint to connect two adjacent bodies, I can define (or not define) the associated coordinates of that joint. The defined coordinates and their velocity compose a part of the State. Some of these coordinates can be prescribed as a function of another coordinate. The coordinates that are 'independent' are shown in the GUI window.
The problem I found in the model is that some of the coordinates are prescribed as a function of other independent coordinates and these dependent coordinates are not visualized in GUI and can not be given an arbitrary value.
I am wondering if my understanding is correct and how should I discover and deal with these dependent uncontrollable coordinates.

Thanks