Drake
Drake C++ Documentation
Loading...
Searching...
No Matches
drake Namespace Reference

Namespaces

namespace  assert
namespace  common
namespace  examples
namespace  geometry
namespace  lcm
namespace  logging
namespace  manipulation
namespace  math
namespace  multibody
namespace  perception
namespace  planning
namespace  schema
namespace  solvers
namespace  symbolic
namespace  systems
namespace  trajectories
namespace  visualization
namespace  yaml

Classes

class  AbstractValue
 A fully type-erased container class. More...
class  copyable_unique_ptr
 A smart pointer with deep copy semantics. More...
struct  DelegatingHasher
 An adapter that forwards the HashAlgorithm::operator(data, length) function concept into a runtime-provided std::function of the same signature. More...
struct  dummy_value
 Provides a "dummy" value for a ScalarType – a value that is unlikely to be mistaken for a purposefully-computed value, useful for initializing a value before the true result is available. More...
struct  dummy_value< Eigen::AutoDiffScalar< DerType > >
 Specializes common/dummy_value.h.
struct  dummy_value< int >
struct  dummy_value< symbolic::Expression >
 Specializes common/dummy_value.h. More...
class  EigenPtr
 This wrapper class provides a way to write non-template functions taking raw pointers to Eigen objects as parameters while limiting the number of copies, similar to Eigen::Ref. More...
class  FindResourceResult
 Models the outcome of drake::FindResource. More...
class  Identifier
 A simple identifier class. More...
struct  is_eigen_nonvector_expression_double_pair
struct  is_eigen_nonvector_of
struct  is_eigen_scalar_same
struct  is_eigen_type
struct  is_eigen_vector
struct  is_eigen_vector_expression_double_pair
struct  is_eigen_vector_of
class  ManualTimer
 Implementation of timing for use with unit tests that control time manually. More...
class  MemoryFile
 A virtual file, stored in memory. More...
class  NameValue
 (Advanced) A basic implementation of the Name-Value Pair concept as used in the Serialize / Archive pattern. More...
class  never_destroyed
 Wraps an underlying type T such that its storage is a direct member field of this object (i.e., without any indirection into the heap), but unlike most member fields T's destructor is never invoked. More...
class  NiceTypeName
 Obtains canonicalized, platform-independent, human-readable names for arbitrarily-complicated C++ types. More...
struct  ostream_formatter
 When using fmt >= 9, this is an alias for fmt::ostream_formatter. More...
class  Parallelism
 Specifies a desired degree of parallelism for a parallelized operation. More...
class  Polynomial
 A scalar multi-variate polynomial, modeled after the msspoly in spotless. More...
class  RandomGenerator
 Defines Drake's canonical implementation of the UniformRandomBitGenerator C++ concept (as well as a few conventional extras beyond the concept, e.g., seeds). More...
class  reset_after_move
 Type wrapper that performs value-initialization on the wrapped type, and guarantees that when moving from this type that the donor object is reset to its value-initialized value. More...
class  reset_on_copy
 Type wrapper that performs value-initialization on copy construction or assignment. More...
struct  RlocationOrError
 (Advanced.) The return type of FindRunfile(). More...
struct  scalar_predicate
 A traits struct that describes the return type of predicates over a scalar type (named T). More...
class  ScopeExit
 Helper class to create a scope exit guard – an object that when destroyed runs func. More...
class  Sha256
 Represents a SHA-256 cryptographic checksum. More...
struct  SortedPair
 This class is similar to the std::pair class. More...
class  SteadyTimer
 Implementation of timing utility that uses monotonic std::chrono::steady_clock. More...
class  Timer
 Abstract base class for timing utility. More...
class  TypeSafeIndex
 A type-safe non-negative index class. More...
struct  uhash
 A hashing functor, somewhat like std::hash. More...
class  Value
 A container class for an arbitrary type T (with some restrictions). More...

Typedefs

template<typename T>
using boolean = typename scalar_predicate<T>::type
 An alias for a boolean-like value, conditioned on the scalar type T.
using AutoDiffXd = Eigen::AutoDiffScalar<Eigen::VectorXd>
 An autodiff variable with a dynamic number of partials.
template<int num_vars>
using AutoDiffd = Eigen::AutoDiffScalar<Eigen::Matrix<double, num_vars, 1> >
 An autodiff variable with num_vars partials.
template<int num_vars, int rows>
using AutoDiffVecd = Eigen::Matrix<AutoDiffd<num_vars>, rows, 1>
 A vector of rows autodiff variables, each with num_vars partials.
typedef AutoDiffVecd< Eigen::Dynamic, Eigen::Dynamic > AutoDiffVecXd
 A dynamic-sized vector of autodiff variables, each with a dynamic-sized vector of partials.
template<typename Scalar>
using Vector0 = Eigen::Matrix<Scalar, 0, 1>
 The empty column vector (zero rows, one column), templated on scalar type.
template<typename Scalar>
using Vector1 = Eigen::Matrix<Scalar, 1, 1>
 A column vector of size 1 (that is, a scalar), templated on scalar type.
using Vector1d = Eigen::Matrix<double, 1, 1>
 A column vector of size 1 of doubles.
template<typename Scalar>
using Vector2 = Eigen::Matrix<Scalar, 2, 1>
 A column vector of size 2, templated on scalar type.
template<typename Scalar>
using Vector3 = Eigen::Matrix<Scalar, 3, 1>
 A column vector of size 3, templated on scalar type.
template<typename Scalar>
using Vector4 = Eigen::Matrix<Scalar, 4, 1>
 A column vector of size 4, templated on scalar type.
template<typename Scalar>
using Vector6 = Eigen::Matrix<Scalar, 6, 1>
 A column vector of size 6.
using Vector6d = Eigen::Matrix<double, 6, 1>
 A column vector of size 6 of doubles.
template<typename Scalar, int Rows>
using Vector = Eigen::Matrix<Scalar, Rows, 1>
 A column vector templated on the number of rows.
template<typename Scalar>
using VectorX = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>
 A column vector of any size, templated on scalar type.
template<typename Scalar>
using VectorUpTo6 = Eigen::Matrix<Scalar, Eigen::Dynamic, 1, 0, 6, 1>
 A vector of dynamic size templated on scalar type, up to a maximum of 6 elements.
template<typename Scalar>
using RowVector2 = Eigen::Matrix<Scalar, 1, 2>
 A row vector of size 2, templated on scalar type.
template<typename Scalar>
using RowVector3 = Eigen::Matrix<Scalar, 1, 3>
 A row vector of size 3, templated on scalar type.
template<typename Scalar>
using RowVector4 = Eigen::Matrix<Scalar, 1, 4>
 A row vector of size 4, templated on scalar type.
template<typename Scalar>
using RowVector6 = Eigen::Matrix<Scalar, 1, 6>
 A row vector of size 6.
template<typename Scalar, int Cols>
using RowVector = Eigen::Matrix<Scalar, 1, Cols>
 A row vector templated on the number of columns.
template<typename Scalar>
using RowVectorX = Eigen::Matrix<Scalar, 1, Eigen::Dynamic>
 A row vector of any size, templated on scalar type.
template<typename Scalar>
using Matrix2 = Eigen::Matrix<Scalar, 2, 2>
 A matrix of 2 rows and 2 columns, templated on scalar type.
template<typename Scalar>
using Matrix3 = Eigen::Matrix<Scalar, 3, 3>
 A matrix of 3 rows and 3 columns, templated on scalar type.
template<typename Scalar>
using Matrix4 = Eigen::Matrix<Scalar, 4, 4>
 A matrix of 4 rows and 4 columns, templated on scalar type.
template<typename Scalar>
using Matrix6 = Eigen::Matrix<Scalar, 6, 6>
 A matrix of 6 rows and 6 columns, templated on scalar type.
template<typename Scalar>
using Matrix2X = Eigen::Matrix<Scalar, 2, Eigen::Dynamic>
 A matrix of 2 rows, dynamic columns, templated on scalar type.
template<typename Scalar>
using Matrix3X = Eigen::Matrix<Scalar, 3, Eigen::Dynamic>
 A matrix of 3 rows, dynamic columns, templated on scalar type.
template<typename Scalar>
using Matrix4X = Eigen::Matrix<Scalar, 4, Eigen::Dynamic>
 A matrix of 4 rows, dynamic columns, templated on scalar type.
template<typename Scalar>
using Matrix6X = Eigen::Matrix<Scalar, 6, Eigen::Dynamic>
 A matrix of 6 rows, dynamic columns, templated on scalar type.
