Hi,
I wonder where I can find documents for coppeliaSim.lib? I only see several examples in the CoppeliaSim's library section of the manual but I don't find the specific document to explain the arguments for several functions like, simInitialize, simRunGui, simLoop, etc.
To be more specific, I have two questions:
1. Should simLoop always be used as simLoop(None, 0) ?
2. Another thing is that if I only use simInitialize without simRunGui, does it mean headless running? Then, what's the purpose of the headless argument in the simRunGui?
Thanks,
kz
Document and Question for coppeliaSim.lib
Re: Document and Question for coppeliaSim.lib
Hello Kz,
yes, for now, keep the arguments of simLoop unchanged. In a future version, there might be more possibilities.
Then, you can run CoppeliaSim in two types of headless mode:
a) only supressing the GUI part (emulated headless mode): this will run quite similarly with the regular mode, with the difference that dialogs are not initialized nor shown. From the command line, you'd start the default CoppeliaSim client with:
The Python client however should be invoked with:
b) running CoppeliaSim in true headless mode: this is a different library, which does not have any GUI thread. So simRunGui won't have to be called in that mode when starting via the Python client. From the command line, you'd start the default CoppeliaSim client with:
The Python client however should be invoked with:
yes, for now, keep the arguments of simLoop unchanged. In a future version, there might be more possibilities.
Then, you can run CoppeliaSim in two types of headless mode:
a) only supressing the GUI part (emulated headless mode): this will run quite similarly with the regular mode, with the difference that dialogs are not initialized nor shown. From the command line, you'd start the default CoppeliaSim client with:
Code: Select all
coppeliaSim -h
Code: Select all
python3 coppeliaSim.py -H
Code: Select all
coppeliaSim -H
Code: Select all
python3 coppeliaSim_noUI.py
Re: Document and Question for coppeliaSim.lib
Hi,
I have some further questions. What's the difference between simLoop(None, 0) and sim.step(). I find my thread will be blocked after I call sim.step() even though I have set sim.setStepping(True).
Best,
Kz
I have some further questions. What's the difference between simLoop(None, 0) and sim.step(). I find my thread will be blocked after I call sim.step() even though I have set sim.setStepping(True).
Best,
Kz
Re: Document and Question for coppeliaSim.lib
If as in your case you run within the CoppeliaSim thread, i.e. you loaded the coppeliaSim library via Python, then you should use simLoop or simStep (instead of sim.step). But in the end, simStep is a subset of simLoop: simLoop is meant to be used when running CoppeliaSim via the GUI, e.g.:
In above code, start simulation, stop simulation, etc. should come from the GUI or from some other control entity (e.g. a remote API client). Also, in above, you do not have direct control of each simulation steps.
However if you do not have any other interaction from the GUI or similar, or you want to perfectly control when the next simulation step happens, use simStep, e.g.:
simStep however only works when simulation is running. Above is actually equivalent to:
Cheers
Code: Select all
while not simGetExitRequest():
simLoop(None, 0)
However if you do not have any other interaction from the GUI or similar, or you want to perfectly control when the next simulation step happens, use simStep, e.g.:
Code: Select all
sim.loadScene('path/to/scene.ttt')
simStart()
for i in range(1000):
t = sim.getSimulationTime()
print(f'Simulation time: {t:.2f} [s] (simulation running synchronously to client, i.e. stepped)')
simStep()
simStop()
simDeinitialize()
Code: Select all
sim.loadScene('path/to/scene.ttt')
simStart()
for i in range(1000):
t = sim.getSimulationTime()
print(f'Simulation time: {t:.2f} [s] (simulation running synchronously to client, i.e. stepped)')
simLoop(None, 0)()
simStop()
simDeinitialize()