JointReaction vs InverseDynamics

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Mohammadreza Rezaie
Posts: 366
Joined: Fri Nov 24, 2017 12:48 am

JointReaction vs InverseDynamics

Post by Mohammadreza Rezaie » Mon Feb 28, 2022 2:25 am

Dear Experts,
The JointReaction analysis calculates the resultant forces and moments the joint structure caries in response to all motions and forces in the model, including muscles, motors, and all other actuators.
Based on this statement from:
https://simtk-confluence.stanford.edu:8 ... seDynamics
I expect to get the same results compared with ID, If I remove all muscles and actuators in a model. But it is not.
This is Ankle moment from ID (red) and JRA (blue)
AnkleMoment.png
AnkleMoment.png (31.75 KiB) Viewed 958 times
The input data of JRA were IK output and the external load (GRF) file.

I was wondering If anyone could explain this difference as well as how to get joint moments from JRA, identical with ID.

Regards,
Mohammadreza

Tags:

User avatar
Jacob J. Banks
Posts: 88
Joined: Tue Jul 15, 2014 5:17 am

Re: JointReaction vs InverseDynamics

Post by Jacob J. Banks » Mon Mar 07, 2022 2:13 pm

Hmmm.... I've never tried this (because unclear why you would want to do it?), but I can see where it 'should' work. But to be honest, I've actually sort of always wondered what the JRA moments mean if you have Residual Actuators (how they are are not =0).

I have tried an equivalent, where I used JRA to get the reactive forces that the ID tool in OpenSim does not report... to do this, I just assigned 0 for all the muscle/actuator force inputs (via a custom_forces.sto file).

At any rate, do you have residual actuators? If so, they could taking up your joint moment... if not, try putting them in with a high optimal torques for each joint. Then at least _forces.sto file from SOpt should have equivalent moments (so not from JRA but from SOpt).
Jake Banks

User avatar
Mohammadreza Rezaie
Posts: 366
Joined: Fri Nov 24, 2017 12:48 am

Re: JointReaction vs InverseDynamics

Post by Mohammadreza Rezaie » Tue Mar 08, 2022 11:18 am

Dear Dr. Banks,

