rcnl-org / nmsm-core

Neuromusculoskeletal Modeling (NMSM) Pipeline codebase
https://nmsm.rice.edu
Other
15 stars 3 forks source link

[BUG] Tracking Optimization Incorrectly Says Two-segment Foot Model Is Not Two Segments #325

Open bfregly opened 3 months ago

bfregly commented 3 months ago

Describe the bug

I am trying to run a torque-driven Tracking Optimization using my restructured fullbody OpenSim model that has two ground-to-foot joints and a three-part pelvis with bushings that pull the two hemipelvises together and into the sacrum. The initial model checking code incorrectly identifies my two-segment foot models as not being two-segment models.

Below is a description of what I did:


|                                                                   | |            __              __          | |           / __/ \/ \/ \/ /       /  /  /          | |          / / / // / / / / // /__ \ ___  / / / /            | |         / // / ____/ // / // //____// // /             | |         ____//    __/_/    //      ///             | |                                                                   | | GPOPS-II Version 2.5.  Release Date: Aug 2018                     | || |                                                                   | | GPOPS-II Copyright (c) 2013-2019 Michael Patterson & Anil V. Rao. | || |                                                                   | | Downloading, using, copying, or modifying the GPOPS-II code       | | code constitutes an agreement to ALL of the terms of the          | | GPOPS-II license.                                                 | |___|   Error using assert Treatment Optimization supports two segment foot models only

Error in prepareGroundContactSurfaces>getParentChildSprings (line 54) assert(length(joints) == 2, ...

Error in prepareGroundContactSurfaces (line 36)     contactSurfaces{i} = getParentChildSprings(osimModel, contactSurfaces{i});

Error in makeTreatmentOptimizationInputs (line 36) inputs.contactSurfaces = prepareGroundContactSurfaces( ...

Error in TrackingOptimizationTool (line 37) inputs = makeTreatmentOptimizationInputs(inputs, params);

So TO thinks that my two-segment foot model is not a two-segment foot model.

My guess is that the following is happening. TO is probably looking at the hindfoot segment (calcn_r and calcn_l still), looking for children, and then if there is more than one child attached to the hindfoot segment, or if a child of the hindfoot segment also has a child body attached to it, it assumes the foot model is only two segments.

In the case of my restructured model, each hindfoot segment has two children that branch from it in open chains. So it's not as simple as looking to the end of the open chain, since there are two directions to check.

An easy fix for this problem would be to look only in the direction of the child body that has springs attached to it, in this case a toes segment.

Let me know if I have diagnosed the problem correctly, and if so, if you can make a quick fix for me (AFTER you get your two ICNR abstracts submitted).

To Reproduce

Unzip my zip file TOBug.zip and run Tracking Optimization using my settings file TrackingOptimizationSettings.xml.

Expected behavior

My two-segment foot model should be allowed.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

TOBug.zip

SpencerTWilliams commented 3 months ago

Yes, you're right about why that issue is happening. I'll try the change you suggested after submitting my abstracts.