template<typename Scalar>
using MatrixX = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
 A matrix of dynamic size, templated on scalar type.
template<typename Scalar>
using MatrixUpTo6
 A matrix of dynamic size templated on scalar type, up to a maximum of 6 rows and 6 columns.
template<typename Scalar>
using Matrix6xUpTo6 = Eigen::Matrix<Scalar, 6, Eigen::Dynamic, 0, 6, 6>
 A matrix of 6 rows and dynamic column size up to a maximum of 6, templated on scalar type.
template<typename Scalar, typename Derived>
using MatrixLikewise
 A matrix with the same compile-time sizes and storage order as Derived, but with a different scalar type and its default alignment (Eigen::AutoAlign).
using StrideX = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>
 A fully dynamic Eigen stride.
template<typename Scalar>
using Quaternion = Eigen::Quaternion<Scalar>
 A quaternion templated on scalar type.
template<typename Scalar>
using AngleAxis = Eigen::AngleAxis<Scalar>
 An AngleAxis templated on scalar type.
template<typename Scalar>
using Isometry3 = Eigen::Transform<Scalar, 3, Eigen::Isometry>
 An Isometry templated on scalar type.
using FileSource = std::variant<std::filesystem::path, MemoryFile>
 Represents a file.
using DefaultHasher = internal::FNV1aHasher
 The default HashAlgorithm concept implementation across Drake.
using DefaultHash = drake::uhash<DefaultHasher>
 The default hashing functor, akin to std::hash.
template<typename T>
using is_cloneable = is_cloneable_internal::is_cloneable_helper<T, void>
 Provides method for determining at run time if a class is "cloneable".
typedef Polynomial< doublePolynomiald
typedef Eigen::Matrix< Polynomiald, Eigen::Dynamic, 1 > VectorXPoly
 A column vector of polynomials; used in several optimization classes.
template<typename T>
using string_map = std::map<std::string, T, std::less<void>>
 Like std::map<std::string, T>, but with better defaults than the plain std::map<std::string, T> spelling.
template<typename T>
using string_multimap = std::multimap<std::string, T, std::less<void>>
 Like std::multimap<std::string, T>, but with better defaults than the plain std::multimap<std::string, T> spelling.
using string_set = std::set<std::string, std::less<void>>
 Like std::set<std::string>, but with better defaults than the plain std::set<std::string> spelling.
using string_multiset = std::multiset<std::string, std::less<void>>
 Like std::multiset<std::string>, but with better defaults than the plain std::multiset<std::string> spelling.
template<typename T>
using string_unordered_map
 Like std::unordered_map<std::string, T>, but with better defaults than the plain std::unordered_map<std::string, T> spelling.
template<typename T>
using string_unordered_multimap
 Like std::unordered_multimap<std::string, T>, but with better defaults than the plain std::unordered_multimap<std::string, T> spelling.
using string_unordered_set
 Like std::unordered_set<std::string>, but with better defaults than the plain std::unordered_set<std::string> spelling.
using string_unordered_multiset
 Like std::unordered_multiset<std::string>, but with better defaults than the plain std::unordered_multiset<std::string> spelling.

Enumerations

enum class  ToleranceType { kAbsolute , kRelative }
enum class  RandomDistribution { kUniform = 0 , kGaussian = 1 , kExponential = 2 }
 Drake supports explicit reasoning about a few carefully chosen random distributions. More...

Functions

template<typename DerType>
double ExtractDoubleOrThrow (const Eigen::AutoDiffScalar< DerType > &scalar)
 Returns the autodiff scalar's value() as a double.
template<typename DerType, int RowsAtCompileTime, int ColsAtCompileTime, int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime>
auto ExtractDoubleOrThrow (const Eigen::MatrixBase< Eigen::Matrix< Eigen::AutoDiffScalar< DerType >, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > > &matrix)
 Returns matrix as an Eigen::Matrix<double, ...> with the same size allocation as matrix.
template<typename DerType1, typename DerType2>
Eigen::AutoDiffScalar< typename Eigen::internal::remove_all< DerType1 >::type::PlainObject > if_then_else (bool f_cond, const Eigen::AutoDiffScalar< DerType1 > &x, const Eigen::AutoDiffScalar< DerType2 > &y)
 Provides if-then-else expression for Eigen::AutoDiffScalar type.
template<typename DerType, typename... Rest>
Eigen::AutoDiffScalar< typename Eigen::internal::remove_all< DerType >::type::PlainObject > cond (bool f_cond, const Eigen::AutoDiffScalar< DerType > &e_then, Rest... rest)
 Provides special case of cond expression for Eigen::AutoDiffScalar type.
double if_then_else (bool f_cond, double v_then, double v_else)
 Provides if-then-else expression for double.
template<typename Derived>
Derived::Scalar all (const Eigen::DenseBase< Derived > &m)
 Checks truth for all elements in matrix m.
template<typename Derived>
boolean< typename Derived::Scalar > all_of (const Eigen::MatrixBase< Derived > &m, const std::function< boolean< typename Derived::Scalar >(const typename Derived::Scalar &)> &pred)
 Checks if unary predicate pred holds for all elements in the matrix m.
template<typename Derived>
Derived::Scalar any (const Eigen::DenseBase< Derived > &m)
 Checks truth for at least one element in matrix m.
template<typename Derived>
boolean< typename Derived::Scalar > any_of (const Eigen::MatrixBase< Derived > &m, const std::function< boolean< typename Derived::Scalar >(const typename Derived::Scalar &)> &pred)
 Checks if unary predicate pred holds for at least one element in the matrix m.
template<typename Derived>
Derived::Scalar none (const Eigen::MatrixBase< Derived > &m)
 Checks that no elements of m are true. An empty matrix returns true.
template<typename Derived>
boolean< typename Derived::Scalar > none_of (const Eigen::MatrixBase< Derived > &m, const std::function< boolean< typename Derived::Scalar >(const typename Derived::Scalar &)> &pred)
 Checks if unary predicate pred holds for no elements in the matrix m.
template<typename T, int Rows>
auto if_then_else (const boolean< T > &f_cond, const Eigen::Matrix< T, Rows, 1 > &m_then, const Eigen::Matrix< T, Rows, 1 > &m_else)
 Overloads if_then_else for Eigen vectors of m_then and m_else values with with a single f_cond condition to toggle them all at once.
std::optional< std::string > MaybeGetDrakePath ()
 (Advanced) Returns the fully-qualified path to the first folder containing Drake resources as located by FindResource, or nullopt if none is found.
template<typename Container>
auto EigenMapView (Container &&c)
 Given a random access container (like std::vector, std::array, or C array), returns an Eigen::Map view into that container.
double ExtractDoubleOrThrow (double scalar)
 Returns scalar as a double. Never throws.
double ExtractDoubleOrThrow (float scalar)
 Returns scalar as a double. Never throws.
template<typename Derived>
std::enable_if_t< std::is_same_v< typename Derived::Scalar, double >, MatrixLikewise< double, Derived > > ExtractDoubleOrThrow (const Eigen::MatrixBase< Derived > &matrix)
 Returns matrix as an Eigen::Matrix<double, ...> with the same size allocation as matrix.
std::string to_string (const FileSource &source)
 Returns a string representation.
std::optional< std::string > LoadedLibraryPath (const std::string &library_name)
 This function returns the absolute path of the library with the name library_name if that library was loaded in the current running process.
FindResourceResult FindResource (const std::string &resource_path)
 (Advanced) Attempts to locate a Drake resource named by the given resource_path.
std::string FindResourceOrThrow (const std::string &resource_path)
 (Advanced) Convenient wrapper for querying FindResource(resource_path) followed by FindResourceResult::get_absolute_path_or_throw().
std::optional< std::string > ReadFile (const std::filesystem::path &path)
 Returns the content of the file at the given path, or nullopt if it cannot be read.
std::string ReadFileOrThrow (const std::filesystem::path &path)
 Returns the content of the file at the given path, or throws if it cannot be read.
bool HasRunfiles ()
 (Advanced.) Returns true iff this process has Bazel runfiles available.
RlocationOrError FindRunfile (const std::string &resource_path, const std::string &source_repository={})
 (Advanced.) Returns the absolute path to the given resource_path from Bazel runfiles, or else an error message when not found.
auto fmt_runtime (std::string_view s)
 When using fmt >= 8, this is an alias for fmt::runtime.
