Page 1 of 1

get contact force vector during C++ runtime

Posted: Mon Jun 03, 2019 11:49 pm
by hkimpara
Dear Experts,

I have a question about getting method of contact force data through C++ OpenSim API.

I used something like:

Code: Select all

osimModel.realizeAcceleration(si);
auto vals = osimModel.getForceSet().get(ContactForceName).getRecordValues(si);
However, obtained values show always zero even the contact force happens. Alternatively, I monitor force data from forcestorage in current. But, I'm willing to get contact force from runtime variables.

What kind of methods is lacked in my process?

Thank you,
Hide

Re: get contact force vector during C++ runtime

Posted: Thu Jun 06, 2019 12:20 am
by mitkof6
I think the calculation of forces requires realization to dynamics stage. Can you verify that the contact is working properly (e.g.,in the GUI)? You may also find the following example code from Simbody:

https://github.com/simbody/simbody/blob ... ground.cpp

Re: get contact force vector during C++ runtime

Posted: Thu Jun 06, 2019 3:35 am
by hkimpara
Hi Dimitar!
Thank you for your response. Yes, I made a double check with both of GUI and ForceReporter outputs. I changed realization from acceleration to dynamics stage, but get force does not give me any outputs.
I remember you used generalized force data for task space control. How did you monitor force data during C++ run-time?
Thank you, Hide