Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buggy behaviour when using models with a patellofemoral joint #184

Open
TorsteinDaehlin opened this issue Jan 31, 2025 · 0 comments
Open

Comments

@TorsteinDaehlin
Copy link

Description
getCoordinateIndexForStateVectorOpenSimAPI() may produce incorrect indices to reference the coordinates of the OpenSim model (stored in model_info.ExtFunIO.coordi_OpenSimAPIstate) when the model contains a patellofemoral joint. Specifically, as the loop that sets the state variables of the OpenSim model to the corresponding coordinate index on lines 41-43 uses the number of coordinates from the external function (which ignores the patellofemoral joint), the state of all coordinates may not be assigned the correct index depending on the order of the coordinates returned by state_vars = model.getStateVariableValues(state);.

Incorrect indexing of the coordinates of the OpenSim model in turn may trigger the following error:

Array indices must be positive integers or logical values.

Error in update_model_info (line 40)
    tmpst = [tmpst names_coords_i{end}];
                   ^^^^^^^^^^^^^^^^^^^
Error in PreProcessing (line 61)
model_info = update_model_info(S,osim_path,model_info);
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in run_pred_sim (line 108)
[S,model_info] = PreProcessing(S,osim_path);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in runPredSim (line 43)
    [savename] = run_pred_sim(S,osim_path);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
Error in main_cycling (line 124)
    [savename] = runPredSim(S, osim_path);
                 ^^^^^^^^^^^^^^^^^^^^^^^^

A quick-fix is to insert model.getCoordinateSet().getSize() in place of n_coord on line 41, such that the loop is over all of the coordinates of the OpenSim model, rather than the number of coordinates in the external function. However, a better solution should probably be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant