Computing torque due to gravity only

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Dustin Crouch
Posts: 5
Joined: Tue Jan 05, 2010 11:56 am

Computing torque due to gravity only

Post by Dustin Crouch » Thu Nov 21, 2013 6:41 pm

Hi,

Does anyone know of a SimTK or OpenSim class that computes joint torques due to gravity only? I'd like to compute the torques during a forward simulation. I could think of some work-arounds but I thought I'd ask first. Thanks!

Dustin

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

Re: Computing torque due to gravity only

Post by Michael Sherman » Thu Nov 21, 2013 7:52 pm

Hi, Dustin. Here is a way you can do it if you are working in C++ with OpenSim 3.1 and Simbody 3.1. It takes a few steps (somewhat easier in the next release):
Call the Model's getGravityForce() method which returns a reference to a SimTK::Force::Gravity element. That has a method getBodyForce(), doxygen is here. You call getBodyForce() once for each body, accumulating them into a stacked vector of 6-vectors, type

Code: Select all

SimTK::Vector_<SpatialVec> F;
. That gives you body forces and torques (torques because the forces act at the body origin rather than COM). Then if you want to convert those to an equivalent set of generalized forces (by computing Vector f=J^T*F), use the SimbodyMatterSubsystem's multiplyBySystemJacobianTranspose() method here.

Regards,
Sherm

POST REPLY