How to reset v-rep properly

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

How to reset v-rep properly

Post by skye53969 » 11 Sep 2019, 06:24

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
Site Admin
Posts: 7330
Joined: 14 Dec 2012, 00:25

Re: How to reset v-rep properly

Post by coppelia » 12 Sep 2019, 12:30

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: 2
Joined: 11 Sep 2019, 02:25

Re: How to reset v-rep properly

Post by skye53969 » 17 Sep 2019, 02:27

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
Site Admin
Posts: 7330
Joined: 14 Dec 2012, 00:25

Re: How to reset v-rep properly

Post by coppelia » 18 Sep 2019, 06:17

Yes, you can use sim.resetDynamicObject: the effect is as if you would temporarily remove the object from the dynamics representation.
For example, if you have a falling cube, and call sim.resetDynamicObject on it, the cube will halt, and start falling again.

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.

If you want the reset of a model to be perfect, you would also need to set the relative position/orientation of all object relative to its parent, in that model, to what it was just before simulation started. This is because the dynamics simulation will introduce very small errors between objects linked via a joint or force sensor.

Cheers

Post Reply