Display prescribed forces

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Charles David Sasportes
Posts: 15
Joined: Thu Jan 23, 2020 6:36 am

Display prescribed forces

Post by Charles David Sasportes » Wed Feb 26, 2020 2:24 am

Hello,

I successfully added a prescribed force to my model by adding the following code in the .osim file (Lumbar_C_4 from Lumbar spine model):

Code: Select all

<ForceSet name="forceset">
	<objects>
		<PrescribedForce name="prescribedForce">
			<isDisabled>false</isDisabled>
			<socket_frame>../../bodyset/lumbar1</socket_frame>
			<FunctionSet name="forceFunctions">
				<objects>
                					<Constant name="forceX">
                  						<value>50</value>
                					</Constant>
                					<Constant name="forceY">
                  						<value>0</value>
                					</Constant>
                					<Constant name="forceZ">
                  						<value>0</value>
                					</Constant>	
				</objects>
				<groups />
			</FunctionSet>
			<FunctionSet name="pointFunctions">
           				<objects>        		
          						<Constant name="pointX">
           							<value>0</value>
								</Constant>          			
                					<Constant name="pointY">
                  						<value>0</value>
                					</Constant>
                					<Constant name="pointZ">
                  						<value>0</value>
                					</Constant>
            			</objects>
            			<groups />
          			</FunctionSet>
		</PrescribedForce>
First off, I apologize for the horrible indentation. This code is the product of many copy-pasting trials. It seems to be working, when I run static optimization on the model for a flexion extension there is a noticeable difference in muscle activation.

My question is the following : is there a way to display this prescribed force that is embedded in the .osim file on the model ? I would like to make sure the point of application is correct and as plan to add forces it would be a lot easier to monitor. Right clicking in the GUI on the prescribed force and adjusting the "display" options does not seem to do anything.

Thanks in advance !

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Display prescribed forces

Post by Dimitar Stanev » Wed Feb 26, 2020 3:22 am

Hi Charles,

One possibility is create a .mot file that contains the values of the force, point and torque. Then, you can preview the force in the GUI (File -> Preview Experimental Data ...). This is similar to how you preview the ground reaction forces.

User avatar
Charles David Sasportes
Posts: 15
Joined: Thu Jan 23, 2020 6:36 am

Re: Display prescribed forces

Post by Charles David Sasportes » Wed Feb 26, 2020 4:51 am

Thanks for your quick response !

From there, I have two follow up questions :

- Do you recommend applying the force directly using a .mot file, by adding columns to the ground reaction file and matching them in GUI to the corresponding external force for inverse dynamics or static optimization, rather than declaring the prescribed force by editing the .osim model ?
- Is there a way to get the positions of the different bodies after applying a motion to the model ? For example, in my usecase I apply values to the flex_extension variable and my model leans forward and backward. Let's say I want to simulate the model also lifting a weight by applying a force on the hands, how can I get the successive positions of the hand to match those with the point to which I will apply my force in my .mot file ?

Thanks in advance

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Display prescribed forces

Post by Dimitar Stanev » Wed Feb 26, 2020 2:00 pm

1. You can apply the force either as an external force (.mot and .xml) or with the prescribed force. In the former case, you will also be able to visualize the force.

2. You can apply a force on a point in the body local frame. The point will be always the same in this frame, but in another frame (e.g., ground) it will be changing. There is an option where you specify how the coordinates of the point should be interpreted (e.g., local body frame or global ground frame).

User avatar
Charles David Sasportes
Posts: 15
Joined: Thu Jan 23, 2020 6:36 am

Re: Display prescribed forces

Post by Charles David Sasportes » Wed Mar 11, 2020 3:18 am

Thank you very much for your reply.

I have tried applying the force using a .mot file, the same way I apply ground forces. The results seem on par with what I got when I prescribed the force in the .osim model, which is great.