template<typename T>
requires (std::is_same_v<T, float> || std::is_same_v<T, double>)
std::string fmt_floating_point (T x)
 Returns fmt::to_string(x) but always with at least one digit after the decimal point.
template<typename T>
requires (!(std::is_same_v<T, float> || std::is_same_v<T, double>))
std::string fmt_floating_point (T x)
 Returns fmt::to_string(x) but always with at least one digit after the decimal point.
std::string fmt_debug_string (std::string_view x)
 Returns fmt::("{:?}", x), i.e, using fmt's "debug string format"; see https://fmt.dev docs for the '?
template<typename Derived>
internal::fmt_eigen_ref< typename Derived::Scalar > fmt_eigen (const Eigen::MatrixBase< Derived > &matrix)
 When passing an Eigen::Matrix to fmt, use this wrapper function to instruct fmt to use Drake's custom formatter for Eigen types.
template<typename T>
auto fmt_streamed (const T &ref)
 When using fmt >= 9, this is an alias for fmt::streamed.
template<class HashAlgorithm, class T>
std::enable_if_t< std::is_integral_v< T > > hash_append (HashAlgorithm &hasher, const T &item) noexcept
 Provides hash_append generic hashing for integral constants.
template<class HashAlgorithm, class T>
void hash_append (HashAlgorithm &hasher, const T *item) noexcept
 Provides hash_append generic hashing for bare pointers.
template<class HashAlgorithm, class T>
std::enable_if_t< std::is_enum_v< T > > hash_append (HashAlgorithm &hasher, const T &item) noexcept
 Provides hash_append generic hashing for enumerations.
template<class HashAlgorithm, class T>
std::enable_if_t< std::is_floating_point_v< T > > hash_append (HashAlgorithm &hasher, const T &item) noexcept
 Provides hash_append generic hashing for floating point values.
template<class HashAlgorithm, class Traits, class Allocator>
void hash_append (HashAlgorithm &hasher, const std::basic_string< char, Traits, Allocator > &item) noexcept
 Provides hash_append generic hashing for std::string.
template<class HashAlgorithm, class T1, class T2>
void hash_append (HashAlgorithm &hasher, const std::pair< T1, T2 > &item) noexcept
 Provides hash_append generic hashing for std::pair.
template<class HashAlgorithm, class T>
void hash_append (HashAlgorithm &hasher, const std::optional< T > &item) noexcept
 Provides hash_append generic hashing for std::optional.
template<class HashAlgorithm, class T1, class T2, class Compare, class Allocator>
void hash_append (HashAlgorithm &hasher, const std::map< T1, T2, Compare, Allocator > &item) noexcept
 Provides hash_append generic hashing for std::map.
template<class HashAlgorithm, class Key, class Compare, class Allocator>
void hash_append (HashAlgorithm &hasher, const std::set< Key, Compare, Allocator > &item) noexcept
 Provides hash_append generic hashing for std::set.
template<class HashAlgorithm, class Iter>
void hash_append_range (HashAlgorithm &hasher, Iter begin, Iter end) noexcept
 Provides hash_append generic hashing for a range, as given by two iterators.
template<typename Tag>
std::string to_string (const drake::Identifier< Tag > &id)
 Enables use of identifiers with to_string.
template<typename DerivedA, typename DerivedB>
bool is_approx_equal_abstol (const Eigen::MatrixBase< DerivedA > &m1, const Eigen::MatrixBase< DerivedB > &m2, double tolerance)
 Returns true if and only if the two matrices are equal to within a certain absolute elementwise tolerance.
template<typename DerivedA, typename DerivedB>
bool IsApproxEqualAbsTolWithPermutedColumns (const Eigen::MatrixBase< DerivedA > &m1, const Eigen::MatrixBase< DerivedB > &m2, double tolerance)
 Returns true if and only if a simple greedy search reveals a permutation of the columns of m2 to make the matrix equal to m1 to within a certain absolute elementwise tolerance.
template<typename T>
NameValue< T > MakeNameValue (const char *name, T *value)
 (Advanced) Creates a NameValue.
template<class T, class U>
std::unique_ptr< T > static_pointer_cast (std::unique_ptr< U > &&other) noexcept
 Casts the object owned by the std::unique_ptr other from type U to T; no runtime type checking is performed.
template<class T, class U>
std::unique_ptr< T > dynamic_pointer_cast (std::unique_ptr< U > &&other) noexcept
 Casts the object owned by the std::unique_ptr other from type U to T; if the cast fails, returns nullptr.
template<class T, class U>
std::unique_ptr< T > dynamic_pointer_cast_or_throw (std::unique_ptr< U > &&other)
 Casts the object owned by the std::unique_ptr other from type U to T; if other is nullptr or the cast fails, throws a std::exception.
template<class T, class U>
T * dynamic_pointer_cast_or_throw (U *other)
 Casts the pointer other from type U to T using dynamic_cast.
template<typename T>
Polynomial< T > pow (const Polynomial< T > &base, typename Polynomial< T >::PowerType exponent)
 Provides power function for Polynomial.
template<typename T, int Rows, int Cols>
std::ostream & operator<< (std::ostream &os, const Eigen::Matrix< Polynomial< T >, Rows, Cols > &poly_mat)
template<typename T>
CalcProbabilityDensity (RandomDistribution distribution, const Eigen::Ref< const VectorX< T > > &x)
 Calculates the density (probability density function) of the multivariate distribution.
template<class T>
bool operator== (const SortedPair< T > &x, const SortedPair< T > &y)
 Two pairs of the same type are equal iff their members are equal after sorting.
template<class T>
bool operator< (const SortedPair< T > &x, const SortedPair< T > &y)
 Compares two pairs using lexicographic ordering.
template<class T>
bool operator!= (const SortedPair< T > &x, const SortedPair< T > &y)
 Determine whether two SortedPair objects are not equal using operator==.
template<class T>
bool operator> (const SortedPair< T > &x, const SortedPair< T > &y)
 Determines whether x > y using operator<.
template<class T>
bool operator<= (const SortedPair< T > &x, const SortedPair< T > &y)
 Determines whether x <= y using operator<.
template<class T>
bool operator>= (const SortedPair< T > &x, const SortedPair< T > &y)
 Determines whether x >= y using operator<.
template<class T>
constexpr SortedPair< typename std::decay< T >::type > MakeSortedPair (T &&x, T &&y)
 A convenience wrapper for creating a sorted pair from two objects.
template<class C>
constexpr auto ssize (const C &c) -> std::common_type_t< std::ptrdiff_t, std::make_signed_t< decltype(c.size())> >
 Implements C++20 std::ssize() for earlier compilers.
template<class T, std::ptrdiff_t N>
constexpr std::ptrdiff_t ssize (const T(&array)[N]) noexcept
 This signature returns the size of built-in (C style) arrays.
template<typename... Rest>
symbolic::Expression cond (const symbolic::Formula &f_cond, double v_then, Rest... rest)
 Provides specialization of cond function defined in drake/common/cond.h file.
double ExtractDoubleOrThrow (const symbolic::Expression &e)
 Returns the symbolic expression's value() as a double.
template<typename Derived>
std::enable_if_t< std::is_same_v< typename Derived::Scalar, symbolic::Expression >, MatrixLikewise< double, Derived > > ExtractDoubleOrThrow (const Eigen::MatrixBase< Derived > &matrix)
 Returns matrix as an Eigen::Matrix<double, ...> with the same size allocation as matrix.
std::string temp_directory ()
 Returns a directory location suitable for temporary files.
logging::loggerlog ()
 Retrieve an instance of a logger to use for logging; for example:
template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator== (const U &value, const TypeSafeIndex< Tag > &tag)
template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator!= (const U &value, const TypeSafeIndex< Tag > &tag)
template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator< (const U &value, const TypeSafeIndex< Tag > &tag)
template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator<= (const U &value, const TypeSafeIndex< Tag > &tag)
template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator> (const U &value, const TypeSafeIndex< Tag > &tag)
template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator>= (const U &value, const TypeSafeIndex< Tag > &tag)
template<typename... Args>
void unused (const Args &...)
 Documents the argument(s) as unused, placating GCC's -Wunused-parameter warning.
template<typename Tag>
std::ostream & operator<< (std::ostream &out, const Identifier< Tag > &id)
 Streaming output operator.
cond

