Piecewise Constant Function in C++

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Mike Spahr
Posts: 14
Joined: Mon May 04, 2020 7:59 am

Piecewise Constant Function in C++

Post by Mike Spahr » Fri Feb 12, 2021 9:33 am

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

Tags:

User avatar
Thomas Uchida
Posts: 1777
Joined: Wed May 16, 2012 11:40 am

Re: Piecewise Constant Function in C++

Post by Thomas Uchida » Sat Feb 13, 2021 5:10 am

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.

User avatar
Mike Spahr
Posts: 14
Joined: Mon May 04, 2020 7:59 am

Re: Piecewise Constant Function in C++

Post by Mike Spahr » Sun Feb 14, 2021 8:58 am

Thank you a lot this worked out for me!

POST REPLY