Calculated marker position from IK
- Alexander Kotschwar
- Posts: 7
- Joined: Tue Dec 11, 2007 9:13 am
Calculated marker position from IK
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
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
- Alexander Kotschwar
- Posts: 7
- Joined: Tue Dec 11, 2007 9:13 am
RE: Calculated marker position from IK
Nothing at all?
- Anders Sandholm
- Posts: 30
- Joined: Thu Feb 22, 2007 1:53 pm
RE: Calculated marker position from IK
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
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
- Alexander Kotschwar
- Posts: 7
- Joined: Tue Dec 11, 2007 9:13 am
RE: Calculated marker position from IK
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
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
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
RE: Calculated marker position from IK
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
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
- Anders Sandholm
- Posts: 30
- Joined: Thu Feb 22, 2007 1:53 pm
RE: Calculated marker position from IK
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.
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.
- Moon Ki Jung
- Posts: 44
- Joined: Wed Oct 24, 2007 2:56 am
RE: Calculated marker position from IK
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
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
- Alexander Kotschwar
- Posts: 7
- Joined: Tue Dec 11, 2007 9:13 am
RE: Calculated marker position from IK
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
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
- Alexander Kotschwar
- Posts: 7
- Joined: Tue Dec 11, 2007 9:13 am
RE: Calculated marker position from IK
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.
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.
- Alexander Kotschwar
- Posts: 7
- Joined: Tue Dec 11, 2007 9:13 am
RE: Calculated marker position from IK
THANKS!
For pointing out the obvious - if I only had found that line in the xml file earlier.
Problem solved..
Sascha
For pointing out the obvious - if I only had found that line in the xml file earlier.
Problem solved..
Sascha