pydrake.common

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.

Members:

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

kExponential = RandomDistribution.kExponential
kGaussian = RandomDistribution.kGaussian
kUniform = RandomDistribution.kUniform
name

(self – handle) -> str

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 https://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine

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.

Returns:

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.

Raises:
  • 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.
pydrake.common.trigger_an_assertion_failure() → None

Trigger a Drake C++ assertion failure