AnyPyTools - ERROR(OBJ1)


I am working with AnyPyTools and TkInter. I am trying to calculate the model and print with matplotlib in a GUI. GUI is working but I am getting strange errors depending on my macro in AnyPyTools. Like in this Topic: Changing the TrailFileName with AnyPy Tools I try to load a C3D File from my PC. I already changed my TrialSpecificData_FullBody.any:

  #define TRIAL_FILE_NAME "C006_20170724_29.c3d"
  TrialFileName = TRIAL_FILE_NAME;

But if I run in python with following macrolist:

        macrolist = [
            Load('UpperLimb.any', paths={"TRIAL_FILE_NAME": self.open_files()}),
            # Load('UpperLimb.any'),

gives me following errors:

ERROR(OBJ1) :   C:\Users\biolab\Documents\AnyBody.7.2.x\AMMR.v2.2.3_Steinfeld\Tools\AnyMocap\InterpolateJointAngleData.any(56)  :   'AnyMoCap_msg2'  :  
                                 No valid kinematic joint angle data available.
                         Please run the Marker Tracking analysis first (or Main.RunAnalysis)

Running only Load('UpperLimb.any') without paths gives me

Failed (i=0) : 239.5 sec : mocapexamples-plug-in-gait_simple-0_(3jrlveqm).txt
100%|████████████████████████████████████████████████████████████████████████████| 1/1 [03:59<00:00, 239.60s/it]
Completed: 0, Failed: 1

But it still prints the needed output.
Here are 2 Files from output. (9.1 KB)

And there is another Error I get after few Analysis with AnyPyTools:

Constructing model tree...
Linking identifiers...
Evaluating constants...
Fatal Python error: init_sys_streams: can't initialize sys standard streams
ValueError: Cannot open console output buffer for reading

Current thread 0x00002c4c (most recent call first):

ERROR: AnyPyTools : anybodycon.exe exited unexpectedly. Return code: 3

I do nothing in code and only update anypytools in terminal and it's working again. How is that possible? I had that error quite often. So if I get and init_sys_streams error I just update anypytools again and it works.

It seems I found one of possibilities.
For example Main.Studies.InverseDynamicStudy.Output.MaxMuscleActivity is stored as:

{0.15236323, 0.15223458, 0.15210497, 0.1519744 , 0.15184267,
          0.15170952, 0.15157474, 0.15143809, 0.15129938, ... };

and can be readed and printed. But the position of GlenoHumeralAbduction which is saved as Main.Studies.InverseDynamicStudy.Output.BodyModel.Right.ShoulderArm.Jnt.ClaviculaProtractionDriver.ClaviculaProtractionRhythm.HumerusElevation.Pos is stored as

{{1.6426891970455255}, {1.646243926329195}, {1.6497787233362129}, {1.6532941019894791}, {1.6567890795720559}, {1.6602626494798451}, {1.6637137893007092},...}

It may be my fault and I am asking the wrong path for the position.
I am happy to hear any answer/suggestion :slight_smile:

Hi Irzigen,

The first error "No valid joint data..." is most likely because the files names of the output files are not unique. Please this post from yesterday on the same issue:

So you need to ensure file names are unique.

The second problem ... that the analysis goes through but is listed as an error is because there is indeed an error. If you look at the output file you will see that it can not find an .anyset file. This would happen if you did not run a parameter optimization first which would create this file.

The last error with the "init_sys_streams" error I do not have a good idea about, do your model use python hooks?

Concerning your last post this is not a problem the data dump will have different formats depending on the nature of the data, so this is correct and not a problem.

Best regards

Thanks for the tipp. I am controllilng in my GUI now if anyset exists or not :slight_smile:

I am using this imports:

import tkinter as tk
from tkinter import Menu, filedialog, messagebox
import os.path, pathlib, sys
from anypytools import AnyPyProcess
from anypytools.macro_commands import Load, Dump, OperationRun
import matplotlib.pyplot as plt

I don't know how to recreate that error. It appear kinda unstable. I just need to update or install again and after that it's working:

(base) C:\Users\biolab\Documents\AnyBody.7.2.x\AMMR.v2.2.3_Steinfeld\Application\MocapExamples\Plug-in-gait_Simple> cd c:\Users\biolab\Documents\AnyBody.7.2.x\AMMR.v2.2.3_Steinfeld\Application\MocapExamples\Plug-in-gait_Simple && cmd /C "C:\Users\biolab\anaconda3\python.exe c:\Users\biolab\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\lib\python\debugpy\launcher 57395 -- c:\Users\biolab\Documents\AnyBody.7.2.x\AMMR.v2.2.3_Steinfeld\Application\MocapExamples\Plug-in-gait_Simple\ "
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00,  1.22s/it]
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\biolab\anaconda3\lib\tkinter\", line 1705, in __call__
    return self.func(*args)
  File "c:\Users\biolab\Documents\AnyBody.7.2.x\AMMR.v2.2.3_Steinfeld\Application\MocapExamples\Plug-in-gait_Simple\", line 119, in run_process
    MaxMuscleActivity = results[0]['Main.Studies.InverseDynamicStudy.Output.MaxMuscleActivity']
  File "C:\Users\biolab\anaconda3\lib\site-packages\anypytools\", line 511, in __getitem__
    raise KeyError(msg) from None