Thank you so much for your response. I'm already aware how to get joint moments from SOpt using actuators, identical with ID.
unclear why you would want to do it?
Exactly for this reason:
used JRA to get the reactive forces that the ID tool in OpenSim does not report
Please find the attached setup files. The model is simplified, no muscles and actuators and I only use IK output and external load file without any additional force set file (currently, I'm not interested in muscle analysis tools).

Would you please show me how JRA works in this manner? In all cases, the hip moments are zero and the moments for undefined coordinates (e.g knee adduction and knee internal rotation) are not similar to those when defined.

The ID tool already export 3D body forces and moments by adjusting <joints_to_report_body_forces> and <output_body_forces_file>. Is there similar thing for joint moment?

I would be grateful for your help.
MrR
Desktop.zip
(236.86 KiB) Downloaded 20 times

User avatar
Jacob J. Banks
Posts: 88
Joined: Tue Jul 15, 2014 5:17 am

Re: JointReaction vs InverseDynamics

Post by Jacob J. Banks » Tue Mar 15, 2022 3:23 pm

Sorry for not coming back to this forum (I got your email though!).
So, here is what I came up with (attached zip)... the subject_scale_walk_StaticOptimization_force.sto file should have your joint moments, then the _JointReaction_ReactionLoads.sto file should contain your reactive forces and the same moments (I just ran and looked at... I didn't confirm with any by hand calcs/logic).

The key to running this without muscles was to construct an actuator file using the 'createActuatorsFile.m' that comes with the OpenSim download (or at least it used to). When that creates a file, adjust all the optimal forces to be a large number (I made them 10,000), so that it has no issues solving the SOpt with those actuators. Then you can assign those actuators to the SOpt tool and solve. The torque actuators should give you your moments, just like in InvDyn. You could also just put these actuators into your original model and solve that way (i.e., built in, and not as reserve actuators).

Next, you assign the resulting _force.sto file to the JRA tool (see attached xml file that I modified to read this file) just like you would if you had muscles. This should result in your the reactive joint forces that are due to the external forces and segment inertia(s) (and also contain the aforementioned reactive moments).

Again, sorry for the delay!
Jake Banks
Attachments
JJB_Modify.zip
(558.1 KiB) Downloaded 13 times

User avatar
Mohammadreza Rezaie
Posts: 366
Joined: Fri Nov 24, 2017 12:48 am

Re: JointReaction vs InverseDynamics

Post by Mohammadreza Rezaie » Wed Mar 16, 2022 12:05 am

Dear Dr. Banks,

Thanks for your time and I deeply appreciate your response.

This method works well. Since the output of SOpt and ID is identical, I suggest to use inverse_dynamics.sto as the force file in JointReaction tool. But you need to rename the CoordinateActuators the same as ID output columns (e.g pelvis_tilt_moment, pelvis_tx_force and ...). It is much faster and convenient than using SOpt. In my case, both methods produce same results.

However, when I compare the hip moments (and others) from JRA and ID, I see the patterns are close but not identical and hence, this makes me doubt the validity of other moments that ID doesn't report (e.g knee adduction and rotation moments)
test.png
test.png (82.05 KiB) Viewed 700 times
Do you have any idea about this difference?

Kind regards,
Mohammadreza

User avatar
Jacob J. Banks
Posts: 88
Joined: Tue Jul 15, 2014 5:17 am

Re: JointReaction vs InverseDynamics

Post by Jacob J. Banks » Wed Mar 16, 2022 6:08 am

Interesting that they are a bit off, but not totally surprising. My 1-2 thoughts:
- I assume you filtered the kinematics (6Hz) for InvDyn? If not, that would be a big reason.
- I think when you run through JRA the kinetics/moments may be getting filtered, either that or the kinematics are getting filtered a 2nd time.
- did you (I) keep the residual actuator file in the JRA? Wonder if by keeping that there that that takes some of the moment (for whatever reason), so try running the JRA with/without the actuator file.

Differences aside, a few other thoughts... Your SOpt doesn't take too long (note, I am used to the our thoracolumbar spine model that has >600 MTAs, so my standard for SOpt speed is pretty low!), it may be worth not worrying about changing file structures/headers. Also, note that your 'back' joint will be solved via a Top-Down approach, while all your other joints are solved with a Bottom-Up (this would be consistent between InvDyn and JRA, so not a part of the observed differences). If you want to keep that consistent between all joints, you can easily switch your base joint to the trunk and your parent/child frame for the back joint. Finally, the beginning of your file does not have any GRFs, so the model may have a hard time (especially in SOpt) to 'fight gravity' and may require you increase the 'pelvis_ty' optimal force in the actuator files.

Otherwise, let me/us know what you figure out.
Jake Banks

User avatar
Mohammadreza Rezaie
Posts: 366
Joined: Fri Nov 24, 2017 12:48 am

Re: JointReaction vs InverseDynamics

Post by Mohammadreza Rezaie » Thu Mar 17, 2022 10:06 am

Hi,

I tested several things and there was no success. Manipulating the filtering and residual actuators couldn't fix the issue. (changing CoordinateActuator to TorqueActuator leads to identical SOpt output compared with body_forces_at_joints.sto)

There was also a strange behavior. The output of SOpt and inverse_dynamics.sto is always identical, even if I set 1 Nm for all CoordinateActuators, while I would expect to get the maximum moment of 1Nm based on optimal_force definition:
The maximum torque produced by this actuator when fully activated.

MrR

User avatar
Jacob J. Banks
Posts: 88
Joined: Tue Jul 15, 2014 5:17 am

Re: JointReaction vs InverseDynamics

Post by Jacob J. Banks » Mon Mar 21, 2022 8:32 am

viewtopicPhpbb.php?f=91&t=14336&p=41315&start=0&view=
Hmm... unsure what is going on with the mismatch, but the actuator max magnitude similarity is consistent with what the max actually is (see above forum exchange)... a force/moment per unit of activation. So the torques would be the same for 1Nm as it would be for 10k, but the activations would just be way higher (and they are set to Inf, I believe, so that isn't an issue).
I'll let you know if I think of anything else to try/think about in terms of the differences though.
Jake Banks

User avatar
Mohammadreza Rezaie
Posts: 366
Joined: Fri Nov 24, 2017 12:48 am

Re: JointReaction vs InverseDynamics

Post by Mohammadreza Rezaie » Mon Mar 21, 2022 4:06 pm

Dear Dr. Banks,

Thanks for the link. That behavior looks normal based on your explanations.

Any idea, guidance, and solution about the mismatch between JRA and ID (inverse_dynamics.sto) is much appreciated. I was thinking about the difference between joint/body frames. For example, in the Rajagopal model, the knee joint has been defined differently and the knee flexion is over X axis. But the counterpart moment in JRA is over Z axis which is the child frame (tibia). Using different frames (joint frame vs. child body frame) may cause this difference. But I'm not sure about it.

Kind regards,
MrR

User avatar
Jacob J. Banks
Posts: 88
Joined: Tue Jul 15, 2014 5:17 am

Re: JointReaction vs InverseDynamics

Post by Jacob J. Banks » Tue Mar 22, 2022 6:20 am

Hmmm... That is an interesting point. However, in the graph you showed, it was just ID vs JRA moments, so it was the exact same model, correct?
Even so, to maybe test if the 2 approaches are using different coordinate systems, look at the resultant moment from both (i.e., sqrt(Mx^2 + My^2 + Mz^2)? If that is the same (or closer to each other, as maybe the origin is slightly different too... which is probably unlikely), then your on the right track!
Jake Banks

POST REPLY