Joint Reaction Goal
- Burak Kula
- Posts: 31
- Joined: Wed Dec 04, 2019 3:34 pm
Joint Reaction Goal
Hello Everyone,
In my study, I want to minimize joint forces and moments. To do so I am using "MocoJointReactionGoal" function in MATLAB. But I have some problem regarding subfunctions of "MocoJointReactionGoal" which is called "setReactionMeasures()". In tutorial page of function "https://opensim-org.github.io/opensim-m ... _goal.html" it says "force-x","force-y","force-z","moment-x","moment-y","moment-z" can be minimized as it is desired.
When I run my below code,
% Joint Torque optimization
jointCost=MocoJointReactionGoal();
problem.addGoal(jointCost);
jointCost.setName("tibiofemoral_compressive_force");
jointCost.setJointPath("/jointset/knee_l");
jointCost.setLoadsFrame("child");
jointCost.setExpressedInFramePath("/bodyset/tibia_l");
jointCost.setReactionMeasures("force-x");
I am facing with below error,
Check for missing argument or incorrect argument data type in call to function 'setReactionMeasures'.
How can I correct this argument error in my code? What should I give this function as input? or Which type of data should I give ??
Best Regards,
Burak.
In my study, I want to minimize joint forces and moments. To do so I am using "MocoJointReactionGoal" function in MATLAB. But I have some problem regarding subfunctions of "MocoJointReactionGoal" which is called "setReactionMeasures()". In tutorial page of function "https://opensim-org.github.io/opensim-m ... _goal.html" it says "force-x","force-y","force-z","moment-x","moment-y","moment-z" can be minimized as it is desired.
When I run my below code,
% Joint Torque optimization
jointCost=MocoJointReactionGoal();
problem.addGoal(jointCost);
jointCost.setName("tibiofemoral_compressive_force");
jointCost.setJointPath("/jointset/knee_l");
jointCost.setLoadsFrame("child");
jointCost.setExpressedInFramePath("/bodyset/tibia_l");
jointCost.setReactionMeasures("force-x");
I am facing with below error,
Check for missing argument or incorrect argument data type in call to function 'setReactionMeasures'.
How can I correct this argument error in my code? What should I give this function as input? or Which type of data should I give ??
Best Regards,
Burak.
- Carlos Gonçalves
- Posts: 139
- Joined: Wed Jun 08, 2016 4:56 am
Re: Joint Reaction Goal
Hello Burka,
The method "setReactionMeasures()" receives a list as an argument.
I Python it would be something like this: jointCost.setReactionMeasures(["force-x"]). It should be very similar in MATLAB.
Best regards.
Carlos
The method "setReactionMeasures()" receives a list as an argument.
I Python it would be something like this: jointCost.setReactionMeasures(["force-x"]). It should be very similar in MATLAB.
Best regards.
Carlos
- Burak Kula
- Posts: 31
- Joined: Wed Dec 04, 2019 3:34 pm
Re: Joint Reaction Goal
Hello Carlos,
I am appreciated for your help, but when I try your method unfortunately I got same error.
Check for missing argument or incorrect argument data type in call to function 'setReactionMeasures'.
Also there was a warning for syntax of "jointCost.setReactionMeasures(["force-x"])." It said that in order to specify the argument I must use parenthesis instead of brackets.
I am starting thinking about Moco does not know "force-x, force-y, force-z, moment-x, moment-y, moment-z" . Shall I identify them first in MATLAB or osim file ?
I am appreciated for your help, but when I try your method unfortunately I got same error.
Check for missing argument or incorrect argument data type in call to function 'setReactionMeasures'.
Also there was a warning for syntax of "jointCost.setReactionMeasures(["force-x"])." It said that in order to specify the argument I must use parenthesis instead of brackets.
I am starting thinking about Moco does not know "force-x, force-y, force-z, moment-x, moment-y, moment-z" . Shall I identify them first in MATLAB or osim file ?
- Carlos Gonçalves
- Posts: 139
- Joined: Wed Jun 08, 2016 4:56 am
Re: Joint Reaction Goal
Hello Burka,
You need to find out how the lists are used in MATLAB.
For example, in C++ the syntax is: cost->setReactionMeasures({"force-y"});
The command that I sent previously would only run in Python ( jointCost.setReactionMeasures(["force-x"]) ).
Since the function argument is not a list, the compiler (interpreter) is failing.
I used this Goal before in multiple ways, without argument, or with a list argument with multiple options.
Best regards.
Carlos
You need to find out how the lists are used in MATLAB.
For example, in C++ the syntax is: cost->setReactionMeasures({"force-y"});
The command that I sent previously would only run in Python ( jointCost.setReactionMeasures(["force-x"]) ).
Since the function argument is not a list, the compiler (interpreter) is failing.
I used this Goal before in multiple ways, without argument, or with a list argument with multiple options.
Best regards.
Carlos
- Nicholas Bianco
- Posts: 1057
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Joint Reaction Goal
Hi Burak,
setReactionMeasures() takes a list of strings as Carlos mentioned, and C++ the type is std::vector<std::string>. In MATLAB you can use StdVectorString to provide string lists of this type:
Best,
-Nick
setReactionMeasures() takes a list of strings as Carlos mentioned, and C++ the type is std::vector<std::string>. In MATLAB you can use StdVectorString to provide string lists of this type:
Code: Select all
% Joint Torque optimization
jointCost=MocoJointReactionGoal();
problem.addGoal(jointCost);
jointCost.setName("tibiofemoral_compressive_force");
jointCost.setJointPath("/jointset/knee_l");
jointCost.setLoadsFrame("child");
jointCost.setExpressedInFramePath("/bodyset/tibia_l");
measures = StdVectorString();
measures.append("force-x");
jointCost.setReactionMeasures(measures);
-Nick
- Burak Kula
- Posts: 31
- Joined: Wed Dec 04, 2019 3:34 pm
Re: Joint Reaction Goal
Hello Carlos and Nicholas,
Firstly I want to thank you for your help and quick response.
@Nicholas,
When I tried your suggestion, I had below error in attachment.
Do you have any more ideas ?
Firstly I want to thank you for your help and quick response.
@Nicholas,
When I tried your suggestion, I had below error in attachment.
Do you have any more ideas ?
- Attachments
-
- er.PNG (18.32 KiB) Viewed 996 times
- Nicholas Bianco
- Posts: 1057
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Joint Reaction Goal
Hi Burak,
Apologies, use add(), not append(), for StdVectorString.
-Nick
Apologies, use add(), not append(), for StdVectorString.
-Nick
- Burak Kula
- Posts: 31
- Joined: Wed Dec 04, 2019 3:34 pm
Re: Joint Reaction Goal
Hello Nicholas,
Firstly, I want to thank you for your help.
I have another question. When I use "force-x" term, can Moco know this is a force in x-direction ? or is for "force-x" defined before in Moco or in any XML file?
Best Regards,
Burak.
Firstly, I want to thank you for your help.
I have another question. When I use "force-x" term, can Moco know this is a force in x-direction ? or is for "force-x" defined before in Moco or in any XML file?
Best Regards,
Burak.
- Nicholas Bianco
- Posts: 1057
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Joint Reaction Goal
Hi Burak,
When you specify "force-x", you are say to minimize the component of the reaction force in the x-direction as defined by the joint. So it depends on how your joint is oriented in the model. A quick way to check is to load your model in the OpenSim GUI, go to the joint in the Navigator, right-click and select "Toggle Parent Frame" or "Toggle Child Frame" to show the joint axes. The axes colors red/green/blue correspond to x/y/z.
-Nick
When you specify "force-x", you are say to minimize the component of the reaction force in the x-direction as defined by the joint. So it depends on how your joint is oriented in the model. A quick way to check is to load your model in the OpenSim GUI, go to the joint in the Navigator, right-click and select "Toggle Parent Frame" or "Toggle Child Frame" to show the joint axes. The axes colors red/green/blue correspond to x/y/z.
-Nick