Page 1 of 1
Computing torque due to gravity only
Posted: Thu Nov 21, 2013 6:41 pm
by dustpack
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
Re: Computing torque due to gravity only
Posted: Thu Nov 21, 2013 7:52 pm
by sherm
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
. 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