Creating Custom Controller in Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Daniel Gordon
Posts: 34
Joined: Fri May 06, 2016 7:57 am

Creating Custom Controller in Matlab

Post by Daniel Gordon » Wed Apr 08, 2020 2:43 am

Hi,

I was wondering if it's possible in OpenSim 4.1 to create a custom controller component in Matlab (e.g. in a similar manner to as is done in the TugOfWar Controller example in the C++ files).

I know this wasn't possible in OpenSim 3.3 but just wanted to check. I have a work-around involving the Manager and a PrescribedController which is updated at short time-scales, if not.

Cheers

Tags:

User avatar
Carmichael Ong
Posts: 378
Joined: Fri Feb 24, 2012 11:50 am

Re: Creating Custom Controller in Matlab

Post by Carmichael Ong » Wed Apr 08, 2020 10:00 am

I looked through the TugOfWar code from 4.1, and I see the controls section between L260 and L275. It looks like it's also using a PrescribedController as you are using with a linear function. Is this what you're referring to? If so, I think it should be doable. LinearFunction should be available in MATLAB, and Array<double> should be ArrayDouble in MATLAB.

User avatar
Carlos Gonçalves
Posts: 127
Joined: Wed Jun 08, 2016 4:56 am

Re: Creating Custom Controller in Matlab

Post by Carlos Gonçalves » Thu Aug 20, 2020 8:17 pm

Hello Carmichael, I am starting my research on custom controllers for OpenSim.

Do you know if there is an example in Python?

Best regards.

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Creating Custom Controller in Matlab

Post by Dimitar Stanev » Fri Aug 21, 2020 1:11 am

Hi Carlos,

Just to compliment Carmichael's answer, you can find an example code of a custom controller in C++ below:

https://github.com/mitkof6/OpenSim_API_ ... controller

If you want to create controllers in Python, keep in mind that they are not tightly integrated as would be in C++. One approach is to set the muscle excitation and integrate the system as with the osim-rl project. Please also, consider the following discussion:

viewtopicPhpbb.php?f=91&t=12337&p=0&sta ... 4086ef55f8

POST REPLY