Page 1 of 1

Opensim And Matlab

Posted: Fri Aug 21, 2020 11:35 pm
by mec_amini
Hi guys
I would try to use addincontrol in Matlab code. I want to define control signal for one actuator. thus I write this code. but it isn't work. why?

modelcontrols = walkerModel.getDefaultControls

model.updActuators().get("knee_motor_r").addInControls(0,modelcontrols)

please guide me.

Re: Opensim And Matlab

Posted: Sun Aug 23, 2020 11:25 pm
by mec_amini
I solved it
modelcontrols = Model.getDefaultControls;
Tkr = Vector(1, Tkr);
Model.getActuators.get("knee_motor_r").addInControls(Tkr,modelcontrols)
Model.setDefaultControls(modelcontrols)

Re: Opensim And Matlab

Posted: Mon Aug 24, 2020 1:00 am
by mitkof6
Hi,

I am glad that you made it work. However, you are not supposed to set the controls directly, but through a controller. You can use a prescribed controller. Please, study the following code:

https://github.com/stanfordnmbl/osim-rl ... sim.py#L19

and in particular:

https://github.com/stanfordnmbl/osim-rl ... sim.py#L59

and

https://github.com/stanfordnmbl/osim-rl ... sim.py#L92