Page 1 of 1

IK Error: Incorrect number of keys

Posted: Wed Sep 12, 2018 10:30 am
by jamarsh
I recently switched over to V4.0 of OpenSim, but have run into an error when running IK on a model that previously worked in OpenSim 3.3. I have gotten other models to work in V4.0 no problem, but something is up with this one.

The full error message is: "Incorrect number of keys. Expected =8. Received =7. Thrown at trcfileadapter.cpp:76 in extendRead()."

Curious if this is a problem with my files, or if it's a beat problem, or whatever it may be. Any help or advice is greatly appreciated!

- Joe

Re: IK Error: Incorrect number of keys

Posted: Thu Sep 13, 2018 6:45 am
by clnsmith
Check that the line in the .trc file that gives the meta data values (line 3 in example below) is separated by tabs and not spaces. I'm guessing you have one pair that has a space in between the values instead of a tab.

Most text editors have an option "View Whitespace" etc that will show you tabs vs spaces.

Re: IK Error: Incorrect number of keys

Posted: Thu Sep 13, 2018 6:48 am
by clnsmith
Sorry forgot to post the file example:
Capture.JPG
Capture.JPG (56.26 KiB) Viewed 827 times

Re: IK Error: Incorrect number of keys

Posted: Thu Sep 13, 2018 6:08 pm
by jamarsh
I gave that a shot, but it looks like I have everything tabbed out correctly. I compared it to a .trc file that I've gotten to work and format wise they were identical as far as I could tell. It is an error reading meta data from that .trc file so it's gotta be something in there somewhere. But that line 3 that you referenced looks good as far as I can tell.

I've been using Mokka as a reference tool quite a lot, and I can't open the file there either. It says that an error occurred during file reading, and the logger says "Unexpected exception occurred: Error during type conversion from a string." Don't know if that gives you a bit more context.
trc meta data.PNG
trc meta data.PNG (21.84 KiB) Viewed 807 times

Re: IK Error: Incorrect number of keys

Posted: Fri Sep 14, 2018 2:28 am
by mitkof6
Maybe you should remove the path (C:\ ...) after (X/Y/Z) on the first line.

Re: IK Error: Incorrect number of keys

Posted: Fri Sep 14, 2018 12:57 pm
by jamarsh
Tried deleting the path, but I think I found the issue! I had to have somehow had the meta data inputs wrong somehow, but I got it working.

It looks like it was an old type of .trc file that only has 7 inputs to begin with, so I had to add the 8th by hand. For reference:

Old: DataRate->CameraRate->NumFrames->NumMarkers->Units->OrigDataRate->DataStartFrame
New: DataRate->CameraRate->NumFrames->NumMarkers->Units->OrigDataRate->OrigDataStartFrame->OrigNumFrames

The file still won't open in Mokka, but hey! It's working in opensim now. Thanks for all the help guys!

Re: IK Error: Incorrect number of keys

Posted: Sat Jul 18, 2020 1:39 pm
by israelluis7
Hi Guys,

it was very useful for me as well. I had that problem but for scaling my model in Opensim 4.1. I had the same error "Incorrect number of keys".

I followed what Joseph mentioned and it worked. Here is my own:

DataRate CameraRate NumFrames NumMarkers Units OrigDataRate OrigDataStartFrame OrigNumFrames
100 100 394 57 mm 100 2 394

You need to also include the value of "OrigNumFrames" in the next row (394 for me), and it needs to be spaced by Tab, white space does not solve the issue.