Page 1 of 1

Piecewise Constant Function in C++

Posted: Fri Feb 12, 2021 9:33 am
by st115990
Hello,

I am currently adding a new muscle model to OpenSim. I finished the first version of it and now I want to test my implementation.
Therefore I tried to simulate my muscle instead of the Millard muscle in the simple C++ example of https://github.com/opensim-org/opensim-core, which worked fine.

Now I additionaly added a triceps muscle and want to simulate an alternating movement with the setup.
Therefore, I want to implement a piecewise constant function which alternates between minimum and maximum activation for both muscles.

Unfortunately I was not able to define a PiecewiseConstantFunction.
How can such a function be defined in C++? Is there any example I could use to define this function?

Many thanks in advance for answering my question.

Best
Mike

Re: Piecewise Constant Function in C++

Posted: Sat Feb 13, 2021 5:10 am
by tkuchida
You can search the GitHub repo for "PiecewiseConstantFunction" (https://github.com/opensim-org/opensim- ... ntfunction). The class is used in PrescribedController.cpp (https://github.com/opensim-org/opensim- ... r.cpp#L217), buildHopperModel.cpp (https://github.com/opensim-org/opensim- ... l.cpp#L171), etc.

Re: Piecewise Constant Function in C++

Posted: Sun Feb 14, 2021 8:58 am
by st115990
Thank you a lot this worked out for me!