Fast Simulation

Typically: "How do I... ", "How can I... " questions
Post Reply
Rodrigo
Posts: 28
Joined: 25 Aug 2014, 16:33

Fast Simulation

Post by Rodrigo » 22 Sep 2014, 13:34

Hi,

I am running evolutionary algorithms and I need very fast simulations, I am setting up a scene that receives some parameters from the Java remoteApi, runs the simulation using non-threaded Lua scrpits, and returns the results to Java when finished.

What would be a good configuration to speed up the simulation? would changing the Lua Scripts for a C plugin help speed up the simulation? I have also noticed that a lot of things get loaded when starting the simulator, is it possible to get a "bare bones" configuration of the simulator (I am already running in headless mode) to increase speed and how would that be achieved?

Also, I am using a flag inside the simulation, an IntegerSignal, to notify Java that the simulation is finished, is there another way to do this?

Thanks in advance.

Rodrigo

coppelia
Site Admin
Posts: 7190
Joined: 14 Dec 2012, 00:25

Re: Fast Simulation

Post by coppelia » 22 Sep 2014, 22:25

Hello Rodrigo,

you can disable individual plugins by taking them out of the V-REP folder (i.e. all files that start with v_repExt). Make sure to keep v_repExtRemoteApi, otherwise you will lose connectivity with your remote API client.

The remote API requests/signals/etc. are handled exactly one time for each simulation loop. This means that if your simulation loop runs slow, your remote API client will receive data in a sower manner. This is because it wouldn't make sense to send the same value (i.e. for a same simulation time t) over and over, knowing that is can only change in each simulation step.

If you need to communicate very quickly, and that communication doesn't directly depend on results from V-REP, then you can use a plugin that will communicate with a separate thread with your client (but in that case you would not use the remote API). Remember also that you can only access API functions in a plugins if you do this from the main thread.

Cheers

Rodrigo
Posts: 28
Joined: 25 Aug 2014, 16:33

Re: Fast Simulation

Post by Rodrigo » 24 Sep 2014, 09:57

Hi,


Thanks, but yes the signal still depends on results from V-REP as the simulation has to meet certain conditions for stopping and sending back data to Java.

About the plugin, my question is: if I use a plugin to control each robot (I have several robots communicating with each other) instead of implementing the controllers using Lua scripts, will my simulation run faster?

Still I have to ask, what is the best configuration for speed, even if the simulation is not accurate? for example which physics engine runs faster or which parameters can I change inside the simulator or the physics engine? Another person suggested recompiling the source code for the specific machine, I am using version 3.1.3beta, where can I get the source code for this version?

Thanks!

coppelia
Site Admin
Posts: 7190
Joined: 14 Dec 2012, 00:25

Re: Fast Simulation

Post by coppelia » 24 Sep 2014, 12:28

if you use a plugin, then the language code will run faster, since C/C++ is faster than Lua. But the API function calls will run at the exact same speed in both cases.

You can adjust several things in order to run a simulation faster:
  • you can increase the simulation step size. The simulation will run faster, but individual simulation steps not. You can do this in the simulation settings dialog.
  • you can handle sensor reading explicitely, and not in each simulation step. For that, check the explicit handling check-box for each of the sensors you wish to manually handle. Then, each time you wish to handle your sensor, call simHandleProximitySensor (or similar) on it.
  • you can reduce the number of dynamic calculation steps: by default, V-REP will run 10 dynamic calculation steps in each simulation step, this in order to have stable dynamics. If you reduce that number, you will run faster, but dynamic simulation will be less stable/accurate. You can do this in the dynamics engine general properties.
  • you can adjust other parameters of the specific physics engine (e.g. constraint solving iterations). Here too, the simulation will run faster, but be less stable/accurate.
The easiest would be to select a different predefined physics engine setting in the toolbar (on the right hand side of the selected physics engine). Depending on your simulation setting, Bullet, ODE or Vortex might run faster, you will have to try this out.

Cheers

Post Reply