Page 1 of 1

Vastus shoots through wrapping object in Hopper Example

Posted: Tue Sep 15, 2020 2:15 am
by joris997
Dear all,
I am trying to change the wrapping surface of the hopper example to an ellipsoid and sphere. This would mean that, especially on the sphere, the vastus is 'balancing' on the patella. However, for an ellipsoid of significant width (read ridiculously large) this should not be a problem. For both the ellipsoid with extreme width and the sphere however, the vastus remains on the patella for about 0.2 seconds of the simulation and afterwards seems to shoot through the wrapping surface. Could anyone point me in the right direction regarding this?

Here is the code (changes to the file "buildHopperModel.cpp", patella_shape is passed to the buildHopper function as an additional argument):

Code: Select all

// Attach a patella to the distal end of the thigh over which the
// vastus muscle can wrap. linkDistalPoint only has a longitudal displacement w.r.t. the shank
        auto patellaFrame = new PhysicalOffsetFrame("patellaFrame",*thigh, SimTK::Transform(linkDistalPoint));
        // create an empty patella before the 'if' statement declarations
        auto patella = new WrapEllipsoid();

        if (patella_shape == "ellipsoid") {
            delete patella;
            auto patella = new WrapEllipsoid();
            patella->setAllPropertiesUseDefault(true);
            // a significant e2 size of the ellipsoid still leads to the vastus going through the wrapping surface
            // although this is physically not possible
            patella->set_dimensions(Vec3(0.08, 0.08, 1));
            patella->set_quadrant("+x");
        } else if (patella_shape == "sphere") {
            delete patella;
            auto patella = new WrapSphere();
            patella->setAllPropertiesUseDefault(true);
            patella->set_radius(0.08);
            patella->set_quadrant("+x");
        }

        patella->setName("patella");
        std::cout << "Patella is a " << patella->getWrapTypeName() << std::endl;

        patellaFrame->addWrapObject(patella);
        thigh->addComponent(patellaFrame);

        // Configure the vastus muscle to wrap over the patella.
        vastus->updGeometryPath().addPathWrap(*patella);
Notice that the 'width' of the ellipsoid is 1 so the vastus going 'around' the ellipsoid should not be possible. Also, the patella (and therefore the patellaFrame) are on the same line as the vastus' origin and insertion point. I've recently added the 'setAllPropertiesUseDefault' since I saw it in another forum post. I've also tried with a width of the ellipse of 0.01 at which the vastus goes around the patella before the simulation even started.

Would love to understand why this is not happening properly. Seems like it should be a simple and straightforward change to the code so I must be missing something obvious.

Cheers and thanks in advance

Re: Vastus shoots through wrapping object in Hopper Example

Posted: Tue Sep 15, 2020 6:22 am
by tkuchida
Please verify that you have set the "quadrant" property appropriately. There are explanations/discussions elsewhere on the Forum, which you can find by searching for "quadrant" (e.g., see topics 10435 viewtopicPhpbb.php?f=91&t=10435 and 10898 viewtopicPhpbb.php?f=91&t=10898).

Re: Vastus shoots through wrapping object in Hopper Example

Posted: Tue Sep 15, 2020 7:31 am
by joris997
Hi Thomas,

Thank you for your quick response. Just to be sure, I've applied all possible quadrants but no luck. I'm quite confident in the "+x" quadrant being chosen.

I think however that the problem is different and that I perhaps can better show it with some images;

Picture 1: This is before and during the first ~0.2 seconds of the simulation
Picture 2: This is after 0.2 until the end of the simulation
https://imgur.com/a/a77Uj04

So as you can see the initial wrapping is perfect. During the simulation it seems that after a certain amount of stretch, the muscle clips through the wrapping surface (but this is not possible as also the initial cylinder in the design is of the same radius and the program itself should not allow this). Also just to be sure; the cylinder works perfectly with exactly the same quadrant, position, and wrapping radius.

So while the wrapping is fine, the interaction with the surface seems to be wrong.

Re: Vastus shoots through wrapping object in Hopper Example

Posted: Wed Sep 16, 2020 1:03 am
by tkuchida
I can think of a couple possible explanations:
1. The calculations are correct but the visualization is wrong. Do you see a discontinuity when you plot the moment arm over time? If not, then this may just be a visualization bug. There was a similar bug with cylinders in 4.0 but I thought it was fixed (see the last bullet in the first list on the "What's New in OpenSim 4.1?" page in the documentation, https://simtk-confluence.stanford.edu/p ... d=36439186).
2. "All possible quadrants" is not an exhaustive search. I can't tell which part of the ellipsoid "+x" refers to, but it is conceivable that the wrapping could disengage when one of the muscle path contact points passes into the next quadrant of the ellipsoid. I presume your ellipsoid is aligned with the global frame. You could try rotating the ellipsoid about its long axis by +/-45 degrees, for example.