## How to reset v-rep properly

Typically: "How do I... ", "How can I... " questions
skye53969
Posts: 3
Joined: 11 Sep 2019, 02:25

### How to reset v-rep properly

Hi,

I would like to use PyRep as a reinforcement learning environment, so I try to follow the example found herehttps://github.com/stepjam/PyRep/blob/m ... ing_env.py. However, I don't know how to reset the environment preperly. In my reset function, I call something like set_position(start_pos), then it simply call _get_state function and return. Inside _get_state function, it call simReadProximitySensor to get the sensor data. But, it seems that the return sensor data is from the last step before reset. How can I fix this?

Thanks

coppelia
Posts: 7597
Joined: 14 Dec 2012, 00:25

### Re: How to reset v-rep properly

Hello,

try to check here for questions specific to PyRep.
In V-REP, when you stop a simulation (e.g. by calling sim.stopSimulation), it will still take a couple of simulation steps, before the simulation has really halted. Only when it has really halted, will objects be reset to the position/orientation prior to simulation start.

Cheers

skye53969
Posts: 3
Joined: 11 Sep 2019, 02:25

### Re: How to reset v-rep properly

Thank you for your answer. Is there any way that I can reset the robot without stopping the simulation? I know I can reset the robot positions and orientation with simResetDynamicObject. Is there something similar for resetting joint velocities?
I don't quite understand how simResetDynamicObject work. Can I use simResetDynamicObject to reset joint velocities?

coppelia
Yes, you can use sim.resetDynamicObject: the effect is as if you would temporarily remove the object from the dynamics representation.
If you have a whole robot (e.g. a model) and you want to dynamically reset it, then you need to make sure to reset all of its objects at the same time (i.e. in the exact same simulation step). This is also how you can instantaneously teleport a dynamically enabled model: you would first reset all its objects, and move the base of the model (e.g. with sim.setObjectPosition). Here also, the move needs to take place at the exact same simulation step as the reset.