Obtaining reaction forces
- Adrian Lai
- Posts: 46
- Joined: Tue Mar 13, 2012 11:33 am
Obtaining reaction forces
Hi all,
I would like to get the reaction forces between two bodies at a weld joint using only the state values alone. The goal is to match the reaction forces with an external force through muscle force/activation alone.
I know I need to use the function calcEquivalentSpatialForce(states,mobility forces) but I'm unsure how to obtain the mobility forces without running an inverse dynamic analysis.
Can anyone point me in the right direction or an alternative methods to obtain a reaction force. I also tried using contact geometries but it didn't work because the joint of interest is a weld joint.
Thanks in advance!
Adrian
I would like to get the reaction forces between two bodies at a weld joint using only the state values alone. The goal is to match the reaction forces with an external force through muscle force/activation alone.
I know I need to use the function calcEquivalentSpatialForce(states,mobility forces) but I'm unsure how to obtain the mobility forces without running an inverse dynamic analysis.
Can anyone point me in the right direction or an alternative methods to obtain a reaction force. I also tried using contact geometries but it didn't work because the joint of interest is a weld joint.
Thanks in advance!
Adrian
- Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Re: Obtaining reaction forces
Hey Adrian:
Could you clarify what you mean by "only the state values alone" and "through muscle force/activation alone"? I'm not sure I understand the distinction you're making.
If you're using 4.0, you can use Joint::calcReactionOnParentExpressedInGround(), etc.: https://github.com/opensim-org/opensim- ... #L250-L270
I don't think you want to use Joint::calcEquivalentSpatialForce(). This will not give you the correct joint reaction forces, even if you provided the mobility forces generated by muscles (because you would not account for the path of the muscle).
Could you clarify what you mean by "only the state values alone" and "through muscle force/activation alone"? I'm not sure I understand the distinction you're making.
If you're using 4.0, you can use Joint::calcReactionOnParentExpressedInGround(), etc.: https://github.com/opensim-org/opensim- ... #L250-L270
I don't think you want to use Joint::calcEquivalentSpatialForce(). This will not give you the correct joint reaction forces, even if you provided the mobility forces generated by muscles (because you would not account for the path of the muscle).
- Adrian Lai
- Posts: 46
- Joined: Tue Mar 13, 2012 11:33 am
Re: Obtaining reaction forces
I'm currently running my own direct collocation code and harnessing the OpenSim API to do all my dynamics by giving it the states and controls I need to solve for and asking it for outputs such as computing state derivatives and calculating metabolic cost.Could you clarify what you mean by "only the state values alone" and "through muscle force/activation alone"? I'm not sure I understand the distinction you're making.
I'm currently prescribing an experimentally-measured external force at a fixed point directly into the model osim. I would like to instead, call the model and obtain a reaction force as a result of the states and controls I provide it and then match the reaction force to the experimental data via my optimisation. Hence, when I say through "muscle force/activation alone", I would imagine these states/controls are what drive the model to match a prescribed force in the equations of motion especially in the case, for example, when the kinematics (angles, angular velocities) are identical but an external force is and is not applied. A similar approach was recently done for foot ground contact models to track ground reaction forces during walking (see https://goo.gl/Bhq2QS).
I found this function in the documentation as well but I'm currently working in my OpenSim 3.3 environment because everything seems a bit more computationally efficient for my code. I have it written for 4.0 so I'll be migrating to it in the near future (maybe if it's the only way to solve my problem)If you're using 4.0, you can use Joint::calcReactionOnParentExpressedInGround(), etc.: https://github.com/opensim-org/opensim- ... #L250-L270
Thanks!
Adrian
- Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Re: Obtaining reaction forces
In 3.3 you may be able to use SimbodyEngine::computeReactions(): https://github.com/opensim-org/opensim- ... ine.h#L118
- Adrian Lai
- Posts: 46
- Joined: Tue Mar 13, 2012 11:33 am
Re: Obtaining reaction forces
How do you run simbody functions using the MATLAB API if I can't find it in the documentation?
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
- Adrian Lai
- Posts: 46
- Joined: Tue Mar 13, 2012 11:33 am
Re: Obtaining reaction forces
Thanks Tom! I'll let you know how it goes.
- Adrian Lai
- Posts: 46
- Joined: Tue Mar 13, 2012 11:33 am
Re: Obtaining reaction forces
Hi Chris and Tom,
I've tried the following code but my MATLAB crashes. Can you point me in the right direction?
Thanks!
I've tried the following code but my MATLAB crashes. Can you point me in the right direction?
Code: Select all
import org.opensim.modeling.*
model_name = 'test_model.osim';
osimModel = Model(model_name);
osimState = osimModel.initSystem();
no_joints = osimModel.getJointSet.getSize();
temp_vector = Vec3(1);
rForce = VectorOfVec3(no_joints,temp_vector);
rTorque = VectorOfVec3(no_joints,temp_vector);
tool = SimbodyEngine();
tool.computeReactions(osimState,rForce,rTorque);
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Obtaining reaction forces
You're creating a new SimbodyEngine that isn't connected to the Model. This should work:
Code: Select all
osimModel.getSimbodyEngine().computeReactions(osimState,rForce,rTorque);
- Adrian Lai
- Posts: 46
- Joined: Tue Mar 13, 2012 11:33 am
Re: Obtaining reaction forces
Thanks for the function Tom. It works and I can get reaction forces at all the joints.
However, I'm not sure if it's due to my computers (I've tried it on two computer so far), but after running the function once, the second time I run, it crashes my MATLAB. Sometimes when I reopen a new instance of MATLAB, MATLAB crashes again when running the function the first time.
Is it related to some type of memory leak? Any ideas on a solution?
Thanks! So close to a working solution.
Adrian
However, I'm not sure if it's due to my computers (I've tried it on two computer so far), but after running the function once, the second time I run
Code: Select all
osimModel.getSimbodyEngine().computeReactions(osimState,rForce,rTorque);
Is it related to some type of memory leak? Any ideas on a solution?
Thanks! So close to a working solution.
Adrian