Improvements to testspeed

Support named CLI flags, physics overrides, and refactor global state.

  - **Named CLI Flags**: Replaced standard positional arguments with named flags (`--nstep`, `--nthread`, `--noisestd`, `--noiserate`, `--npoolthread`) and preserved Google-wide flags compatibility (via custom argv compacting and InitGoogle).
  - **Physics Option Overrides**: Added support for configuring loaded model settings directly from the command line (`--solver`, `--cone`, `--jacobian`, `--integrator`, `--iterations`, `--tolerance`, `--sleep_tolerance`, `--noslip_iterations`).
  - **Encapsulated Thread State**: Consolidated loose global variables and per-thread rollout statistics arrays into a single data structure, `RolloutRunner runner`, simplifying mutli-threaded data boundaries.
  - **Readable Physics Options Printing**: Logged configured non-default options dynamically prior to rollout. Enums and active bitmask flags (e.g. disableflags/enableflags) are decoded into friendly strings (e.g., `Sleep : Enabled`).
  - **Tests & Docs**: Added testspeed_test.sh running testspeed over dominos.xml to check all overrides, registered shell test target in BUILD and CMakeLists.txt, and updated samples.rst documentation.

PiperOrigin-RevId: 942285912
Change-Id: Idb966fadfa0ccba0f1862f9d62bf83458b61939a
This commit is contained in:
Yuval Tassa
2026-07-03 16:52:02 -07:00
committed by Copybara-Service
parent 7c0d527005
commit 38f0ff3caa
4 changed files with 513 additions and 146 deletions
+42 -13
View File
@@ -21,34 +21,61 @@ the console. To simulate controlled dynamics instead of passive dynamics one can
.. code-block:: Shell
testspeed modelfile [nstep nthread ctrlnoise npoolthread]
testspeed [options] model
Where the command line arguments are
Where the command-line options and arguments are
.. list-table::
:width: 95%
:align: left
:widths: 1 1 5
:widths: 2 1 4
:header-rows: 1
* - Argument
* - Option
- Default
- Meaning
* - ``modelfile``
* - ``model``
- (required)
- path to model
* - ``nstep``
- path to model (positional argument)
* - ``--nstep=N``
- 10000
- number of steps per rollout
* - ``nthread``
* - ``--nthread=N``
- 1
- number of threads running parallel rollouts
* - ``ctrlnoise``
* - ``--noisestd=X``
- 0.01
- scale of pseudo-random noise injected into actuators
* - ``npoolthread``
- 1
* - ``--noiserate=X``
- 0.1
- rate of convergence to ctrl keyframe/midpoint
* - ``--npoolthread=N``
- 0
- number of threads in engine-internal threadpool
* - ``--solver=S``
- Newton
- override constraint solver algorithm (PGS, CG, Newton)
* - ``--cone=C``
- Pyramidal
- override friction cone type (Pyramidal, Elliptic)
* - ``--jacobian=J``
- Auto
- override constraint Jacobian type (Dense, Sparse, Auto)
* - ``--integrator=I``
- Euler
- override integration mode (Euler, RK4, Implicit, ImplicitFast)
* - ``--iterations=N``
- 100
- override solver iterations limit
* - ``--tolerance=X``
- 1e-8
- override solver convergence tolerance
* - ``--sleep_tolerance=X``
- 1e-4
- override sleep tolerance
* - ``--noslip_iterations=N``
- 0
- override noslip solver iterations limit
**Notes:**
@@ -58,8 +85,10 @@ Where the command line arguments are
logical cores.
- By default, the simulation starts from the model reference configuration with zero velocities. However, if a
keyframe named "test" is present in the model, it is used as the initial state.
- The ``ctrlnoise`` argument prevents models from settling into a static state where, due to warmstarts, one can
measure artificially faster simulation.
- The physics option override flags (such as ``--solver``) only override the model settings if they are explicitly
specified on the command line; otherwise, the model options configured in the XML file are preserved.
- The control noise arguments (``noisestd`` and ``noiserate``) prevent models from settling into a static state where,
due to warmstarts, one can measure artificially faster simulation.
- When ``npoolthread > 1`` is specified, an engine-internal thread pool is created with the specified number of
threads, to speed up simulation of large scenes. Note that while it is possible to use both ``nthread`` and
``npoolthread``, the scenarios for which one would want these different types of multithreading are usually mutually