Page 1 of 1

Prescribed coordinate not working:

Posted: Mon Mar 30, 2020 11:27 am
by mlaudu
Hi,
My model has several degrees of freedom and I prescribed one of the generalized coordinates and saved the model. The section of the model file displaying information on that coordinate is shown below:

Code: Select all

<coordinates>
	<Coordinate name="walkerToGround_coord_0">
		<!--The value of this coordinate before any value has been set. Rotational coordinate value is in radians and Translational in meters.-->
		<default_value>0</default_value>
		<!--The speed value of this coordinate before any value has been set. Rotational coordinate value is in rad/s and Translational in m/s.-->
		<default_speed_value>0</default_speed_value>
		<!--The minimum and maximum values that the coordinate can range between. Rotational coordinate range in radians and Translational in meters.-->
		<range>-5 5</range>
		<!--Flag indicating whether or not the values of the coordinates should be constrained to the current (e.g. default) value, above.-->
		<locked>false</locked>
		<!--If specified, the coordinate can be prescribed by a function of time. It can be any OpenSim Function with valid second order derivatives.-->
		<prescribed_function>
			<SimmSpline>
				<x> 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1</x>
				<y> 0 0.0075 0.0175 0.0325 0.05 0.065 0.0825 0.095 0.1 0.1 0.1</y>
			</SimmSpline>
		</prescribed_function>
		<!--Flag indicating whether or not the values of the coordinates should be prescribed according to the function above. It is ignored if the no prescribed function is specified.-->
		<prescribed>true</prescribed>
	</Coordinate>
</coordinates>
After integrating the model I realized that the coordinate does not follow the prescribed path prescribed for it above. Am I missing something else in doing this? I note that neither OpenSim documentation nor any previous forum posting contains any successful example of prescribing generalized coordinates in this way.
Thanks.
Musa

Re: Prescribed coordinate not working:

Posted: Mon Mar 30, 2020 11:55 am
by chrisdembia
Your model snippet looks correct. How are you integrating your model?

Re: Prescribed coordinate not working:

Posted: Mon Mar 30, 2020 12:54 pm
by mlaudu
Thanks Chris. Below is the snippet of code immediately the model is fully defined:

Code: Select all

// Define the integrator and its options
SimTK::RungeKuttaMersonIntegrator integrator(osimModel.getMultibodySystem());

initialTime = 0.0;
finalTime = 1.0;
stepSize = 0.1;
TINY_TIME = 1.0e-6;

Manager manager(osimModel);
manager.setIntegratorAccuracy(1.0e-4);
manager.initialize(si);

/* Integrate the equations of motion forward */
t = initialTime;
si.setTime(t);
manager.integrate(finalTime);
Should I have done something else before this?
Thanks.
Musa

Re: Prescribed coordinate not working:

Posted: Mon Mar 30, 2020 1:13 pm
by chrisdembia
Hey, Musa.

That integration code looks fine. How big is the error in the trajectory of the coordinate?

Are there any other constraints on this function?

In general, the prescribed motion works fine.

Consider trying this on an even simpler model, such as a point mass.

Re: Prescribed coordinate not working:

Posted: Mon Nov 29, 2021 8:19 pm
by sjk123
Hello, when I use the Prescribed_Function and click the simulation button, I will always exit OpenSim software automatically. Can you tell me the reason and look forward to your reply