Constructs conditional expression (similar to Lisp's cond).

  cond(cond_1, expr_1,
       cond_2, expr_2,
          ...,   ...,
       cond_n, expr_n,
       expr_{n+1})

The value returned by the above cond expression is expr_1 if cond_1 is true; else if cond_2 is true then expr_2; ... ; else if cond_n is true then expr_n. If none of the conditions are true, it returns expr_{n+1}.

Note
This functions assumes that ScalarType provides operator< and the type of f_cond is the type of the return type of operator<(ScalarType, ScalarType). For example, symbolic::Expression can be used as a ScalarType because it provides symbolic::Formula operator<(symbolic::Expression, symbolic::Expression).
template<typename ScalarType>
ScalarType cond (const ScalarType &e)
template<typename ScalarType, typename... Rest>
ScalarType cond (const decltype(ScalarType()< ScalarType())&f_cond, const ScalarType &e_then, Rest... rest)

Variables

template<typename T>
constexpr bool is_default_scalar
static constexpr auto eigen_all = Eigen::placeholders::all
 A portable alias for Eigen::placeholders::all.
const char *const kDrakeResourceRootEnvironmentVariableName
 The name of the environment variable that provides the first place where FindResource attempts to look.

Typedef Documentation

◆ AngleAxis

template<typename Scalar>
using AngleAxis = Eigen::AngleAxis<Scalar>

An AngleAxis templated on scalar type.

◆ AutoDiffd

template<int num_vars>
using AutoDiffd = Eigen::AutoDiffScalar<Eigen::Matrix<double, num_vars, 1> >

An autodiff variable with num_vars partials.

◆ AutoDiffVecd

template<int num_vars, int rows>
using AutoDiffVecd = Eigen::Matrix<AutoDiffd<num_vars>, rows, 1>

A vector of rows autodiff variables, each with num_vars partials.

◆ AutoDiffVecXd

typedef AutoDiffVecd<Eigen::Dynamic, Eigen::Dynamic> AutoDiffVecXd

A dynamic-sized vector of autodiff variables, each with a dynamic-sized vector of partials.

◆ AutoDiffXd

using AutoDiffXd = Eigen::AutoDiffScalar<Eigen::VectorXd>

An autodiff variable with a dynamic number of partials.

◆ boolean

template<typename T>
using boolean = typename scalar_predicate<T>::type

An alias for a boolean-like value, conditioned on the scalar type T.

In many cases this will be a synonym for bool, e.g., when T = double. When T = symbolic::Expression, this is a synonym for symbolic::Formula. This is a convenience abbreviation for scalar_predicate<T>::type.

◆ DefaultHash

The default hashing functor, akin to std::hash.

◆ DefaultHasher

using DefaultHasher = internal::FNV1aHasher

The default HashAlgorithm concept implementation across Drake.

This is guaranteed to have a result_type of size_t to be compatible with std::hash.

◆ FileSource

using FileSource = std::variant<std::filesystem::path, MemoryFile>

Represents a file.

The file can be on-disk or in-memory.

◆ is_cloneable

template<typename T>
using is_cloneable = is_cloneable_internal::is_cloneable_helper<T, void>

Provides method for determining at run time if a class is "cloneable".

Usage

This gets used like type_traits functions (e.g., is_copy_constructible, is_same, etc.) To determine if a class is cloneable simply invoke:

is_cloneable_internal::is_cloneable_helper< T, void > is_cloneable
Provides method for determining at run time if a class is "cloneable".
Definition is_cloneable.h:81

If Foo is cloneable, it will evaluate to true. It can also be used in compile-time tests (e.g., SFINAE and static_asserts):

static_assert(is_cloneable<Foo>::value, "This method requires its classes to "
"be cloneable.");

Definition of "cloneability"

To be cloneable, the class Foo must have a public method of the form:

unique_ptr<Foo> Foo::Clone() const;

Note that "friend" access for the is_cloneable-using class is not sufficient. The Foo::Clone() method must actually be public.

The pointer contained in the returned unique_ptr must point to a heap-allocated deep copy of the concrete object. This test can confirm the proper signature, but cannot confirm the heap-allocated deep copy. A Clone() method that doesn't return such a copy of the concrete object should be considered a malformed function.

Warning
It is important to note, that a Clone() method that returns a unique_ptr to a super class is not sufficient to be cloneable. In other words the presence of:
unique_ptr<Base> Derived::Clone() const;
will not make the Derived class cloneable.
Template Parameters
TThe class to test for cloneability.

◆ Isometry3

template<typename Scalar>
using Isometry3 = Eigen::Transform<Scalar, 3, Eigen::Isometry>

An Isometry templated on scalar type.

◆ Matrix2

template<typename Scalar>
using Matrix2 = Eigen::Matrix<Scalar, 2, 2>

A matrix of 2 rows and 2 columns, templated on scalar type.

◆ Matrix2X

template<typename Scalar>
using Matrix2X = Eigen::Matrix<Scalar, 2, Eigen::Dynamic>

A matrix of 2 rows, dynamic columns, templated on scalar type.

◆ Matrix3

template<typename Scalar>
using Matrix3 = Eigen::Matrix<Scalar, 3, 3>

A matrix of 3 rows and 3 columns, templated on scalar type.

◆ Matrix3X

template<typename Scalar>
using Matrix3X = Eigen::Matrix<Scalar, 3, Eigen::Dynamic>

A matrix of 3 rows, dynamic columns, templated on scalar type.

◆ Matrix4

template<typename Scalar>
using Matrix4 = Eigen::Matrix<Scalar, 4, 4>

A matrix of 4 rows and 4 columns, templated on scalar type.

◆ Matrix4X

template<typename Scalar>
using Matrix4X = Eigen::Matrix<Scalar, 4, Eigen::Dynamic>

A matrix of 4 rows, dynamic columns, templated on scalar type.

◆ Matrix6

template<typename Scalar>
using Matrix6 = Eigen::Matrix<Scalar, 6, 6>

A matrix of 6 rows and 6 columns, templated on scalar type.

◆ Matrix6X

template<typename Scalar>
using Matrix6X = Eigen::Matrix<Scalar, 6, Eigen::Dynamic>

A matrix of 6 rows, dynamic columns, templated on scalar type.

◆ Matrix6xUpTo6

template<typename Scalar>
using Matrix6xUpTo6 = Eigen::Matrix<Scalar, 6, Eigen::Dynamic, 0, 6, 6>

A matrix of 6 rows and dynamic column size up to a maximum of 6, templated on scalar type.

◆ MatrixLikewise

template<typename Scalar, typename Derived>
using MatrixLikewise
Initial value:
Eigen::Matrix<Scalar, Derived::RowsAtCompileTime,
Derived::ColsAtCompileTime,
Derived::IsRowMajor ? Eigen::RowMajor : Eigen::ColMajor,
Derived::MaxRowsAtCompileTime, Derived::MaxColsAtCompileTime>

A matrix with the same compile-time sizes and storage order as Derived, but with a different scalar type and its default alignment (Eigen::AutoAlign).

◆ MatrixUpTo6

template<typename Scalar>
using MatrixUpTo6
Initial value:
Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, 0, 6, 6>

A matrix of dynamic size templated on scalar type, up to a maximum of 6 rows and 6 columns.

Rectangular matrices, with different number of rows and columns, are allowed.

◆ MatrixX

template<typename Scalar>
using MatrixX = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>

A matrix of dynamic size, templated on scalar type.

◆ Polynomiald

◆ Quaternion

template<typename Scalar>
using Quaternion = Eigen::Quaternion<Scalar>

A quaternion templated on scalar type.

◆ RowVector

template<typename Scalar, int Cols>
using RowVector = Eigen::Matrix<Scalar, 1, Cols>

A row vector templated on the number of columns.

◆ RowVector2

template<typename Scalar>
using RowVector2 = Eigen::Matrix<Scalar, 1, 2>

A row vector of size 2, templated on scalar type.

◆ RowVector3

template<typename Scalar>
using RowVector3 = Eigen::Matrix<Scalar, 1, 3>

A row vector of size 3, templated on scalar type.

◆ RowVector4

template<typename Scalar>
using RowVector4 = Eigen::Matrix<Scalar, 1, 4>

A row vector of size 4, templated on scalar type.

◆ RowVector6

template<typename Scalar>
using RowVector6 = Eigen::Matrix<Scalar, 1, 6>

A row vector of size 6.

◆ RowVectorX

template<typename Scalar>
using RowVectorX = Eigen::Matrix<Scalar, 1, Eigen::Dynamic>

A row vector of any size, templated on scalar type.

◆ StrideX

using StrideX = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>

A fully dynamic Eigen stride.

◆ string_map

template<typename T>
using string_map = std::map<std::string, T, std::less<void>>

Like std::map<std::string, T>, but with better defaults than the plain std::map<std::string, T> spelling.

We need std::less<void> as the comparison function so that std::string_view and const char* can be used as lookup keys without copying them to a std::string.

◆ string_multimap

template<typename T>
using string_multimap = std::multimap<std::string, T, std::less<void>>

Like std::multimap<std::string, T>, but with better defaults than the plain std::multimap<std::string, T> spelling.

We need std::less<void> as the comparison function so that std::string_view and const char* can be used as lookup keys without copying them to a std::string.

◆ string_multiset

using string_multiset = std::multiset<std::string, std::less<void>>

Like std::multiset<std::string>, but with better defaults than the plain std::multiset<std::string> spelling.

We need std::less<void> as the comparison function so that std::string_view and const char* can be used as lookup keys without copying them to a std::string.

◆ string_set

using string_set = std::set<std::string, std::less<void>>

Like std::set<std::string>, but with better defaults than the plain std::set<std::string> spelling.

We need std::less<void> as the comparison function so that std::string_view and const char* can be used as lookup keys without copying them to a std::string.

◆ string_unordered_map

template<typename T>
using string_unordered_map
Initial value:
std::unordered_map<std::string, T, internal::StringHash,
std::equal_to<void>>

Like std::unordered_map<std::string, T>, but with better defaults than the plain std::unordered_map<std::string, T> spelling.

We need the custom hash and comparison functions so that std::string_view and const char* can be used as lookup keys without copying them to a std::string.

◆ string_unordered_multimap

template<typename T>
using string_unordered_multimap
Initial value:
std::unordered_multimap<std::string, T, internal::StringHash,
std::equal_to<void>>

Like std::unordered_multimap<std::string, T>, but with better defaults than the plain std::unordered_multimap<std::string, T> spelling.

We need the custom hash and comparison functions so that std::string_view and const char* can be used as lookup keys without copying them to a std::string.

◆ string_unordered_multiset

Initial value:
std::unordered_multiset<std::string, internal::StringHash,
std::equal_to<void>>

Like std::unordered_multiset<std::string>, but with better defaults than the plain std::unordered_multiset<std::string> spelling.

We need the custom hash and comparison functions so that std::string_view and const char* can be used as lookup keys without copying them to a std::string.

◆ string_unordered_set

Initial value:
std::unordered_set<std::string, internal::StringHash, std::equal_to<void>>

Like std::unordered_set<std::string>, but with better defaults than the plain std::unordered_set<std::string> spelling.

We need the custom hash and comparison functions so that std::string_view and const char* can be used as lookup keys without copying them to a std::string.

◆ Vector

template<typename Scalar, int Rows>
using Vector = Eigen::Matrix<Scalar, Rows, 1>

A column vector templated on the number of rows.

◆ Vector0

template<typename Scalar>
using Vector0 = Eigen::Matrix<Scalar, 0, 1>

The empty column vector (zero rows, one column), templated on scalar type.

◆ Vector1

template<typename Scalar>
using Vector1 = Eigen::Matrix<Scalar, 1, 1>

A column vector of size 1 (that is, a scalar), templated on scalar type.

◆ Vector1d

using Vector1d = Eigen::Matrix<double, 1, 1>

A column vector of size 1 of doubles.

◆ Vector2

template<typename Scalar>
using Vector2 = Eigen::Matrix<Scalar, 2, 1>

A column vector of size 2, templated on scalar type.

◆ Vector3

template<typename Scalar>
using Vector3 = Eigen::Matrix<Scalar, 3, 1>

A column vector of size 3, templated on scalar type.

◆ Vector4

template<typename Scalar>
using Vector4 = Eigen::Matrix<Scalar, 4, 1>

A column vector of size 4, templated on scalar type.

◆ Vector6

template<typename Scalar>
using Vector6 = Eigen::Matrix<Scalar, 6, 1>

A column vector of size 6.

◆ Vector6d

using Vector6d = Eigen::Matrix<double, 6, 1>

A column vector of size 6 of doubles.

◆ VectorUpTo6

template<typename Scalar>
using VectorUpTo6 = Eigen::Matrix<Scalar, Eigen::Dynamic, 1, 0, 6, 1>

A vector of dynamic size templated on scalar type, up to a maximum of 6 elements.

◆ VectorX

template<typename Scalar>
using VectorX = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>

A column vector of any size, templated on scalar type.

◆ VectorXPoly

typedef Eigen::Matrix<Polynomiald, Eigen::Dynamic, 1> VectorXPoly

A column vector of polynomials; used in several optimization classes.

Enumeration Type Documentation

◆ RandomDistribution

enum class RandomDistribution
strong

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

Enumerator
kUniform 

Vector elements are independent and uniformly distributed ∈ [0.0, 1.0).

kGaussian 

Vector elements are independent and drawn from a mean-zero, unit-variance normal (Gaussian) distribution.

kExponential 

Vector elements are independent and drawn from an exponential distribution with λ=1.0.

◆ ToleranceType

enum class ToleranceType
strong
Enumerator
kAbsolute 
kRelative 

Function Documentation

◆ all()

template<typename Derived>
Derived::Scalar all ( const Eigen::DenseBase< Derived > & m)

Checks truth for all elements in matrix m.

This is identical to Eigen::DenseBase::all(), except this function allows for lazy evaluation, so works even when scalar_predicate<>::is_bool does not hold. An empty matrix returns true.

◆ all_of()

template<typename Derived>
boolean< typename Derived::Scalar > all_of ( const Eigen::MatrixBase< Derived > & m,
const std::function< boolean< typename Derived::Scalar >(const typename Derived::Scalar &)> & pred )

Checks if unary predicate pred holds for all elements in the matrix m.

An empty matrix returns true.

◆ any()

template<typename Derived>
Derived::Scalar any ( const Eigen::DenseBase< Derived > & m)

Checks truth for at least one element in matrix m.

This is identical to Eigen::DenseBase::any(), except this function allows for lazy evaluation, so works even when scalar_predicate<>::is_bool does not hold. An empty matrix returns false.

◆ any_of()

template<typename Derived>
boolean< typename Derived::Scalar > any_of ( const Eigen::MatrixBase< Derived > & m,
const std::function< boolean< typename Derived::Scalar >(const typename Derived::Scalar &)> & pred )

Checks if unary predicate pred holds for at least one element in the matrix m.

An empty matrix returns false.

◆ CalcProbabilityDensity()

template<typename T>
T CalcProbabilityDensity ( RandomDistribution distribution,
const Eigen::Ref< const VectorX< T > > & x )

Calculates the density (probability density function) of the multivariate distribution.

Parameters
distributionThe distribution type.
xThe value of the sampled vector.
Template Parameters
TThe scalar type, which must be one of the default nonsymbolic scalars.
Note
When instantiating this function, the user needs to explicitly pass in the scalar type, for example CalcProbabilityDensity<double>(...), the compiler might have problem to deduce the scalar type automatically.

◆ cond() [1/4]

template<typename DerType, typename... Rest>
Eigen::AutoDiffScalar< typename Eigen::internal::remove_all< DerType >::type::PlainObject > cond ( bool f_cond,
const Eigen::AutoDiffScalar< DerType > & e_then,
Rest... rest )

Provides special case of cond expression for Eigen::AutoDiffScalar type.

◆ cond() [2/4]

template<typename ScalarType, typename... Rest>
ScalarType cond ( const decltype(ScalarType()< ScalarType())& f_cond,
const ScalarType & e_then,
Rest... rest )

◆ cond() [3/4]

template<typename ScalarType>
ScalarType cond ( const ScalarType & e)

◆ cond() [4/4]

template<typename... Rest>
symbolic::Expression cond ( const symbolic::Formula & f_cond,
double v_then,
Rest... rest )

Provides specialization of cond function defined in drake/common/cond.h file.

This specialization is required to handle double to symbolic::Expression conversion so that we can write one such as cond(x > 0.0, 1.0, -1.0).

◆ dynamic_pointer_cast()

template<class T, class U>
std::unique_ptr< T > dynamic_pointer_cast ( std::unique_ptr< U > && other)
noexcept

Casts the object owned by the std::unique_ptr other from type U to T; if the cast fails, returns nullptr.

Casting is performed using dynamic_cast on the managed value (i.e., the result of other.get()). On success, other's managed value is transferred to the result and other is empty; on failure, other will retain its original managed value and the result is empty. As with dynamic_cast, casting nullptr to anything always succeeds, so a nullptr result could indicate either that the argument was nullptr or that the cast failed.

This method is analogous to the built-in std::dynamic_pointer_cast that operates on a std::shared_ptr.

Note that this function only supports default deleters.

◆ dynamic_pointer_cast_or_throw() [1/2]

template<class T, class U>
std::unique_ptr< T > dynamic_pointer_cast_or_throw ( std::unique_ptr< U > && other)

Casts the object owned by the std::unique_ptr other from type U to T; if other is nullptr or the cast fails, throws a std::exception.

Casting is performed using dynamic_cast on the managed value (i.e., the result of other.get()). On success, other's managed value is transferred to the result and other is empty; on failure, other will retain its original managed value.

Exceptions
std::exceptionif the cast fails.

Note that this function only supports default deleters.

◆ dynamic_pointer_cast_or_throw() [2/2]

template<class T, class U>
T * dynamic_pointer_cast_or_throw ( U * other)

Casts the pointer other from type U to T using dynamic_cast.

The result is never nullptr.

This differs from the C++ built-in dynamic_cast by providing a nicer exception message, and always throwing on any failure.

Exceptions
std::exceptionif other is nullptr or the cast fails.

◆ EigenMapView()

template<typename Container>
auto EigenMapView ( Container && c)

Given a random access container (like std::vector, std::array, or C array), returns an Eigen::Map view into that container.

Because this effectively forms a reference to borrowed memory, you must be be careful using the return value as anything other than a temporary. The Map return value currently uses Eigen::Dynamic size at compile time even when the container is fixed-size (e.g., std::array); if that ever turns into a performance bottleneck in practice, it would be plausible to interrogate the size and return a fixed-size Map, instead.

◆ ExtractDoubleOrThrow() [1/7]

template<typename DerType>
double ExtractDoubleOrThrow ( const Eigen::AutoDiffScalar< DerType > & scalar)

Returns the autodiff scalar's value() as a double.

Never throws. Overloads ExtractDoubleOrThrow from common/extract_double.h.

See also
math::ExtractValue(), math::DiscardGradient()

◆ ExtractDoubleOrThrow() [2/7]

template<typename Derived>
std::enable_if_t< std::is_same_v< typename Derived::Scalar, double >, MatrixLikewise< double, Derived > > ExtractDoubleOrThrow ( const Eigen::MatrixBase< Derived > & matrix)

Returns matrix as an Eigen::Matrix<double, ...> with the same size allocation as matrix.

Calls ExtractDoubleOrThrow on each element of the matrix, and therefore throws if any one of the extractions fail.

◆ ExtractDoubleOrThrow() [3/7]

template<typename Derived>
std::enable_if_t< std::is_same_v< typename Derived::Scalar, symbolic::Expression >, MatrixLikewise< double, Derived > > ExtractDoubleOrThrow ( const Eigen::MatrixBase< Derived > & matrix)

Returns matrix as an Eigen::Matrix<double, ...> with the same size allocation as matrix.

Calls ExtractDoubleOrThrow on each element of the matrix, and therefore throws if any one of the extractions fail.

◆ ExtractDoubleOrThrow() [4/7]

template<typename DerType, int RowsAtCompileTime, int ColsAtCompileTime, int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime>
auto ExtractDoubleOrThrow ( const Eigen::MatrixBase< Eigen::Matrix< Eigen::AutoDiffScalar< DerType >, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > > & matrix)

Returns matrix as an Eigen::Matrix<double, ...> with the same size allocation as matrix.

Calls ExtractDoubleOrThrow on each element of the matrix, and therefore throws if any one of the extractions fail.

See also
math::ExtractValue(), math::DiscardGradient()

◆ ExtractDoubleOrThrow() [5/7]

double ExtractDoubleOrThrow ( const symbolic::Expression & e)

Returns the symbolic expression's value() as a double.

Exceptions
std::exceptionif it is not possible to evaluate the symbolic expression with an empty environment.

◆ ExtractDoubleOrThrow() [6/7]

double ExtractDoubleOrThrow ( double scalar)

Returns scalar as a double. Never throws.

◆ ExtractDoubleOrThrow() [7/7]

double ExtractDoubleOrThrow ( float scalar)

Returns scalar as a double. Never throws.

◆ FindResource()

FindResourceResult FindResource ( const std::string & resource_path)

(Advanced) Attempts to locate a Drake resource named by the given resource_path.

The resource_path refers to the relative path within the Drake source repository, prepended with drake/. For example, to find the source file examples/pendulum/Pendulum.urdf, the resource_path would be drake/examples/pendulum/Pendulum.urdf. Paths that do not start with drake/ will return an error result. The resource_path must refer to a file (not a directory).

The search scans for the resource in the following resource roots and in the following order:

  1. In the DRAKE_RESOURCE_ROOT environment variable.
  2. In the Bazel runfiles for a bazel-bin/pkg/program.
  3. In the Drake CMake install directory.

The first resource root from the list that exists is used to find any and all Drake resources. If the resource root does not contain the resource, the result is an error even (if a resource root lower on the list happens to have the resource). If all three roots are unavailable, then returns an error result.

◆ FindResourceOrThrow()

std::string FindResourceOrThrow ( const std::string & resource_path)

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

The primary purpose of this function is for Drake's software internals to locate Drake resources (e.g., config files) within Drake's build system. In most cases, end users should not need to use it.

Do NOT use this function to feed into a drake::multibody::parsing::Parser. Instead, use parser.AddModelsFromUrl() in coordination with the parser's PackageMap.

◆ FindRunfile()

RlocationOrError FindRunfile ( const std::string & resource_path,
const std::string & source_repository = {} )

(Advanced.) Returns the absolute path to the given resource_path from Bazel runfiles, or else an error message when not found.

When HasRunfiles() is false, returns an error.

Note
For Drake Developers, note that in an installed copy of Drake (e.g., in a binary release) the HasRunfiles() check will return false, so this function will return an error. That means it's generally ill-advised to call this function from library code inside Drake, or if you do you'll need to have a fallback plan in case of an error. Typically our library code should be calling FindResource() not FindRunfile(). On the other hand, for our private code like unit tests and benchmarks, it's fine to call this function and in those programs it's also fine to leave the source_repository defaulted (empty).
Parameters
resource_pathThe path to find, formulated as the repository name followed by package and filename, e.g., "repository/topdir/subdir/file.ext". Drake resource paths look like "drake/common/foo.txt".
source_repositoryWhen looking up a Drake runfile, this value is ignored (and therefore may be set to anything). Otherwise, it should be set to the value of the preprocessor definition BAZEL_CURRENT_REPOSITORY or else when running with bzlmod enabled you risk using an incorrect repo_mapping. That preprocessor definition is Bazel magic that takes on different values depending on which translation unit is being compiled (and is undefined unless you add Bazel's runfiles library to your own library's deps = ... directly), so cannot be used as the default value here.

◆ fmt_debug_string()

std::string fmt_debug_string ( std::string_view x)

Returns fmt::("{:?}", x), i.e, using fmt's "debug string format"; see https://fmt.dev docs for the '?

' presentation type for details. We provide this wrapper because not all of our supported platforms have a new-enough fmt to rely on it. On platforms with older fmt, we use a Drake re-implementation of the feature that does NOT handle unicode correctly.

◆ fmt_eigen()

template<typename Derived>
internal::fmt_eigen_ref< typename Derived::Scalar > fmt_eigen ( const Eigen::MatrixBase< Derived > & matrix)

When passing an Eigen::Matrix to fmt, use this wrapper function to instruct fmt to use Drake's custom formatter for Eigen types.

Within Drake, when formatting an Eigen matrix into a string you must wrap the Eigen object as fmt_eigen(M). This holds true whether it be for logging, error messages, debugging, or etc.

For example:

if (!CheckValid(M)) {
throw std::logic_error(fmt::format("Invalid M = {}", fmt_eigen(M)));
}
internal::fmt_eigen_ref< typename Derived::Scalar > fmt_eigen(const Eigen::MatrixBase< Derived > &matrix)
When passing an Eigen::Matrix to fmt, use this wrapper function to instruct fmt to use Drake's custom...
Definition fmt_eigen.h:77
Warning
The return value of this function should only ever be used as a temporary object, i.e., in a fmt argument list or a logging statement argument list. Never store it as a local variable, member field, etc.
Note
To ensure floating-point data is formatted without losing any digits, Drake's code is compiled using -DEIGEN_NO_IO, which enforces that nothing within Drake is allowed to use Eigen's operator<<. Downstream code that calls into Drake is not required to use that option; it is only enforced by Drake's build system, not by Drake's headers.

◆ fmt_floating_point() [1/2]

template<typename T>
requires (std::is_same_v<T, float> || std::is_same_v<T, double>)
std::string fmt_floating_point ( T x)

Returns fmt::to_string(x) but always with at least one digit after the decimal point.

Different versions of fmt disagree on whether to omit the trailing ".0" when formatting integer-valued floating-point numbers.

Template Parameters
Tmust be either float or double.

◆ fmt_floating_point() [2/2]

template<typename T>
requires (!(std::is_same_v<T, float> || std::is_same_v<T, double>))
std::string fmt_floating_point ( T x)

Returns fmt::to_string(x) but always with at least one digit after the decimal point.

Different versions of fmt disagree on whether to omit the trailing ".0" when formatting integer-valued floating-point numbers.

Template Parameters
Tmust be either float or double.

◆ fmt_runtime()

auto fmt_runtime ( std::string_view s)

When using fmt >= 8, this is an alias for fmt::runtime.

When using fmt < 8, this is a no-op.

◆ fmt_streamed()

template<typename T>
auto fmt_streamed ( const T & ref)

When using fmt >= 9, this is an alias for fmt::streamed.

When using fmt < 9, this uses a polyfill instead.

Within Drake, the nominal use for fmt::streamed is when formatting third-party types that provide operator<< support but not fmt::formatter<T> support. Once we stop using FMT_DEPRECATED_OSTREAM=1, compilation errors will help you understand where you are required to use this wrapper.

◆ hash_append() [1/9]

template<class HashAlgorithm, class Traits, class Allocator>
void hash_append ( HashAlgorithm & hasher,
const std::basic_string< char, Traits, Allocator > & item )
noexcept

Provides hash_append generic hashing for std::string.

(Technically, any string based on CharT = char.)

◆ hash_append() [2/9]

template<class HashAlgorithm, class T1, class T2, class Compare, class Allocator>
void hash_append ( HashAlgorithm & hasher,
const std::map< T1, T2, Compare, Allocator > & item )
noexcept

Provides hash_append generic hashing for std::map.

Note that there is no hash_append overload for std::unordered_map. See N3980 for details.

◆ hash_append() [3/9]

template<class HashAlgorithm, class T>
void hash_append ( HashAlgorithm & hasher,
const std::optional< T > & item )
noexcept

Provides hash_append generic hashing for std::optional.

Note that std::hash<std::optional<T>> provides the peculiar invariant that the hash of an optional bearing a value v shall evaluate to the same hash as that of the value v itself. Hash operations implemented with this hash_append do not provide that invariant.

◆ hash_append() [4/9]

template<class HashAlgorithm, class T1, class T2>
void hash_append ( HashAlgorithm & hasher,
const std::pair< T1, T2 > & item )
noexcept

Provides hash_append generic hashing for std::pair.

◆ hash_append() [5/9]

template<class HashAlgorithm, class Key, class Compare, class Allocator>
void hash_append ( HashAlgorithm & hasher,
const std::set< Key, Compare, Allocator > & item )
noexcept

Provides hash_append generic hashing for std::set.

Note that there is no hash_append overload for std::unordered_set. See N3980 for details.

◆ hash_append() [6/9]

template<class HashAlgorithm, class T>
std::enable_if_t< std::is_integral_v< T > > hash_append ( HashAlgorithm & hasher,
const T & item )
noexcept

Provides hash_append generic hashing for integral constants.

◆ hash_append() [7/9]

template<class HashAlgorithm, class T>
std::enable_if_t< std::is_enum_v< T > > hash_append ( HashAlgorithm & hasher,
const T & item )
noexcept

Provides hash_append generic hashing for enumerations.

◆ hash_append() [8/9]

template<class HashAlgorithm, class T>
std::enable_if_t< std::is_floating_point_v< T > > hash_append ( HashAlgorithm & hasher,
const T & item )
noexcept

Provides hash_append generic hashing for floating point values.

◆ hash_append() [9/9]

template<class HashAlgorithm, class T>
void hash_append ( HashAlgorithm & hasher,
const T * item )
noexcept

Provides hash_append generic hashing for bare pointers.

◆ hash_append_range()

template<class HashAlgorithm, class Iter>
void hash_append_range ( HashAlgorithm & hasher,
Iter begin,
Iter end )
noexcept

Provides hash_append generic hashing for a range, as given by two iterators.

◆ HasRunfiles()

bool HasRunfiles ( )

(Advanced.) Returns true iff this process has Bazel runfiles available.

For both C++ and Python programs, and no matter what workspace a program resides in (@drake or otherwise), this will be true when running bazel-bin/pkg/program or bazel test //pkg:program or bazel run pkg:program.

◆ if_then_else() [1/3]

template<typename DerType1, typename DerType2>
Eigen::AutoDiffScalar< typename Eigen::internal::remove_all< DerType1 >::type::PlainObject > if_then_else ( bool f_cond,
const Eigen::AutoDiffScalar< DerType1 > & x,
const Eigen::AutoDiffScalar< DerType2 > & y )

Provides if-then-else expression for Eigen::AutoDiffScalar type.

To support Eigen's generic expressions, we use casting to the plain object after applying Eigen::internal::remove_all. It is based on the Eigen's implementation of min/max function for AutoDiffScalar type (https://bitbucket.org/eigen/eigen/src/10a1de58614569c9250df88bdfc6402024687bc6/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h?at=default&fileviewer=file-view-default#AutoDiffScalar.h-546).

◆ if_then_else() [2/3]

double if_then_else ( bool f_cond,
double v_then,
double v_else )

Provides if-then-else expression for double.

The value returned by the if-then-else expression is v_then if f_cond is true. Otherwise, it returns v_else. The semantics is similar but not exactly the same as C++'s conditional expression constructed by its ternary operator, ?:. In if_then_else(f_cond, v_then, v_else), both of v_then and v_else are evaluated regardless of the evaluation of f_cond. In contrast, only one of v_then or v_else is evaluated in C++'s conditional expression f_cond ? v_then : v_else.

◆ if_then_else() [3/3]

template<typename T, int Rows>
auto if_then_else ( const boolean< T > & f_cond,
const Eigen::Matrix< T, Rows, 1 > & m_then,
const Eigen::Matrix< T, Rows, 1 > & m_else )

Overloads if_then_else for Eigen vectors of m_then and m_else values with with a single f_cond condition to toggle them all at once.

◆ is_approx_equal_abstol()

template<typename DerivedA, typename DerivedB>
bool is_approx_equal_abstol ( const Eigen::MatrixBase< DerivedA > & m1,
const Eigen::MatrixBase< DerivedB > & m2,
double tolerance )

Returns true if and only if the two matrices are equal to within a certain absolute elementwise tolerance.

Special values (infinities, NaN, etc.) do not compare as equal elements.

◆ IsApproxEqualAbsTolWithPermutedColumns()

template<typename DerivedA, typename DerivedB>
bool IsApproxEqualAbsTolWithPermutedColumns ( const Eigen::MatrixBase< DerivedA > & m1,
const Eigen::MatrixBase< DerivedB > & m2,
double tolerance )

Returns true if and only if a simple greedy search reveals a permutation of the columns of m2 to make the matrix equal to m1 to within a certain absolute elementwise tolerance.

E.g., there exists a P such that

   forall i,j,  |m1 - m2*P|_{i,j} <= tolerance
   where P is a permutation matrix:
      P(i,j)={0,1}, sum_i P(i,j)=1, sum_j P(i,j)=1.

Note: Returns false for matrices of different sizes. Note: The current implementation is O(n^2) in the number of columns. Note: In marginal cases (with similar but not identical columns) this algorithm can fail to find a permutation P even if it exists because it accepts the first column match (m1(i),m2(j)) and removes m2(j) from the pool. It is possible that other columns of m2 would also match m1(i) but that m2(j) is the only match possible for a later column of m1.

◆ LoadedLibraryPath()

std::optional< std::string > LoadedLibraryPath ( const std::string & library_name)

This function returns the absolute path of the library with the name library_name if that library was loaded in the current running process.

Otherwise it returns an empty optional.

◆ log()

logging::logger * log ( )

Retrieve an instance of a logger to use for logging; for example:

  drake::log()->info("potato!")

See the text_logging.h documentation for a short tutorial.

◆ MakeNameValue()

template<typename T>
NameValue< T > MakeNameValue ( const char * name,
T * value )

(Advanced) Creates a NameValue.

The conventional method for calling this function is the DRAKE_NVP sugar macro below.

Both pointers are aliased for the lifetime of the return value.

◆ MakeSortedPair()

template<class T>
SortedPair< typename std::decay< T >::type > MakeSortedPair ( T && x,
T && y )
constexpr

A convenience wrapper for creating a sorted pair from two objects.

Parameters
xThe first_ object.
yThe second_ object.
Returns
A newly-constructed SortedPair object.

◆ MaybeGetDrakePath()

std::optional< std::string > MaybeGetDrakePath ( )

(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.

◆ none()

template<typename Derived>
Derived::Scalar none ( const Eigen::MatrixBase< Derived > & m)

Checks that no elements of m are true. An empty matrix returns true.

◆ none_of()

template<typename Derived>
boolean< typename Derived::Scalar > none_of ( const Eigen::MatrixBase< Derived > & m,
const std::function< boolean< typename Derived::Scalar >(const typename Derived::Scalar &)> & pred )

Checks if unary predicate pred holds for no elements in the matrix m.

An empty matrix returns true.

◆ operator!=() [1/2]

template<class T>
bool operator!= ( const SortedPair< T > & x,
const SortedPair< T > & y )

Determine whether two SortedPair objects are not equal using operator==.

◆ operator!=() [2/2]

template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator!= ( const U & value,
const TypeSafeIndex< Tag > & tag )

◆ operator<() [1/2]

template<class T>
bool operator< ( const SortedPair< T > & x,
const SortedPair< T > & y )

Compares two pairs using lexicographic ordering.

◆ operator<() [2/2]

template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator< ( const U & value,
const TypeSafeIndex< Tag > & tag )

◆ operator<<() [1/2]

template<typename T, int Rows, int Cols>
std::ostream & operator<< ( std::ostream & os,
const Eigen::Matrix< Polynomial< T >, Rows, Cols > & poly_mat )

◆ operator<=() [1/2]

template<class T>
bool operator<= ( const SortedPair< T > & x,
const SortedPair< T > & y )

Determines whether x <= y using operator<.

◆ operator<=() [2/2]

template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator<= ( const U & value,
const TypeSafeIndex< Tag > & tag )

◆ operator==() [1/2]

template<class T>
bool operator== ( const SortedPair< T > & x,
const SortedPair< T > & y )

Two pairs of the same type are equal iff their members are equal after sorting.

◆ operator==() [2/2]

template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator== ( const U & value,
const TypeSafeIndex< Tag > & tag )

◆ operator>() [1/2]

template<class T>
bool operator> ( const SortedPair< T > & x,
const SortedPair< T > & y )

Determines whether x > y using operator<.

◆ operator>() [2/2]

template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator> ( const U & value,
const TypeSafeIndex< Tag > & tag )

◆ operator>=() [1/2]

template<class T>
bool operator>= ( const SortedPair< T > & x,
const SortedPair< T > & y )

Determines whether x >= y using operator<.

◆ operator>=() [2/2]

template<typename Tag, typename U>
std::enable_if_t< std::is_integral_v< U > &&std::is_unsigned_v< U >, bool > operator>= ( const U & value,
const TypeSafeIndex< Tag > & tag )

◆ pow()

template<typename T>
Polynomial< T > pow ( const Polynomial< T > & base,
typename Polynomial< T >::PowerType exponent )

Provides power function for Polynomial.

◆ ReadFile()

std::optional< std::string > ReadFile ( const std::filesystem::path & path)

Returns the content of the file at the given path, or nullopt if it cannot be read.

Note that the path is a filesystem path, not a resource_path.

◆ ReadFileOrThrow()

std::string ReadFileOrThrow ( const std::filesystem::path & path)

Returns the content of the file at the given path, or throws if it cannot be read.

Note that the path is a filesystem path, not a resource_path.

◆ ssize() [1/2]

template<class C>
auto ssize ( const C & c) -> std::common_type_t<std::ptrdiff_t, std::make_signed_t<decltype(c.size())> >
constexpr

Implements C++20 std::ssize() for earlier compilers.

See https://en.cppreference.com/w/cpp/iterator/size for documentation. Will be removed once all Drake-supported platforms offer std::ssize().

◆ ssize() [2/2]

template<class T, std::ptrdiff_t N>
std::ptrdiff_t ssize ( const T(&) array[N])
constexprnoexcept

This signature returns the size of built-in (C style) arrays.

◆ static_pointer_cast()

template<class T, class U>
std::unique_ptr< T > static_pointer_cast ( std::unique_ptr< U > && other)
noexcept

Casts the object owned by the std::unique_ptr other from type U to T; no runtime type checking is performed.

This method is analogous to the built-in std::static_pointer_cast that operates on a std::shared_ptr.

Note that this function only supports default deleters.

◆ temp_directory()

std::string temp_directory ( )

Returns a directory location suitable for temporary files.

The directory will be called ${parent}/robotlocomotion_drake_XXXXXX where each X is replaced by a character from the portable filename character set. The path ${parent} is defined as one of the following (in decreasing priority):

  • ${TEST_TMPDIR}
  • ${TMPDIR}
  • /tmp

If successful, this will always create a new directory. While the caller is not obliged to delete the directory, it has full power to do so based on specific context and need.

Returns
The path representing a newly created directory There will be no trailing /.
Exceptions
ifthe directory ${parent}/robotlocomotion_drake_XXXXXX cannot be created, or is not a directory.

◆ to_string() [1/2]

template<typename Tag>
std::string to_string ( const drake::Identifier< Tag > & id)

Enables use of identifiers with to_string.

It requires ADL to work. So, it should be invoked as: to_string(id); and should be preceded by using std::to_string.

◆ to_string() [2/2]

std::string to_string ( const FileSource & source)

Returns a string representation.

◆ unused()

template<typename... Args>
void unused ( const Args & ...)

Documents the argument(s) as unused, placating GCC's -Wunused-parameter warning.

This can be called within function bodies to mark that certain parameters are unused.

When possible, removing the unused parameter is better than placating the warning. However, in some cases the parameter is part of a virtual API or template concept that is used elsewhere, so we can't remove it. In those cases, this function might be an appropriate work-around.

Here's rough advice on how to fix Wunused-parameter warnings:

(1) If the parameter can be removed entirely, prefer that as the first choice. (This may not be possible if, e.g., a method must match some virtual API or template concept.)

(2) Unless the parameter name has acute value, prefer to omit the name of the parameter, leaving only the type, e.g.

void Print(const State& state) override { /* No state to print. */ }

changes to

void Print(const State&) override { /* No state to print. */}

This no longer triggers the warning and further makes it clear that a parameter required by the API is definitively unused in the function.

This is an especially good solution in the context of method definitions (vs declarations); the parameter name used in a definition is entirely irrelevant to Doxygen and most readers.

(3) When leaving the parameter name intact has acute value, it is acceptable to keep the name and mark it unused. For example, when the name appears as part of a virtual method's base class declaration, the name is used by Doxygen to document the method, e.g.,

/** Sets the default State of a System. This default implementation is to
* set all zeros. Subclasses may override to use non-zero defaults. The
* custom defaults may be based on the given @p context, when relevant. */
virtual void SetDefault(const Context<T>& context, State<T>* state) const {
unused(context);
state->SetZero();
}
void unused(const Args &...)
Documents the argument(s) as unused, placating GCC's -Wunused-parameter warning.
Definition unused.h:51

Variable Documentation

◆ eigen_all

auto eigen_all = Eigen::placeholders::all
staticconstexpr

A portable alias for Eigen::placeholders::all.

◆ kDrakeResourceRootEnvironmentVariableName

const char* const kDrakeResourceRootEnvironmentVariableName
extern

The name of the environment variable that provides the first place where FindResource attempts to look.

The environment variable is allowed to be unset or empty; in that case, FindResource will attempt to use other locations without complaint.

The value is guaranteed to be "DRAKE_RESOURCE_ROOT". (For some users, it may be easier to hard-code a value than refer to this constant.)

When the environment variable is set, resources are sought in relation to it by appending the FindResource() resource_path to the environment variable (with an intermediate / as appropriate). For example, if the resource_path is drake/examples/pendulum/Pendulum.urdf and the DRAKE_RESOURCE_ROOT is set to /home/someuser/foo then the resource will be sought at /home/someuser/foo/drake/examples/pendulum/Pendulum.urdf.

The intended use of this variable is to seek resources from an installed copy of Drake, in case other methods have failed.