Page 1 of 1

computeCurrentMarkerLocations does not return the expected values

Posted: Tue Feb 16, 2021 7:51 am
by docvi
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

Re: computeCurrentMarkerLocations does not return the expected values

Posted: Tue Feb 16, 2021 11:36 am
by aymanh
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

Re: computeCurrentMarkerLocations does not return the expected values

Posted: Fri Feb 19, 2021 2:06 am
by docvi
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