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
Computing torque due to gravity only
- Michael Sherman
- Posts: 807
- Joined: Fri Apr 01, 2005 6:05 pm
Re: Computing torque due to gravity only
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
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;
Regards,
Sherm