Cannot find the objectiveFunction of InverseKinematics

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Cannot find the objectiveFunction of InverseKinematics

Post by YUAN Ye » Thu Jun 22, 2017 3:43 am

Hello,

I am currently working on InverseKinematics, I want to add a constraint when calculating marker errors, but I cannot find the objectiveFunction of InverseKinematics, can someone help me?

Thank you

Ye YUAN

User avatar
Yanis AMMOUCHE
Posts: 23
Joined: Mon Apr 24, 2017 6:09 am

Re: Cannot find the objectiveFunction of InverseKinematics

Post by Yanis AMMOUCHE » Thu Jun 22, 2017 4:06 am

Hello,

What kind of constraints do you want to use ?

Yanis.

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: Cannot find the objectiveFunction of InverseKinematics

Post by YUAN Ye » Thu Jun 22, 2017 4:18 am

y_ammouche wrote:Hello,

What kind of constraints do you want to use ?

Yanis.
Hello,

I am doing research on scapula, i add 2 markers on the scapula, and want to make sure that these 2 markers stay as close as possible to the thorax, so i create 100 markers on the thorax, for each frame, i try to find the minimun distance between the 2 markers and the 100 markers, the which will be my minimun distance between the scapula and the thorax. When I did all this, the result of inversekinematics(motion file) doesn't seem to change, so the problem is that these additional markers aren't used for IK.

That's what I found, maybe it's wrong, please don't hesitate if you have any remarks.

Thanks

Ye YUAN

User avatar
Yanis AMMOUCHE
Posts: 23
Joined: Mon Apr 24, 2017 6:09 am

Re: Cannot find the objectiveFunction of InverseKinematics

Post by Yanis AMMOUCHE » Thu Jun 22, 2017 6:31 am

Ok, I imagine you already know it, but here is how IK works.

You create virtual markers on your model that are at the same place of the real markers. The input will be a trc file containing the position of these markers.

Opensim will try to find the set of coordinates q that minimize the sum of the squared difference between the position of the virtual marker (function of q) and the position of the real markers specified on the trc file. You can specify weight on the IK control panel if you want the position of a virtual marker to be really close to the position of a real marker.

Now you specified 100 particular markers and you want to find the shoulder joint angle that alsominimizes the distances beetween your 2 markers and these 100 markers ?

So adding the sum of distances beetween your scapula marker and the 100 torso markers to the previous function.

Yanis

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: Cannot find the objectiveFunction of InverseKinematics

Post by YUAN Ye » Thu Jun 22, 2017 10:33 am

Hi Yanis,

I have a model which contains 24 markers, and I added 2 markers on the scapula, 100 markers on the thorax, but I don't have their real positions in .trc, so I added 102*3 NaN in the .trc file, to make sure that IK works.

Apart from doing the normal IK for the 24 markers, I want to ensure that the distance between the 2 markers and the 100 markers is as small as possible, I don't have their coordinates so I can only calculate the distance of their virtual positions.In AssemblyCondition_Markers.h we have:
Real findCurrentMarkerErrorSquared(MarkerIx mx) const {
const ObservationIx ox = getObservationIxForMarker(mx);
if (!ox.isValid()) return 0; // no observation for this marker
const Vec3& loc = getObservation(ox);
if (!loc.isFinite()) return 0; // NaN in observation; error is ignored
return (findCurrentMarkerLocation(mx) - loc).normSqr();
}
so I made a similar one:
Real function(MarkerIx mx1, MarkerIx mx2) const {
return (findCurrentMarkerLocation(mx1)-findCurrentMarkerLocation(mx2)).normSqr();
}
The problem is after doing all this, the result of IK is exactly the same as before, in my opinion the motion file should change a little bit to ensure that the distance between the 2 markers and the 100 markers is as small as possible, but I cannot see why this doesn't work.

Ye Yuan

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: Cannot find the objectiveFunction of InverseKinematics

Post by YUAN Ye » Fri Jun 23, 2017 7:57 am

y_ammouche wrote: Opensim will try to find the set of coordinates q that minimize the sum of the squared difference between the position of the virtual marker (function of q) and the position of the real markers specified on the trc file.
Where is this functionality realised in the source code ?

User avatar
Yanis AMMOUCHE
Posts: 23
Joined: Mon Apr 24, 2017 6:09 am

Re: Cannot find the objectiveFunction of InverseKinematics

Post by Yanis AMMOUCHE » Fri Jun 23, 2017 10:21 am

Sorry for the late answer, I was searching for the place where this function was called. It may not be that but try to have a look at this link https://github.com/opensim-org/opensim- ... Solver.cpp

Yanis

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: Cannot find the objectiveFunction of InverseKinematics

Post by YUAN Ye » Mon Jun 26, 2017 2:25 am

y_ammouche wrote:Sorry for the late answer, I was searching for the place where this function was called. It may not be that but try to have a look at this link https://github.com/opensim-org/opensim- ... Solver.cpp

Yanis
Hi Yanis,

Thanks for your help although I have already been working on this class :)

Ye YUAN

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Cannot find the objectiveFunction of InverseKinematics

Post by jimmy d » Mon Jun 26, 2017 8:56 am

AssemblySolver is probably what you are after;
https://github.com/opensim-org/opensim- ... Solver.cpp

User avatar
YUAN Ye
Posts: 17
Joined: Wed Jan 25, 2017 9:19 am

Re: Cannot find the objectiveFunction of InverseKinematics

Post by YUAN Ye » Tue Jun 27, 2017 6:33 am

jimmy wrote:AssemblySolver is probably what you are after;
https://github.com/opensim-org/opensim- ... Solver.cpp
Hi,

When doing inverse kinematics, if I want to add a constraint that the distance between 2 specific markers should be constant(d12 = 0.01 for example), where in the source code should I add this?

Ye YUAN

POST REPLY