Dear Sirs:
Thank you for the new release of CoppeliaSim v. 4.6.0!
I have some trouble with the remoteAPI.
My program is as follows:
from coppeliasim_zmqremoteapi_client import RemoteAPIClient
client = RemoteAPIClient()
sim = client.getObject('sim')
client.setStepping(True)
sim.startSimulation()
while(True):
pass
-----------------------------------------------------------------
The problem is when sim.startSimulation() is invoked, the following error appeared on the screen:
Connectivity >> ZMQ remote API server@addOnScript: abort execution
I removed the client.setStepping(True) line, then the simulator runs fine.
Is there something wrong with my code?
Thanks for your help,
Oz
trouble with the remoteAPI
Re: trouble with the remoteAPI
Hello Oz,
when in stepping mode, CoppeliaSim will pause simulation until sim.step() is called. After sim.step() is called, exactly one simulation step is executed before the next pause, etc.
Cheers
when in stepping mode, CoppeliaSim will pause simulation until sim.step() is called. After sim.step() is called, exactly one simulation step is executed before the next pause, etc.
Cheers
Re: trouble with the remoteAPI
Thanks for the note.
I am back in my home, where CoppeliaSim is still v. 4.5.1.
On v.4.5.1, the former code (without step()) works.
I will check the code with step() tomorrow with v.4.6.0.
Thank you for your kind help.
Oz
I am back in my home, where CoppeliaSim is still v. 4.5.1.
On v.4.5.1, the former code (without step()) works.
I will check the code with step() tomorrow with v.4.6.0.
Thank you for your kind help.
Oz
Re: trouble with the remoteAPI
For v.4.5.1, I checked the followings:
With an empty scene A) doesn't run (no printout), but B) runs (prints the count variable).
My code is:
A)
from coppeliasim_zmqremoteapi_client import RemoteAPIClient
import time
client = RemoteAPIClient()
sim = client.getObject('sim')
client.setStepping(True)
sim.startSimulation()
count = 0
while(True):
time.sleep(0.05)
client.step()
count += 1
print(count)
B)
from coppeliasim_zmqremoteapi_client import RemoteAPIClient
import time
client = RemoteAPIClient()
sim = client.getObject('sim')
client.setStepping(True)
sim.startSimulation()
count = 0
while(True):
time.sleep(0.05)
# client.step()
count += 1
print(count)
With an empty scene A) doesn't run (no printout), but B) runs (prints the count variable).
My code is:
A)
from coppeliasim_zmqremoteapi_client import RemoteAPIClient
import time
client = RemoteAPIClient()
sim = client.getObject('sim')
client.setStepping(True)
sim.startSimulation()
count = 0
while(True):
time.sleep(0.05)
client.step()
count += 1
print(count)
B)
from coppeliasim_zmqremoteapi_client import RemoteAPIClient
import time
client = RemoteAPIClient()
sim = client.getObject('sim')
client.setStepping(True)
sim.startSimulation()
count = 0
while(True):
time.sleep(0.05)
# client.step()
count += 1
print(count)
Re: trouble with the remoteAPI
You need to make sure to match the corresponding CoppeliaSim version and client application. With CoppeliaSim V4.5.1, you can't use:
but you should use:
There are other finer details with CoppeliaSim V4.6, where you can use:
Also adding a sleep in a stepping simulation very rarely makes sense, and just slows down things unnecessarily
Cheers
Code: Select all
from coppeliasim_zmqremoteapi_client import RemoteAPIClient
Code: Select all
from zmqRemoteApi import RemoteAPIClient
Code: Select all
sim = client.require('sim') # instead of sim = client.getObject('sim')
sim.setStepping(sw) # instead of client.setStepping(sw)
sim.step() # instead of client.step()
Cheers
Re: trouble with the remoteAPI
Thank you very much for your explanation.
I now can run the simulator with v.4.6.0.
I would like to run the simulation in real-time mode.
I try to check the mode with
sim.getRealTimeSimulation()
but it returns an exception of "type object 'sim' has no attribute 'getRealTimeSimulation'." Has the name of the function been changed?
Also, could you tell me how to set the real-time mode in python?
Thanks,
Oz
I now can run the simulator with v.4.6.0.
I would like to run the simulation in real-time mode.
I try to check the mode with
sim.getRealTimeSimulation()
but it returns an exception of "type object 'sim' has no attribute 'getRealTimeSimulation'." Has the name of the function been changed?
Also, could you tell me how to set the real-time mode in python?
Thanks,
Oz
Re: trouble with the remoteAPI
There was a glitch somewhere, and now the function is called sim.getIsRealTimeSimulation somehow... next release will have the sim.getRealTimeSimulation function available again.
But you can also use sim.getBoolParam and sim.setBoolParam with sim.boolparam_realtime_simulation to get/set that state.
Cheers
But you can also use sim.getBoolParam and sim.setBoolParam with sim.boolparam_realtime_simulation to get/set that state.
Cheers
Re: trouble with the remoteAPI
Thank you for the quick reply.
I have tried it and have had a good result.
Thank you for your continued help,
Oz
I have tried it and have had a good result.
Thank you for your continued help,
Oz