Calculated marker position from IK

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Alexander Kotschwar
Posts: 7
Joined: Tue Dec 11, 2007 9:13 am

Calculated marker position from IK

Post by Alexander Kotschwar » Thu May 06, 2010 2:39 am

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

User avatar
Alexander Kotschwar
Posts: 7
Joined: Tue Dec 11, 2007 9:13 am

RE: Calculated marker position from IK

Post by Alexander Kotschwar » Wed May 26, 2010 5:02 am

Nothing at all?

User avatar
Anders Sandholm
Posts: 30
Joined: Thu Feb 22, 2007 1:53 pm

RE: Calculated marker position from IK

Post by Anders Sandholm » Thu May 27, 2010 12:11 am

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

User avatar
Alexander Kotschwar
Posts: 7
Joined: Tue Dec 11, 2007 9:13 am

RE: Calculated marker position from IK

Post by Alexander Kotschwar » Thu May 27, 2010 1:03 am

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

User avatar
Ayman Habib
Posts: 2236
Joined: Fri Apr 01, 2005 12:24 pm

RE: Calculated marker position from IK

Post by Ayman Habib » Thu May 27, 2010 1:39 am

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

User avatar
Anders Sandholm
Posts: 30
Joined: Thu Feb 22, 2007 1:53 pm

RE: Calculated marker position from IK

Post by Anders Sandholm » Thu May 27, 2010 1:40 am

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.

User avatar
Moon Ki Jung
Posts: 44
Joined: Wed Oct 24, 2007 2:56 am

RE: Calculated marker position from IK

Post by Moon Ki Jung » Thu May 27, 2010 1:43 am

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

User avatar
Alexander Kotschwar
Posts: 7
Joined: Tue Dec 11, 2007 9:13 am

RE: Calculated marker position from IK

Post by Alexander Kotschwar » Fri May 28, 2010 12:47 am

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

User avatar
Alexander Kotschwar
Posts: 7
Joined: Tue Dec 11, 2007 9:13 am

RE: Calculated marker position from IK

Post by Alexander Kotschwar » Fri May 28, 2010 12:51 am

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

User avatar
Alexander Kotschwar
Posts: 7
Joined: Tue Dec 11, 2007 9:13 am

RE: Calculated marker position from IK

Post by Alexander Kotschwar » Fri May 28, 2010 2:58 am

THANKS!
For pointing out the obvious - if I only had found that line in the xml file earlier.

Problem solved..


Sascha

POST REPLY