Simulation Execution and Playback

Starting a Simulation

To start a simulation, perform the following operations after completing Creating a Simulation Project:

  1. Select the target simulator item in the item tree view

  2. Press the simulation start button

Operation 1 is not necessary if only one simulator item exists. In this case, since there is only one simulation to execute, no operation is needed to identify it.

On the other hand, a project can contain multiple simulator items. This is useful when you want to prepare multiple simulation items with different parameters, run simulations for each, and compare the results. In such cases, you need to select a simulator item to identify which simulation to execute.

Note

Remember that identifying the target simulator item applies to pause and stop operations as well, which are explained below. In any case, if only one simulator item exists, you don’t need to worry about this.

For operation 2, use the buttons on the simulation bar. Normally, use the following “Start simulation” button to start a simulation:

../_images/SimulationBar_StartButton.png

When you start a simulation with this button, it begins from the position and orientation of the initial state registered in Setting Initial State.

You can also use the following “Resume simulation” button to start a simulation:

../_images/simbar-restart-button.png

In this case, unlike with the start button, the simulation starts from the current model state rather than the registered initial state.

Pausing a Simulation

You can pause a running simulation by pressing the following pause button:

../_images/simbar-pause-button.png

Press this button again or the “Resume simulation” button mentioned earlier to resume the paused simulation.

Stopping a Simulation

Press the following “Stop simulation” button to stop a simulation:

../_images/simbar-stop-button.png

In this case, unlike pausing, all elements involved in the simulation (including controllers) are terminated (as much as possible). Therefore, you cannot resume from exactly the same state as when it was stopped. (You can start a simulation from the position and orientation at the time of stopping using the “Resume simulation” button, but this only sets those as the initial position and orientation, and the simulation restarts with all other elements initialized.)

On the other hand, resources used for simulation execution are released, and it becomes possible to restart the simulation from an initialized state. Therefore, use the stop operation when you don’t need to resume the simulation.

Setting Time Range

You can configure when to end a simulation using the simulator item’s “Time range” property. Select from the following options:

  • Unlimited

Does not specify an end time. The simulation continues until an explicit stop operation is performed. This is the default setting.

  • Specified time

The simulation runs for the time specified in the “Time length” property.

  • Time bar range

The simulation runs for the time bar range.

※ The time specified here is the time in the virtual world within the simulator.

When the time range is set to anything other than “Unlimited”, the simulation automatically ends at the corresponding timing. In this case, no explicit stop operation is necessary. Of course, you can still stop the simulation midway with an explicit stop operation.

When the time range is set to “Unlimited”, the simulation continues until an explicit stop operation is performed.

In addition to these, the “Active control period only” property is also available. When this is set to true, the simulation runs only while controllers are actively performing control, and the simulation ends when all controllers finish their control.

Synchronization with Real Time

Generally, the progression of time in the virtual world where simulation occurs differs from that in the real world. The progression of time in the virtual world depends on the simulation’s computation time and can be faster or slower than the real world.

However, there are cases where you want to match the virtual world’s time progression to real time. One reason is that it’s easier to grasp the simulation’s progress. It’s also more suitable when you want interaction between the simulation and the real world. For example, when a real-world operator controls a robot during simulation, having synchronized time progression provides a sensation closer to operating an actual robot.

In Choreonoid, matching the time progression between the virtual and real worlds is called “real-time synchronization”. This can be configured with the simulator item’s “Realtime sync” property, which is selected from the following options:

  • Off

No synchronization with real time is performed. The simulation progresses at the maximum speed the computation allows.

  • On (Compensatory)

Synchronizes with real time. When the simulation falls behind real time due to slow computation, it tries to recover the delay to some extent by progressing faster than real time afterwards. This is the default setting.

  • On (Conservative)

Synchronizes with real time. This setting prioritizes that the simulation never runs ahead of real time; when a delay occurs, it does not try to recover it and re-synchronizes from the delayed point.

It’s usually best to run simulations with the default “On (Compensatory)” setting for clarity.

However, note that real-time synchronization is only effective when computation time is faster than real time. When computation time is slower than real time, the simulation’s time progression doesn’t change regardless of the synchronization setting. It’s impossible to make slow computation time faster.

Conversely, when computation time is faster than real time, turning off real-time synchronization allows the simulation to progress faster than real time. Try this setting when you want to reduce the time spent on simulation.

Recording and Playing Back Simulation Results

Simulation results can be recorded as time-series data of every physics computation step, which can be used for playing back and analyzing the results. Whether to record is configured with the “Recording” property of the simulator item. The default is the “tail” mode, which records the most recent period of a certain length.

Recorded results can be played back as an animation with the following operations:

  1. Select the target simulator item on the item tree view

  2. Operate the time bar

For time bar operations, pressing the play button displays an animation at a constant speed, and operating the time slider allows you to play back any part. See Time Axis Operations for details.

For the details of the recording modes, the recorded contents, saving the recorded results to files, the world log file that records to an external file, and everything else about recording and playing back logs, see Recording and Playing Back Logs.

Displaying Ongoing Simulations

When simulation result recording is enabled, ongoing simulation display also uses the playback function described above as “playback of data being recorded”. However, there are some behavioral differences between ongoing and completed simulation playback. Specifically:

  1. No additional playback operations are needed when starting a simulation. Animation of the result display starts without needing to reselect the simulator item or operate the time bar.

  2. During simulation, animation continues even if the simulator item is deselected. This continues until another simulator item is selected or an animation stop operation is performed.

  3. You can resume playback of an ongoing simulation by pressing the “Start simulation” or “Resume simulation” buttons on the simulation bar.

  4. When “Sync with ongoing updates” is on in the time bar settings, the latest state is always displayed during simulation.

Note that the simulation itself continues even if animation is stopped. You can restore the ongoing simulation display by performing operation 4. When restoring playback through normal operations, the setting in 4 is involved, so please be aware of this.

Note

When “Sync with ongoing updates” is off, the simulation’s internal progress and the animation progress displaying results don’t necessarily match. In that case, if you perform interactive operations on the ongoing simulation, responses may not return immediately, so caution is needed. This isn’t a problem if “Sync with ongoing updates” is on. It’s on by default.