API tips and tricks
Posted: Mon Aug 09, 2010 1:01 am
Hello everyone,
I have been using OpenSim's API for a little while now, and it is great for performing analyses not based on motion capture data. However understanding the operation of the low level functions is sometimes challenging. I have a few questions on making life easier with the API, and thought I would combine it into a single thread. Here are a few questions:
1) Is there a function which returns the coordinate indices of the generalized coordinates only? At the moment I implement a loop which goes through every coordinate, and record its index if its 'isConstrained()' is false.
2) Is there a function for calculating the torque at the joints required to statically oppose gravity? (i.e no external forces, velocity or accelerations)? In robotics this is usually referred to as the gravity or 'g' vector, and is a function of the generalized coordinates.
3) Similar to the previous question, is there a function that calculates the joint torque required to statically oppose external forces on the model? (not taking into account gravity or dynamics)
4) Is there a simple way of performing static optimization on a single model pose via API, not using a mot file? I have asked this in another thread (https://simtk.org/forum/message.php?msg_id=3697) but I thought I may as well ask again here.
5) Is there a way of quickly extracting the Jacobian from the model in a current pose? I noticed there are some "formJacobian" functions in the SimbodyEngine class, can these be used for this?
6) Is there a sneaky way of performing an analysis which is typically done using a mot or sto file, but using a single (or a small number) of states I define in my code? If so then this might be able to solve some of these questions. For example, I could perform an ID analysis on two identical states, and because there is zero displacement between the two then that essentially would solve question (2) if there are no external forces, or solve question (3) if I set gravity to zero. If this is possible then how can it be done without using a mot or sto file? (maybe a solution is to load the states into a Storage class and have the analysis read it from there? Can this be done?)
I have many questions but I think that's enough for now I think using OpenSim through the API is a very powerful tool. If anyone could help me with these questions it would greatly help me and I am sure help a lot of others. Also if anyone else has any other questions they would like to ask the OpenSim community regarding API tips then I would encourage them to add to this thread
Thanks in advance
Marc
I have been using OpenSim's API for a little while now, and it is great for performing analyses not based on motion capture data. However understanding the operation of the low level functions is sometimes challenging. I have a few questions on making life easier with the API, and thought I would combine it into a single thread. Here are a few questions:
1) Is there a function which returns the coordinate indices of the generalized coordinates only? At the moment I implement a loop which goes through every coordinate, and record its index if its 'isConstrained()' is false.
2) Is there a function for calculating the torque at the joints required to statically oppose gravity? (i.e no external forces, velocity or accelerations)? In robotics this is usually referred to as the gravity or 'g' vector, and is a function of the generalized coordinates.
3) Similar to the previous question, is there a function that calculates the joint torque required to statically oppose external forces on the model? (not taking into account gravity or dynamics)
4) Is there a simple way of performing static optimization on a single model pose via API, not using a mot file? I have asked this in another thread (https://simtk.org/forum/message.php?msg_id=3697) but I thought I may as well ask again here.
5) Is there a way of quickly extracting the Jacobian from the model in a current pose? I noticed there are some "formJacobian" functions in the SimbodyEngine class, can these be used for this?
6) Is there a sneaky way of performing an analysis which is typically done using a mot or sto file, but using a single (or a small number) of states I define in my code? If so then this might be able to solve some of these questions. For example, I could perform an ID analysis on two identical states, and because there is zero displacement between the two then that essentially would solve question (2) if there are no external forces, or solve question (3) if I set gravity to zero. If this is possible then how can it be done without using a mot or sto file? (maybe a solution is to load the states into a Storage class and have the analysis read it from there? Can this be done?)
I have many questions but I think that's enough for now I think using OpenSim through the API is a very powerful tool. If anyone could help me with these questions it would greatly help me and I am sure help a lot of others. Also if anyone else has any other questions they would like to ask the OpenSim community regarding API tips then I would encourage them to add to this thread
Thanks in advance
Marc