Issue with Pausing and Resuming Simulation (with Python/ZeroMQ)
Posted: 03 Dec 2021, 16:26
Good day,
I am currently working with the Python ZeroMQ API method of interacting with the simulator. My objective is to use CoppeliaSim to record demonstrations of manipulations on basic shapes with a robot arm and gripper. I wish to record a sequence of actions one by one by pausing and resuming the simulation in steps.
I am doing this as follows: 1) start the simulation in a base state, 2) perform one action and record position/orientation of objects, 3) pause the simulation when an action is complete, 4) resume the simulation to record another action, 4) repeat steps 2 - 4 for different actions, and 5) stop the simulation when entire demonstration is completed.
I am currently using the functions sim.startSimulation(), sim.stopSimulation(), sim.pauseSimulation(), and sim.getSimulationState() to perform this all. The following shows some function calls I made that use these (based on the ZeroMQ tutorial files):
I use keystrokes that are detected by the Python client to call upon these operations.
My issue is that I am unable to resume my simulation after recording my first action. Once I send the resume command (via sim.startSimulation()), the Python client hangs, and the simulation does not seem to receive the call to resume. If I instead stop instead of pause (and I deselect the "Reset scene to initial state" option in the "Simulation Settings" for Coppelia), I can successfully start and stop recording action by action. However, I am faking some grasps by attaching the objects to a gripper, so stopping and starting will detach the objects between actions, unlike when the simulation is paused. This disrupts the flow of recording, especially if I need to keep an object grasped without slipping or dropping between actions.
Is there something that I am not considering for pausing/resuming correctly? Thank you!
I am currently working with the Python ZeroMQ API method of interacting with the simulator. My objective is to use CoppeliaSim to record demonstrations of manipulations on basic shapes with a robot arm and gripper. I wish to record a sequence of actions one by one by pausing and resuming the simulation in steps.
I am doing this as follows: 1) start the simulation in a base state, 2) perform one action and record position/orientation of objects, 3) pause the simulation when an action is complete, 4) resume the simulation to record another action, 4) repeat steps 2 - 4 for different actions, and 5) stop the simulation when entire demonstration is completed.
I am currently using the functions sim.startSimulation(), sim.stopSimulation(), sim.pauseSimulation(), and sim.getSimulationState() to perform this all. The following shows some function calls I made that use these (based on the ZeroMQ tutorial files):
Code: Select all
# python
def _stopDemo():
sim.stopSimulation()
while sim.getSimulationState() != sim.simulation_stopped:
time.sleep(0.1)
def _pauseDemo():
sim.pauseSimulation()
while sim.getSimulationState() != sim.simulation_paused:
time.sleep(0.1)
def _startDemo():
sim.startSimulation()
while sim.getSimulationState() != sim.simulation_advancing_running:
time.sleep(0.1)
My issue is that I am unable to resume my simulation after recording my first action. Once I send the resume command (via sim.startSimulation()), the Python client hangs, and the simulation does not seem to receive the call to resume. If I instead stop instead of pause (and I deselect the "Reset scene to initial state" option in the "Simulation Settings" for Coppelia), I can successfully start and stop recording action by action. However, I am faking some grasps by attaching the objects to a gripper, so stopping and starting will detach the objects between actions, unlike when the simulation is paused. This disrupts the flow of recording, especially if I need to keep an object grasped without slipping or dropping between actions.
Is there something that I am not considering for pausing/resuming correctly? Thank you!