calcResidualForceIgnoringConstraints() inputs

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

calcResidualForceIgnoringConstraints() inputs

Post by Nicos Haralabidis » Mon Nov 19, 2018 8:47 am

Hi everybody,

My model has 37 DOFs actuated by 31 coordinate actuators, 3 torque actuators and 3 point actuators (the latter 6 are residual actuators at the pelvis) and is made up of 21 rigid bodies.

I am currently trying to get my head around the inputs appliedMobilityForces and appliedBodyForces for calcResidualForceIgnoringConstraints().

I believe I am extracting the necessary MobilityForces and BodyForces after I have updated the controller for each actuator by doing the following:

Code: Select all

myModel.updMultibodySystem().realize(myState, Stage::Dynamics);
const Vector_<SpatialVec>& rigidBFs = myModel.getMultibodySystem().getRigidBodyForces(myState, Stage::Dynamics);
const Vector mfs = myModel.getMultibodySystem().getMobilityForces(myState, Stage::Dynamics);
However, when I print to screen the mobilityforces for the first 6 mobilities they are all 0 and the remaining 31 mobilities are the value I would expect based upon the control value and optimal force.

If I do the following:

Code: Select all

double fx = myModel.getActuators().get("FX").getForce(myState);
double knee_r = myModel.getActuators().get("knee_angle_r").getForce(myState);
I then receive the expected (generalised force) for the FX point actuator and knee_angle_r coordinate actuator (this value matches the value in the mfs vector).

Please could someone clarify why I am receiving this mismatch?

Kind regards,

Nicos Haralabidis

Tags:

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: calcResidualForceIgnoringConstraints() inputs

Post by Christopher Dembia » Mon Nov 19, 2018 11:16 am

The point actuator, for example, adds forces to the body forces, not the mobility forces. See https://github.com/opensim-org/opensim- ... r.cpp#L184

Check the body forces for your first body.

User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

Re: calcResidualForceIgnoringConstraints() inputs

Post by Nicos Haralabidis » Mon Nov 19, 2018 3:27 pm

Hello Chris,

Thank you for your quick reply.

Thanks for sharing the link, it definitely confirms that the point actuator forces get added to the set of rigid body forces. I checked the applyTorque.cpp and that seems to be doing the same.

I extracted the rigid body forces as you suggested for the first body - which I now realize is the 'ground', ~[-15,-15,-15],~[0,0,0]... for the second body, the pelvis, I receive [14.9299,15.9617,22.2021],~[15,-111.239,15]...which makes now makes sense...especially for the rigid body forces!

Thanks!

Nicos

POST REPLY