pydrake.common.FindResourceOrThrow(resource_path: str) → str

Convenient wrapper for querying FindResource(resource_path) followed by FindResourceResult::get_absolute_path_or_throw().

pydrake.common.GetDrakePath() → object

(Advanced) Returns the fully-qualified path to the first folder containing Drake resources as located by FindResource, or nullopt if none is found. For example ${result}/examples/pendulum/Pendulum.urdf would be the path to the Pendulum example’s URDF resource.

Most users should prefer FindResource() or FindResourceOrThrow() to locate Drake resources for a specific resource filename. This method only exists for legacy compatibility reasons, and might eventually be removed.

class pydrake.common.RandomDistribution

Drake supports explicit reasoning about a few carefully chosen random distributions.


kUniform : Vector elements are independent and uniformly distributed

kGaussian : Vector elements are independent and drawn from a

kExponential : Vector elements are independent and drawn from an

__init__(self: pydrake.common._module_py.RandomDistribution, value: int) → None
kExponential = <RandomDistribution.kExponential: 2>
kGaussian = <RandomDistribution.kGaussian: 1>
kUniform = <RandomDistribution.kUniform: 0>
class pydrake.common.RandomGenerator

Defines Drake’s canonical implementation of the UniformRandomBitGenerator C++ concept (as well as a few conventional extras beyond the concept, e.g., seeds). This uses the 32-bit Mersenne Twister mt19937 by Matsumoto and Nishimura, 1998. For more information, see

Note: For many workflows in drake, we aim to have computations that are fully deterministic given a single random seed. This is accomplished by passing a RandomGenerator object. To generate random numbers in numpy that are deterministic given the C++ random seed (see drake issue #12632 for the discussion), use e.g.

generator = pydrake.common.RandomGenerator()
random_state = numpy.random.RandomState(generator())

my_random_value = random_state.uniform()
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.common._module_py.RandomGenerator) -> None

Default constructor. Seeds the engine with the default_seed.

  1. __init__(self: pydrake.common._module_py.RandomGenerator, arg0: int) -> None

Constructs the engine and initializes the state with a given value.

pydrake.common.set_assertion_failure_to_throw_exception() → None

Set Drake’s assertion failure mechanism to be exceptions

pydrake.common.set_log_level(level: str) → str

Invokes drake::log()->set_level(level).

Parameter level:
Must be a string from spdlog enumerations: trace, debug, info, warn, err, critical, off, or unchanged (not an enum, but useful for command-line).
Returns:The string value of the previous log level. If SPDLOG is disabled, then this returns an empty string.
pydrake.common.temp_directory() → str

Returns a directory location suitable for temporary files.


The value of the environment variable TEST_TMPDIR if defined or otherwise ${TMPDIR:-/tmp}/robotlocomotion_drake_XXXXXX where each X is replaced by a character from the portable filename character set. Any trailing / will be stripped from the output.

  • RuntimeError If the path referred to by TEST_TMPDIR or
  • ${TMPDIR – -/tmp}/robotlocomotion_drake_XXXXXX cannot be created,
  • does not exist, or is not a directory.
class pydrake.common.ToleranceType


kAbsolute :

kRelative :

__init__(self: pydrake.common._module_py.ToleranceType, value: int) → None
absolute = <ToleranceType.kAbsolute: 0>
kAbsolute = <ToleranceType.kAbsolute: 0>
kRelative = <ToleranceType.kRelative: 1>
relative = <ToleranceType.kRelative: 1>
pydrake.common.trigger_an_assertion_failure() → None

Trigger a Drake C++ assertion failure