I am trying to use CoppeliaSim for some Reinforcement Learning which requires a lot of simulation (many hours), so I want to do this as quickly as possible. What I currently do is:
- Launch the scene I want to train on
- Open the Simulation Settings
- "Set the Simulation passes per frame (ppf)" to maximum, which seems to be 200
- Start my training using the ZeroMQ API
- And speed up the simulation even further using: sim.intparam_speedmodifier
Ideally, I would be able to set the ppf using the ZEROMQ API, but I haven't figured out how to do that.
Also I read in the "regular API constants" documentation that setting sim.boolparam_display_enabled to false allows you to enter the fast simulation mode. So, I wonder what fast simulation mode might be, because I couldn't find any documentation about it.
Looking forward to any help I might be able to get! Thanks a lot.
How to speed up simulation?
Re: How to speed up simulation?
Hello,
yes, the best option in that regard is to disabled rendering during simulation by setting sim.boolparam_display_enabled to false. Everything elase will run in the same fashion, except that there will be no rendering. With sim.intparam_speedmodifier you can obtain something similar, by skipping some rendering frames.
If you now want to further increase speed, you'll have to look at where you bottleneck is: what, in a given simulation step takes most CPU time? Once you have identified that, you can e.g. execute that operation less frequently, i.e. not in every simulation step. As an example, if vision sensors take too much time, then instead of handling them in each simulation step (i.e. generating a new frame in each simulation step), you can set them to explicit handling and handle them in your child script every n simulation step.
You can of course also select a different simulation loop time step (default is 50ms), e.g. at 100ms. While doing this, keep in mind that the physics engine time step will still remain the same (by default 5ms), which is important, otherwise that would mess-up physics fidelity.
Cheers
yes, the best option in that regard is to disabled rendering during simulation by setting sim.boolparam_display_enabled to false. Everything elase will run in the same fashion, except that there will be no rendering. With sim.intparam_speedmodifier you can obtain something similar, by skipping some rendering frames.
If you now want to further increase speed, you'll have to look at where you bottleneck is: what, in a given simulation step takes most CPU time? Once you have identified that, you can e.g. execute that operation less frequently, i.e. not in every simulation step. As an example, if vision sensors take too much time, then instead of handling them in each simulation step (i.e. generating a new frame in each simulation step), you can set them to explicit handling and handle them in your child script every n simulation step.
You can of course also select a different simulation loop time step (default is 50ms), e.g. at 100ms. While doing this, keep in mind that the physics engine time step will still remain the same (by default 5ms), which is important, otherwise that would mess-up physics fidelity.
Cheers
Re: How to speed up simulation?
Hello,
Thanks for your answering.
If we disable rendering during simulation, would the vision_sensor still work as before?
And talk about explicit handling, could you please suggest some approach? I'm currently using ZMQ and sim.getVisionSensorCharImage each timestep to read the vision_sensor and then do some image processing during the timestep.
Best Regards,
Thanks for your answering.
If we disable rendering during simulation, would the vision_sensor still work as before?
And talk about explicit handling, could you please suggest some approach? I'm currently using ZMQ and sim.getVisionSensorCharImage each timestep to read the vision_sensor and then do some image processing during the timestep.
Best Regards,
coppelia wrote: ↑05 Sep 2022, 13:46 Hello,
yes, the best option in that regard is to disabled rendering during simulation by setting sim.boolparam_display_enabled to false. Everything elase will run in the same fashion, except that there will be no rendering. With sim.intparam_speedmodifier you can obtain something similar, by skipping some rendering frames.
If you now want to further increase speed, you'll have to look at where you bottleneck is: what, in a given simulation step takes most CPU time? Once you have identified that, you can e.g. execute that operation less frequently, i.e. not in every simulation step. As an example, if vision sensors take too much time, then instead of handling them in each simulation step (i.e. generating a new frame in each simulation step), you can set them to explicit handling and handle them in your child script every n simulation step.
You can of course also select a different simulation loop time step (default is 50ms), e.g. at 100ms. While doing this, keep in mind that the physics engine time step will still remain the same (by default 5ms), which is important, otherwise that would mess-up physics fidelity.
Cheers
Re: How to speed up simulation?
I tried
client = RemoteAPIClient()
self.sim = client.require('sim')
self.sim.setStepping(True)
self.sim.startSimulation()
elf.sim.setBoolParam(self.sim.boolparam_display_enabled,False)
and find the UI in coppeliaSim to be black. Is it normal? Many thanks to you.
client = RemoteAPIClient()
self.sim = client.require('sim')
self.sim.setStepping(True)
self.sim.startSimulation()
elf.sim.setBoolParam(self.sim.boolparam_display_enabled,False)
and find the UI in coppeliaSim to be black. Is it normal? Many thanks to you.
coppelia wrote: ↑05 Sep 2022, 13:46 Hello,
yes, the best option in that regard is to disabled rendering during simulation by setting sim.boolparam_display_enabled to false. Everything elase will run in the same fashion, except that there will be no rendering. With sim.intparam_speedmodifier you can obtain something similar, by skipping some rendering frames.
If you now want to further increase speed, you'll have to look at where you bottleneck is: what, in a given simulation step takes most CPU time? Once you have identified that, you can e.g. execute that operation less frequently, i.e. not in every simulation step. As an example, if vision sensors take too much time, then instead of handling them in each simulation step (i.e. generating a new frame in each simulation step), you can set them to explicit handling and handle them in your child script every n simulation step.
You can of course also select a different simulation loop time step (default is 50ms), e.g. at 100ms. While doing this, keep in mind that the physics engine time step will still remain the same (by default 5ms), which is important, otherwise that would mess-up physics fidelity.
Cheers
Re: How to speed up simulation?
Hello,
yes, it is normal that the display is black, since you disabled rendering with:
Disabling rendering will not disable vision sensors that will still be able to function normally. Instead of sim.getVisionSensorCharImage, use sim.getVisionSensorImg. But even if you do not fetch the image, the vision sensor will render it (and spend time) in each simulation step. To avoid this, set the vision sensor to explicit handling (aux. set also Ignore depth info (faster) to false), then handle the vision sensor at the frequency you want, e.g.:
Cheers
yes, it is normal that the display is black, since you disabled rendering with:
Code: Select all
sim.setBoolParam(sim.boolparam_display_enabled, False)
Code: Select all
--lua
sim=require'sim'
function sysCall_init()
sensor = sim.getObject('.')
updateEveryXSimulationPass = 10
pass=0
end
function sysCall_sensing()
pass = pass + 1
if pass >= updateEveryXSimulationPass then
sim.handleVisionSensor(sensor)
pass=0
end
end