I still have an issue to see the force act on the body during the animation. I tried using the "Preview Experimental Data" tool, as well as the "associate motion data" tool to visualize the forces in action but I still have an issue. The point of application is stuck in the origin, and the force is not acting in the correct direction, nor changing direction when the object it is applied to does.

Here are a few screencaps of the situation. The force in the vertical direction should correspond to the ground reaction forces, and the other vector should be the external force.
scr 5.png
scr 5.png (24.55 KiB) Viewed 3095 times
scr 4.png
scr 4.png (63.04 KiB) Viewed 3095 times
scr 3.png
scr 3.png (14.53 KiB) Viewed 3095 times
scr 2.png
scr 2.png (17.32 KiB) Viewed 3095 times
also, here is the .mot file containing values of the forces (ground and external)
grd forces + ext tableau.png
grd forces + ext tableau.png (43.37 KiB) Viewed 3095 times
To recap the expected behavior, I want to apply a 50N force in the x direction on the lumbar1 of the model, to simulate an actuator placed on the back of a subject. The point should follow the lumbar1 and the force should be applied relative to its orientation (always in x in the lumbar1 referential)

Do you see something wrong with the way I defined the force ?

Thank you so much for your precious help

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Display prescribed forces

Post by Dimitar Stanev » Thu Mar 12, 2020 2:34 am

I see. When you load the experimental force, it does not know to which model to associate the force. Therefore, since it cannot find the lumbar1 body it assumes that it is at the origin. Typically, we express everything in ground frame and not in body local frame when visualizing forces to void this issue.

You can try to load a motion in your model. Then, right click on the motion file and select associate with the external force. I hope in this way it will work. If it is not working, then you have to transform the body local frame force into global reference frame ground.

User avatar
Charles David Sasportes
Posts: 15
Joined: Thu Jan 23, 2020 6:36 am

Re: Display prescribed forces

Post by Charles David Sasportes » Fri Mar 13, 2020 2:13 am

Hi, thanks for the response !

Does this differ from using the "associate motion data" command when right-clicking on the motion file? If not, I have tried and it did not seem to work either (I posted screencaps in my previous message, the "create/edit motion objects" window is my configuration for the external force).

Let's say I now want to express the force in the global frame to solve this. Is there a way to get a file containing the successive positions of every single body of the model at each timestamp, so I can make the application point of the force match the position of the lumbar1? Otherwise, it will really be a mess to generate the force file when my model is moving around.. do you have any tips for this ?

The thing that worries me is that, if the software does not recognize the lumbar1 as a body to display the force, how do I know it did not also mess up my results when applying the force to the body before running inverse dynamics/static optimization?

Thanks in advance

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

Re: Display prescribed forces

Post by Nicos Haralabidis » Fri Mar 13, 2020 11:24 am

Hi Charles,

As for figuring out the location to apply the force, you could place a marker at the Lumbar region you wish to apply the force, then perform a point kinematics analysis and choose to express that marker point in the ground frame. You could then copy these numbers into your force file under the point of application headings. This is for purely visualisation purposes though.

Cheers,

Nicos

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Display prescribed forces

Post by Dimitar Stanev » Fri Mar 13, 2020 11:30 am

You can also perform PointKinematics to track the point of interest in ground frame. You can combine the point and force and create the .mot files so that can visualize the force. The other way would be to step the model realize its position and compute the point of application in ground frame.

The lumbar1 is recognized well enough when there is a model associated with the force that you apply. When you preview the experimental data, no model is assumed. This, is how this GUI function was implemented and does not mean that the force is not applied properly.

https://simtk-confluence.stanford.edu/d ... h+Analyses

User avatar
Charles David Sasportes
Posts: 15
Joined: Thu Jan 23, 2020 6:36 am

Re: Display prescribed forces

Post by Charles David Sasportes » Mon Mar 23, 2020 8:30 am

Thanks for your response ! I tested the application of the force and indeed it works as expected !

POST REPLY