Inverse Dynamics

SimTKcore exists as a separate project to provide 'one stop shopping' for SimTK Core software and support, although the software is actually developed as a set of interdependent projects. SimTK 1.0 was released in March 2008, SimTK 2.0 in December, 2009.
User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

Inverse Dynamics

Post by Jean-Olivier Racine » Wed Nov 19, 2008 12:38 pm

Hi,

I would like to use SimTKCore to do Inverse Dynamics simulations. I red most of the User Guide, and although the term is mentioned, there's no concrete reference to it. In fact, the most relevant information I've found is about an operator, calcMa, which I cannot find in the Doxygen documentation (I looked at the SimbodyMatterSubsystem class and searched though the class members).

I also looked at examples (and Updated ones) and did not find any that would do Inverse Dynamics.

Where should I look for documentation/examples of Inverse Dynamics using SimTKCore?

Thanks!

User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Thu Nov 20, 2008 6:24 am

Hello? You we're so quick at answering my other post that now I'm scared you missed this one! :)

User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Thu Nov 20, 2008 10:30 am

Doing some more research, I came up with an idea, but I am unsure if this is how it should be done and will that be efficient, computation wise:

Considering that inverse dynamics normally implies "known kinematics" and "unknown force", I figured I could create an event handler, that would update the state of each body with their position at each simulation step, and let SimBody come up with the rest. Yet, I am unsure how to get the forces from the "joints" without a calcMa() method....

User avatar
Michael Sherman
Posts: 807
Joined: Fri Apr 01, 2005 6:05 pm

RE: Inverse Dynamics

Post by Michael Sherman » Thu Nov 20, 2008 12:21 pm

Hi, Jean-Olivier.

Sorry for the delayed response. I am just returning to Stanford next week after an extended absence. Adding direct support in Simbody for inverse dynamics will be one of my top priorities on return, so calcMa() will be there in the next release.

There are a number of workarounds you can use now. Depending on your performance requirements, patience, expertise, and level of motivation these may be good enough for a while:
(1) You can use the calcMInverseV() method to obtain M^-1 explicitly. Invert that to get M. Now you can calculate f=M*a directly for any given a, provided you can write your desired accelerations as accelerations of the mobilities (joint axes).
(2) You can write prescribed motion constraints and apply one at each mobility in the system. Then the constraint solver will calculate the joint forces necessary to cause the prescribed motion.

With method (2) you could just run an ordinary simulation with an integrator. The system would move as you prescribe, and you can extract the time series of mobility forces either from the mobilizer reactions or from the constraints directly.

Do either of those approaches sound feasible to you?

Also, for creating the Simbody inverse dynamics facility to be most useful, I would be interested in knowing what would be the most convenient form for you to supply the motion data and extract the forces. Please let me know -- this is the ideal time for you to have an influence in how it comes out!

Best regards,
Sherm
(Michael Sherman)


User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Thu Nov 20, 2008 2:35 pm

Thank you very much for your answer Michael.

It seems I am lucky with my timings and I will be quite happy to answer any questions regarding what we need or hope to have.

Before I get into our needs, I just want to make sure I understand the two options properly:

1) using calcMInverse()

step a) I create an event handler that applies to the Stage::Position stage, that calls setU or setQ at each "frame" with the value I want my mobilizer to be.

step b) I create an event observer that applies to Stage::Dynamics, then, for each "frame" I call calcMInverse to get the F, through inversion of the given M matrix, multiplied by the acceleration matrix (calcQDotDot).


2) using Constraint::PrescribedMotion

step a) I write constraint that specifies, for each value of t, the mobilizer's degree(s) of freedom's value (vector of Qs).

step b) I use either a combination of calcConstraintForcesFromMultipliers() and getMultipliersAsVector() from the Constraint class, or use calcMobilizerReactionForces() from the SimbodyMatterSubsystem class. These two would be called after the integrator is done doing its magic.

Am I right? Am I understanding what you are saying correctly?

I really appreciate you taking the time to answer my questions. So let me explain a bit what we'd like to do:

We would like to do musculo-skeletal analysis, using inverse dynamics. We generally have motion capture data available and would like to calculate the generalized forces (forces and torques) at each joint. We normally receive data in two possible formats:
1. Positions of body landmarks (which would correspond to station in SimBody)
2. Orientations of segments (which could probably be seen as ModilizedBody::Balls).

We would like to be able to do two types of analysis:
Offline: we know all positions in advance and haven them available in memory.
Online: we calculate inverse dynamics as data comes in, potentially giving results late if processing is slower than data input, or in real-time, if simulation is faster or equal to data.

It seems that your first method would better apply to online analysis, while the second one would apply better to offline analysis.

My main concern is in respect to the performance of the second option, since this might mean there would be quite a few constraint in the system.

Thanks yet again, and sorry for the lengthy message.

User avatar
Peter Eastman
Posts: 2588
Joined: Thu Aug 09, 2007 1:25 pm

RE: Inverse Dynamics

Post by Peter Eastman » Thu Nov 20, 2008 3:42 pm

If I understand correctly, in the first method you wouldn't even be running a simulation. That is, no Integrator or TimeStepper would be involved. You would already know the sequence of positions and velocities from your motion capture data. So for each frame of data, you would simply call setQ() and setU() (or other equivalent methods) on the state, realize it, and then call the necessary methods to construct the mass matrix.

Peter

User avatar
Michael Sherman
Posts: 807
Joined: Fri Apr 01, 2005 6:05 pm

RE: Inverse Dynamics

Post by Michael Sherman » Thu Nov 20, 2008 8:57 pm

Yes, that's right.

Jean-Olivier, I'm sure you know this already but just in case I want to remind you that inverse dynamics requires specifying desired *accelerations* -- positions and velocities aren't enough. Positions q allow you to calculate the mass matrix M(q), velocities allow for computation of the coriolis terms of the accelerations, but then you still have to say what accelerations you want to produce.

Sherm

User avatar
Michael Sherman
Posts: 807
Joined: Fri Apr 01, 2005 6:05 pm

RE: Inverse Dynamics

Post by Michael Sherman » Thu Nov 20, 2008 9:00 pm

Thanks for the information about your intended use of inverse dynamics. Would you please clarify for me where you get your acceleration data?

Regards,
Sherm

User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Fri Nov 21, 2008 8:15 am

Yes, you are right, this would be an option. ALthough we could also do it using a TimeStepper and an Event Handler, I believe. But I'm not sure there would be a gain.

User avatar
Jean-Olivier Racine
Posts: 15
Joined: Fri Sep 19, 2008 7:48 am

RE: Inverse Dynamics

Post by Jean-Olivier Racine » Fri Nov 21, 2008 8:21 am

Thanks for underlining this fact.

There are two different cases of kinematic data:
1. From position based sensors
2. From inertial based sensors

In the first case, I am unsure how it would be done in the "online" solution to be honest. Maybe some numerical differentiation based on some interpolation/approximation of the next point based on previous positions? Experimentation would be needed.

In the second case, these would be obtained almost directly. Although I believe that the accelerations that SimBody requires or uDots, which means that some projections or transformations would be required so they would be given in the correct orientation. In this case, the speed and positions are calculated through a combination of a double integration and some filtering algorithm (Kalman filter to be precise).

I've come up with an idea, I think, of how I would expect SimBody to treat (interface wise) Inverse Dynamics. I`ll explain it in a separate post.

POST REPLY