KeyError: 'The key Main.Studies.InverseDynamicStudy.Output.MaxMuscleActivity could not be found in the data'

(base) C:\Users\biolab\Documents\AnyBody.7.2.x\AMMR.v2.2.3_Steinfeld\Application\MocapExamples\Plug-in-gait_Simple>conda install anypytools
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

After that i can run again my python code and it will work.
Need to check how to recreate that error.

I have another questions:
I can run Main.RunParameterIdentification and Main.RunAnalysis. Dumping is working too. But I am getting this error:

#### Macro command > load "UpperLimb.any" -p C3D_FILE_NAME=---"C001_20170713_143"
Loading  Main  :  "C:\Users\biolab\Documents\AnyBody.7.2.x\AMMR.v2.2.3_Steinfeld\Application\MocapExamples\Plug-in-gait_Simple\UpperLimb.any"
ERROR(SCR.SCN9) :   System and load argument definitions (Virtual File)(24)  :   'C001_20170713_143' : Path does not exist.
Constructing model tree...
Linking identifiers...
Evaluating constants...
Configuring model...
Evaluating model...
Loaded successfully.
Elapsed Time : 1.984000

It's loading, calculating and dumping without any problems. I get the TXT and H5 files. I tried to look up this error but I can't find the source from code. How can I solve that error?
Another point I am interested in is where is the function that print the Error-txt file like mocapexamples-plug-in-gait_simple-0_(uh1knjbw).txt?
And where is this printed?

100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00,  1.05s/it]

Thank you for you concern.
Best regards

I doubt your trick of 'reinstalling' AnyPyTools actually does anything. Are you sure that it actually fixes something? Try kill all running Python instances next time it happens, and then run it again. That may be enough.

It's loading, calculating and dumping without any problems. I get the TXT and H5 files. I tried to look up this error but I can't find the source from code. How can I solve that error?

I think that is because of the way you use C3D_FILE_NAME. It is complaining that it doesn't point to a file. You can make C3D_FILE_NAME a define statement instead.

In anyscript it will look like #define C3D_FILE_NAME "C001_20170713_143"

From AnyPyTools it should be passed into AnyBody in the Load() class like this.

Load("main.any", def={"C3D_FILE_NAME": '"C001_20170713_143"'});

Define statement variables can point to anything, so you won't get an error.

Another point I am interested in is where is the function that print the Error-txt file like mocapexamples-plug-in-gait_simple-0_(uh1knjbw).txt?
And where is this printed?

That is printed by the AnyPyTools python code. You can see the source here:

Printing the progress bar is handled library called tqdm. You can see how anypytools calls tqdm as part running the scheduler.

Hello melund,

thank you for your answer. It seems the problem might be from Microsoft Visual Studio Code. I just started my pc and started only my python project and I did had the same error. But if I run the python file in Anaconda Prompt the file runs without any problems.

I already defined it in anyscript:

  #ifndef C3D_FILE_NAME
  #define C3D_FILE_NAME "C006_20170724_29"
  TrialFileName = C3D_FILE_NAME;

I am only giving the name from tkinter.askopenfilename so I will get only string of the name without any extensions:

def open_files(self):
        self.file_dir = os.path.dirname(__file__)
        self.file_full = filedialog.askopenfilename(initialdir = self.file_dir,title = "Select file",filetypes = [("C3D Files","*.c3d")])
        self.file_only = pathlib.PurePosixPath(self.file_full).stem

def run_process(self):     
        self.macrolist = [
            Load('UpperLimb.any', defs={"C3D_FILE_NAME": self.file_only}),

I am trying to open differnet c3d files in tkinter gui from the Input folder in Plug-in-gait_Simple.

Edit: I could solve it, after I saw that you use double quotation:


Thank you for the API link I will look it up. :slight_smile:

Best regards

Great. Yes. The extra quotation marks only makes sense for #define statements since they can be both strings (#define Test "my string") and non strings (#define Test SomeLiteral).

This topic was automatically closed 125 days after the last reply. New replies are no longer allowed.