Page 1 of 2

Calculated marker position from IK

Posted: Thu May 06, 2010 2:39 am
by leistur
Hi,
probably I'm missing an easy step -
how can I output a file with the calculated marker position in a global coordinate system after Inverse Kinematics (So basically, see the error between my model marker location, and the trc data)
Ideas?

Thanks,
Alexander

RE: Calculated marker position from IK

Posted: Wed May 26, 2010 5:02 am
by leistur
Nothing at all?

RE: Calculated marker position from IK

Posted: Thu May 27, 2010 12:11 am
by sandholm
Hi

Well, its not that simple and depending on how you want to see it (the values or just an estimation, if just and estimation, check out "A Visualization Tool for OpenSim", https://simtk.org/home/visutoolopensim/ there you can create a visualization of the marker error for each marker. You can color code the marker trajectory either according to the global error or the error of each individual marker. There is example files and a manual.

cheers

RE: Calculated marker position from IK

Posted: Thu May 27, 2010 1:03 am
by leistur
Thanks for your reply!
I already tried the Visualization Tool before, and as you say it works nicely for "showing" error.
But I would really be interested in the numbers.
Since the (calculated) marker position is already shown in Opensim (white markers-blue markers), that also means it has already been calculated. So the only thing missing here would be to create an output file from that information. That should actually be simple.
Is there some API access to that?
Any thoughts appreciated!
(Don't want to go back and code a script in Matlab calculating rotation matrices for all the segments... :( )
Sascha

RE: Calculated marker position from IK

Posted: Thu May 27, 2010 1:39 am
by aymanh
Sascha,

Try turning on the flag "include_markers", by adding the following line between the opening and closing tags for <IKTrial>.

<include_markers>true</include_markers>

Good luck,
-Ayman

RE: Calculated marker position from IK

Posted: Thu May 27, 2010 1:40 am
by sandholm
Cool, let us know if you find any bug or if you are looking for anything special.

Now, the error is not really calculated, what we do in the vis tool is to calculate this. What you see in the GUI is your IK marker and the models marker. When the IK is solved you get the joint angle, in the GUI the joint angles (and translations) are applied to the model and this moves the model and markers, at the same time the motion capture data is also "played". So the only time the individual marker error is calculated is during the IK process. What we do in the vis tool is to "replay" the motion, and calculate the error between the model (with the applied IK solution) and the matching motion capture.

You might be able to use the point kinematic tool in the analyze tool, place a marker where you have a marker in your model but express it in the global coordinate system. Now you can just take your motion capture and calculate the error between your point kinematic and your motion capture. I think that should work.

RE: Calculated marker position from IK

Posted: Thu May 27, 2010 1:43 am
by mkjung99
Hi,

This may not be the correct solution. But this code gets the markers' position on human model.(I didn't consider scaling..)

Model osimModel("FileName");
State& si = osimModel.initSystem();

OpenSim::MarkerSet& refMarkerSet = pModel->updMarkerSet();
OpenSim::Array<std::string> tmpArrMarkerNames;
refMarkerSet.getNames(tmpArrMarkerNames);

int i=0;
osimModel.getSystem().realize(si, SimTK::Stage::Position);

for(i=0; i<tmpArrMarkerNames.getSize(); i++)
{
OpenSim::Marker& tempRefMarker = refMarkerSet.get(tmpArrMarkerNames);
OpenSim::Body& tempRefMarkerParentBody = tempRefMarker.getBody();
SimTK::Vec3 tempMarkerLocalPos = tempRefMarker.getOffset();
SimTK::Vec3 tempMarkerGlobalPos ;
osimModel.getSimbodyEngine().getPosition(si, tempRefMarkerParentBody, tempMarkerLocalPos, tempMarkerGlobalPos);
}

For markers' data from motion capture, I don't know exactly but you'd better to refer some classes like MarkerData, MarkerFrame and MarkerPair..

I'm sorry if you know the above code already.

Best regards,
Moonki

RE: Calculated marker position from IK

Posted: Fri May 28, 2010 12:47 am
by leistur
WOW! So much feedback!
Thanks a lot for the new information, it will take me a while to assimilate it and try everything.
I will post my findings here - maybe it's of interest for others.

Cheers,
Alexander

RE: Calculated marker position from IK

Posted: Fri May 28, 2010 12:51 am
by leistur
Ad using point kinematic analysis:
Also thought about it, but then the effort of putting 42 markers in there (and manually adjust for every rescaling, every trial,etc..) just scared me away. :D

RE: Calculated marker position from IK

Posted: Fri May 28, 2010 2:58 am
by leistur
THANKS!
For pointing out the obvious - if I only had found that line in the xml file earlier.

Problem solved..


Sascha