computeCurrentMarkerLocations does not return the expected values

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Vincent Fohanno
Posts: 23
Joined: Thu May 10, 2018 10:03 am

computeCurrentMarkerLocations does not return the expected values

Post by Vincent Fohanno » Tue Feb 16, 2021 7:51 am

Hi gents,

I am using the C++ API to update the coordinate values of my model (estimated previously by calling mInverseKinematicsSolver.track()) and then use computeCurrentMarkerLocations to get the new marker locations in the ground frame.
Unfortunately, the values of the marker locations are not correct because it seems like the state is not updated somehow. I can set the coordinate values to other values, the marker locations values will not change.
Here below is the code I am using where I am setting 0.0 for each coordinate of my model for testing:

Code: Select all

auto& state = mModel->updWorkingState();
        state.updTime() = 0.0;
        // Predict coordinates using the Evolution matrix
        *mXPred = (*mA) * (*mX);
        
        // Update the model with the predicted coordinates
        const OpenSim::CoordinateSet& coordinateSet = mModel->getCoordinateSet();
        for (int i = 0; i < coordinateSet.getSize(); i++)
        {
            coordinateSet[i].setValue(state, 0.0);// (*mXPred)(i));
        }
        mModel->getMultibodySystem().realize(state, SimTK::Stage::Position);
        auto markerNames = mMarkersReference->getNames();
        int nbrMarkers = markerNames.size();
        SimTK::Array_<SimTK::Vec3> markerLocations(nbrMarkers, SimTK::Vec3(0));
        mInverseKinematicsSolver->computeCurrentMarkerLocations(markerLocations);
Is there anything missing so that the new coordinate values are used when callling computeCurrentMarkerLocations?
Thank you for your help

Vincent

Tags:

User avatar
Ayman Habib
Posts: 2235
Joined: Fri Apr 01, 2005 12:24 pm

Re: computeCurrentMarkerLocations does not return the expected values

Post by Ayman Habib » Tue Feb 16, 2021 11:36 am

Thanks for reporting, Vincent.

As you can tell from the method signatures, the state you populated is not passed down to the method computeCurrentMarkerLocations() as such there's no chance it can compute new locations corresponding to the new state. Instead, these methods query an internal state that is set and updated by the solver. It's possible however to compute a marker location in ground given an arbitrary state using the output mechanism/marker methods, for example:

Code: Select all

marker.calcLocationInGround(state)
Hope this helps,
-Ayman

User avatar
Vincent Fohanno
Posts: 23
Joined: Thu May 10, 2018 10:03 am

Re: computeCurrentMarkerLocations does not return the expected values

Post by Vincent Fohanno » Fri Feb 19, 2021 2:06 am

Hi Ayman,

I used getLocationInGround instead which is the same as calcLocationInGround (that I could not call directly) and I got it to work.

Thanks for you help

Vincent

POST REPLY