stanfordnmbl / osim-rl

Reinforcement learning environments with musculoskeletal models
http://osim-rl.stanford.edu/
MIT License
894 stars 249 forks source link

Using fixed step size in opensim_rl #235

Closed shakibaRafiee closed 3 years ago

shakibaRafiee commented 3 years ago

Hello.

I am trying to run some simulations in the OpenSim-rl, and I was wondering if there is a way I can have more control over the integration process.

I am working on a modified version of the sim_L2M2019_controller1 example, and I need to run it with a fixed-time step. I have tried to use manager.setIntegratorMaximumStepSize() and manager.setIntegratorMinimumStepSize() functions to force the model use a fixed-time step. Unfortunately, it seems like that a good number of functions that were developed for the OpenSim python package, are not included in the OpenSim-rl. I was hoping that someone here could help me run the code with a fixed time step.

Best, Shakiba

qmadorell commented 3 years ago

Hey, I'm having the same issue. How did you solve it?

Thanks in advance,

Queralt

shakibaRafiee commented 3 years ago

Hi Queralt,

I ended up using the "setDTArray" function. It gets an OpenSim-array as an input this is how I defined it for my code:

self.stepsize = 0.01 # simulation step size T = 20 # simulation duration dt_intg = self.stepsize/100 # integration step size DT_Array = opensim.ArrayDouble(dt_step, int(T/dt_intg)).getAsVector() self.manager.setDTArray(DT_Array)

Hope this helps.