sync external Python script and internal Coppelia child script
Posted: 09 Jun 2023, 11:20
I am currently running a Coopelia scene from an external Pyhton script using the zmqRemoteAPI module.
The pipeline goes as follows:
1. Some calculations are performed in external Python script.
2. The resulting variables are sent from external Python script to Coppelia via sim.writeCustomTableData() command.
3. A child script is executed in Coppelia before the actual simulation starts
4. The child script is then disabled.
5. The simulation starts via API Python command sim.startSimulation()
6. Simulation takes place within Coppelia.
7. The resulting variables are sent from Coppelia to external Python script.
The actual simulation in Coppelia is sync with the Python script using the following code:
The problem comes when I try to run step 3.
I'm trying to do something similar to the code above, having the Python script running in loop until a confirmation is received from Coppelia script that the actual child script has finished executing.
Im trying something similar to:
but the Coppelia child script never actually runs. I assume I somehow have to manage the multithreading process via sim.setThreadAutomaticSwitch() and sim.switchThread() commands but I'm quite lost, to be honest.
How could I manage to resume the external Python execution once the Coppelia child script is fully executed?
I appreciate any help!
The pipeline goes as follows:
1. Some calculations are performed in external Python script.
2. The resulting variables are sent from external Python script to Coppelia via sim.writeCustomTableData() command.
3. A child script is executed in Coppelia before the actual simulation starts
4. The child script is then disabled.
5. The simulation starts via API Python command sim.startSimulation()
6. Simulation takes place within Coppelia.
7. The resulting variables are sent from Coppelia to external Python script.
The actual simulation in Coppelia is sync with the Python script using the following code:
Code: Select all
sim.startSimulation()
while sim.getStringSignal(signal_tag) == 'on':
client.step()
sim.stopSimulation()
I'm trying to do something similar to the code above, having the Python script running in loop until a confirmation is received from Coppelia script that the actual child script has finished executing.
Im trying something similar to:
Code: Select all
sim.initScript(coppelia_script_handle)
while sim.getStringSignal(signal_tag) == 'on':
pass
How could I manage to resume the external Python execution once the Coppelia child script is fully executed?
I appreciate any help!