Forums Anyscript.org  

Go Back   Forums Anyscript.org > Professional Forum > AnyGait

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2017, 03:55 PM
robin_layton robin_layton is offline
Junior Member
 
Join Date: Nov 2016
Posts: 8
Default AnyPyTools macro

Hi,

I am having an issue when running a macro from anypytools on python. I am aiming to run the kinematics and inverse dynamics as well as dumping some hip reaction force data. The script runs but only returns one value for the hip reaction force. See code below.

Code:
from anypytools.abcutils import AnyPyProcess 
app = AnyPyProcess()

macrolist = [['load "MoCap_LowerBody.main.any" -def MotionAndParameterOptimizationModel="1" -def InverseDynamicModel="0"',
              'operation Main.RunMotionAndParameterOptimizationSequence',
              'run',
              'exit'],
             ['load "MoCap_LowerBody.main.any" -def MotionAndParameterOptimizationModel="0" -def InverseDynamicModel="1"',
              'operation Main.Studies.InverseDynamicStudy.InverseDynamics',
              'run',
              'classoperation Main.Studies.HumanModel.BodyModel.SelectedOutput.Right.Leg.JointReactionForce.Hip_MediolateralForce "Dump"',
              'exit']]
app.start_macro(macrolist);
I believe this could be because the model exits before running the inverse dynamics, therefore returning a value for a stationary body? I have tried to adapt the script but with no success.

Any advice on how to overcome this would be much appreciated.

Kind regards,
Robin
Reply With Quote
  #2  
Old 05-10-2017, 08:49 AM
melund2 melund2 is offline
Member
 
Join Date: Aug 2009
Posts: 69
Default

Hi Robin

To get more values, you need to dump the content of the variables below the study output folder. 'Main.Studies.InverseDynamicStudy.Output' The Output folder is the structure that collects the data from all time steps.

Thus, the dump class operation would look like this:
'classoperation Main.Studies.InverseDynamicStudy.Output.BodyModel. SelectedOutput.Right.Leg.JointReactionForce.Hip_Me diolateralForce "Dump"',

Also, keep in mind that you need to run 'ParameterOptimization' before the inverse dynamic study. In your case, where the macros are split into two, AnyPyTools may run them in parallel.
Reply With Quote
  #3  
Old 05-10-2017, 04:23 PM
robin_layton robin_layton is offline
Junior Member
 
Join Date: Nov 2016
Posts: 8
Default

Thank you very much for the fast reply. I have made the suggested changes and the script is now running fine.

I have a second question regarding output data. I put the following code into the inverse dynamics of my main model. I aim to save a number of variables directly into text files, however although the model runs fine, no text file is saved as far as I can see. Apologies if this is a relatively simple question.

Code:
AnyOutputFile test =
{
FileName = "test.csv";

AnyFloat Hip= Main.Studies.HumanModel.BodyModel.SelectedOutput.Right.Leg.JointReactionForce.Hip_MediolateralForce;
};
Kind regards,
Robin
Reply With Quote
  #4  
Old 05-11-2017, 02:38 PM
melund2 melund2 is offline
Member
 
Join Date: Aug 2009
Posts: 69
Default

Hi Robin

The code looks correct to me. Think the issue happens because the AnyOutputFile object is somehow not included in the study that you run.

It should either live directly in the study or the study should have a reference to it.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:08 PM.