Drake
Drake C++ Documentation
drake Namespace Reference

Namespaces

 ad
 
 assert
 
 common
 
 examples
 
 geometry
 
 lcm
 
 logging
 
 manipulation
 
 math
 
 multibody
 
 perception
 
 planning
 
 pydrake
 For more high-level information, see the Python Bindings technical notes.
 
 schema
 
 solvers
 
 symbolic
 
 systems
 
 test
 
 trajectories
 
 visualization
 
 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...
 
struct  template_single_tag
 Provides a tag for single-parameter templates. More...
 
class  Timer
 Abstract base class for timing utility. More...
 
struct  type_at
 Extracts the Ith type from a sequence of types. More...
 
struct  type_check_different_from
 Provides a check which returns whether T is different than U. More...
 
struct  type_pack
 Provides a tag to pass a parameter packs for ease of inference. More...
 
struct  type_tag
 Provides a tag to pass a type for ease of inference. More...
 
struct  type_visit_with_default
 Visit a type by constructing its default value. More...
 
struct  type_visit_with_tag
 Visits a type by construct a template tag's default value. 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 type_pack_extract = typename internal::type_pack_extract_impl< T >::type
 Extracts the inner template arguments (typename only) for a typename which is a template instantiation. More...
 
template<typename T >
using type_check_always_true = std::true_type
 Provides a check which will return true for any type. More...
 
template<typename T >
using boolean = typename scalar_predicate< T >::type
 An alias for a boolean-like value, conditioned on the scalar type T. More...
 
using AutoDiffXd = Eigen::AutoDiffScalar< Eigen::VectorXd >
 An autodiff variable with a dynamic number of partials. More...
 
template<int num_vars>
using AutoDiffd = Eigen::AutoDiffScalar< Eigen::Matrix< double, num_vars, 1 > >
 An autodiff variable with num_vars partials. More...
 
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. More...
 
typedef AutoDiffVecd< Eigen::Dynamic, Eigen::Dynamic > AutoDiffVecXd
 A dynamic-sized vector of autodiff variables, each with a dynamic-sized vector of partials. More...
 
template<typename Scalar >
using Vector0 = Eigen::Matrix< Scalar, 0, 1 >
 The empty column vector (zero rows, one column), templated on scalar type. More...
 
template<typename Scalar >
using Vector1 = Eigen::Matrix< Scalar, 1, 1 >
 A column vector of size 1 (that is, a scalar), templated on scalar type. More...
 
using Vector1d = Eigen::Matrix< double, 1, 1 >
 A column vector of size 1 of doubles. More...
 
template<typename Scalar >
using Vector2 = Eigen::Matrix< Scalar, 2, 1 >
 A column vector of size 2, templated on scalar type. More...
 
template<typename Scalar >
using Vector3 = Eigen::Matrix< Scalar, 3, 1 >
 A column vector of size 3, templated on scalar type. More...
 
template<typename Scalar >
using Vector4 = Eigen::Matrix< Scalar, 4, 1 >
 A column vector of size 4, templated on scalar type. More...
 
template<typename Scalar >
using Vector6 = Eigen::Matrix< Scalar, 6, 1 >
 A column vector of size 6. More...
 
using Vector6d = Eigen::Matrix< double, 6, 1 >
 A column vector of size 6 of doubles. More...
 
template<typename Scalar , int Rows>
using Vector = Eigen::Matrix< Scalar, Rows, 1 >
 A column vector templated on the number of rows. More...
 
template<typename Scalar >
using VectorX = Eigen::Matrix< Scalar, Eigen::Dynamic, 1 >
 A column vector of any size, templated on scalar type. More...
 
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. More...
 
template<typename Scalar >
using RowVector2 = Eigen::Matrix< Scalar, 1, 2 >
 A row vector of size 2, templated on scalar type. More...
 
template<typename Scalar >
using RowVector3 = Eigen::Matrix< Scalar, 1, 3 >
 A row vector of size 3, templated on scalar type. More...
 
template<typename Scalar >
using RowVector4 = Eigen::Matrix< Scalar, 1, 4 >
 A row vector of size 4, templated on scalar type. More...
 
template<typename Scalar >
using RowVector6 = Eigen::Matrix< Scalar, 1, 6 >
 A row vector of size 6. More...
 
template<typename Scalar , int Cols>
using RowVector = Eigen::Matrix< Scalar, 1, Cols >
 A row vector templated on the number of columns. More...
 
template<typename Scalar >
using RowVectorX = Eigen::Matrix< Scalar, 1, Eigen::Dynamic >
 A row vector of any size, templated on scalar type. More...
 
template<typename Scalar >
using Matrix2 = Eigen::Matrix< Scalar, 2, 2 >
 A matrix of 2 rows and 2 columns, templated on scalar type. More...
 
template<typename Scalar >
using Matrix3 = Eigen::Matrix< Scalar, 3, 3 >
 A matrix of 3 rows and 3 columns, templated on scalar type. More...
 
template<typename Scalar >
using Matrix4 = Eigen::Matrix< Scalar, 4, 4 >
 A matrix of 4 rows and 4 columns, templated on scalar type. More...
 
template<typename Scalar >
using Matrix6 = Eigen::Matrix< Scalar, 6, 6 >
 A matrix of 6 rows and 6 columns, templated on scalar type. More...
 
template<typename Scalar >
using Matrix2X = Eigen::Matrix< Scalar, 2, Eigen::Dynamic >
 A matrix of 2 rows, dynamic columns, templated on scalar type. More...
 
template<typename Scalar >
using Matrix3X = Eigen::Matrix< Scalar, 3, Eigen::Dynamic >
 A matrix of 3 rows, dynamic columns, templated on scalar type. More...
 
template<typename Scalar >
using Matrix4X = Eigen::Matrix< Scalar, 4, Eigen::Dynamic >
 A matrix of 4 rows, dynamic columns, templated on scalar type. More...
 
template<typename Scalar >
using Matrix6X = Eigen::Matrix< Scalar, 6, Eigen::Dynamic >
 A matrix of 6 rows, dynamic columns, templated on scalar type. More...
 
template<typename Scalar >
using MatrixX = Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic >
 A matrix of dynamic size, templated on scalar type. More...
 
template<typename Scalar >
using MatrixUpTo6 = 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. More...
 
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. More...
 
template<typename Scalar , typename Derived >
using MatrixLikewise = 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). More...
 
using StrideX = Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic >
 A fully dynamic Eigen stride. More...
 
template<typename Scalar >
using Quaternion = Eigen::Quaternion< Scalar >
 A quaternion templated on scalar type. More...
 
template<typename Scalar >
using AngleAxis = Eigen::AngleAxis< Scalar >
 An AngleAxis templated on scalar type. More...
 
template<typename Scalar >
using Isometry3 = Eigen::Transform< Scalar, 3, Eigen::Isometry >
 An Isometry templated on scalar type. More...
 
using FileSource = std::variant< std::filesystem::path, MemoryFile >
 Represents a file. More...
 
using DefaultHasher = internal::FNV1aHasher
 The default HashAlgorithm concept implementation across Drake. More...
 
using DefaultHash = drake::uhash< DefaultHasher >
 The default hashing functor, akin to std::hash. More...
 
template<typename T >
using is_cloneable = is_cloneable_internal::is_cloneable_helper< T, void >
 
typedef Polynomial< doublePolynomiald
 
typedef Eigen::Matrix< Polynomiald, Eigen::Dynamic, 1 > VectorXPoly
 A column vector of polynomials; used in several optimization classes. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename T >
using string_unordered_map = 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. More...
 
template<typename T >
using string_unordered_multimap = 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. More...
 
using string_unordered_set = 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. More...
 
using string_unordered_multiset = 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. More...
 

Enumerations

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

Functions

template<template< typename... > class Tpl, typename... Ts>
Tpl< Ts... > type_bind (type_pack< Ts... >)
 Returns an expression (only to be used in decltype) for inferring and binding a parameter pack to a template. More...
 
template<class VisitWith = type_visit_with_default, template< typename > class Predicate = type_check_always_true, typename Visitor = void, typename... Ts>
void type_visit (Visitor &&visitor, type_pack< Ts... >={}, template_single_tag< Predicate >={})
 Visits each type in a type pack. This effectively implements a. More...
 
template<typename T >
constexpr size_t type_hash ()
 Provides short-hand for hashing a type. More...
 
template<typename DerType >
double ExtractDoubleOrThrow (const Eigen::AutoDiffScalar< DerType > &scalar)
 Returns the autodiff scalar's value() as a double. More...
 
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. More...
 
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. More...
 
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. More...
 
double if_then_else (bool f_cond, double v_then, double v_else)
 Provides if-then-else expression for double. More...
 
template<typename Derived >
Derived::Scalar all (const Eigen::DenseBase< Derived > &m)
 Checks truth for all elements in matrix m. More...
 
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. More...
 
template<typename Derived >
Derived::Scalar any (const Eigen::DenseBase< Derived > &m)
 Checks truth for at least one element in matrix m. More...
 
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. More...
 
template<typename Derived >
Derived::Scalar none (const Eigen::MatrixBase< Derived > &m)
 Checks that no elements of m are true. An empty matrix returns true. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
double ExtractDoubleOrThrow (double scalar)
 Returns scalar as a double. Never throws. More...
 
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. More...
 
std::string to_string (const FileSource &source)
 Returns a string representation. More...
 
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. More...
 
FindResourceResult FindResource (const std::string &resource_path)
 (Advanced) Attempts to locate a Drake resource named by the given resource_path. More...
 
std::string FindResourceOrThrow (const std::string &resource_path)
 (Advanced) Convenient wrapper for querying FindResource(resource_path) followed by FindResourceResult::get_absolute_path_or_throw(). More...
 
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. More...
 
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. More...
 
bool HasRunfiles ()
 (Advanced.) Returns true iff this process has Bazel runfiles available. More...
 
RlocationOrError FindRunfile (const std::string &resource_path)
 (Advanced.) Returns the absolute path to the given resource_path from Bazel runfiles, or else an error message when not found. More...
 
auto fmt_runtime (std::string_view s)
 When using fmt >= 8, this is an alias for fmt::runtime. More...
 
template<typename T >
std::string fmt_floating_point (T x)
 Returns fmt::to_string(x) but always with at least one digit after the decimal point. More...
 
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. More...
 
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. More...
 
template<typename T >
auto fmt_streamed (const T &ref)
 When using fmt >= 9, this is an alias for fmt::streamed. More...
 
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. More...
 
template<class HashAlgorithm , class T >
void hash_append (HashAlgorithm &hasher, const T *item) noexcept
 Provides hash_append generic hashing for bare pointers. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<class HashAlgorithm , class T >
void hash_append (HashAlgorithm &hasher, const std::optional< T > &item) noexcept
 Provides hash_append generic hashing for std::optional. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename Tag >
std::string to_string (const drake::Identifier< Tag > &id)
 Enables use of identifiers with to_string. More...
 
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. More...
 
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. More...
 
template<typename T >
NameValue< T > MakeNameValue (const char *name, T *value)
 (Advanced) Creates a NameValue. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename T >
Polynomial< T > pow (const Polynomial< T > &base, typename Polynomial< T >::PowerType exponent)
 Provides power function for Polynomial. More...
 
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. More...
 
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. More...
 
template<class T >
bool operator< (const SortedPair< T > &x, const SortedPair< T > &y)
 Compares two pairs using lexicographic ordering. More...
 
template<class T >
bool operator!= (const SortedPair< T > &x, const SortedPair< T > &y)
 Determine whether two SortedPair objects are not equal using operator==. More...
 
template<class T >
bool operator> (const SortedPair< T > &x, const SortedPair< T > &y)
 Determines whether x > y using operator<. More...
 
template<class T >
bool operator<= (const SortedPair< T > &x, const SortedPair< T > &y)
 Determines whether x <= y using operator<. More...
 
template<class T >
bool operator>= (const SortedPair< T > &x, const SortedPair< T > &y)
 Determines whether x >= y using operator<. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
double ExtractDoubleOrThrow (const symbolic::Expression &e)
 Returns the symbolic expression's value() as a double. More...
 
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. More...
 
std::string temp_directory ()
 Returns a directory location suitable for temporary files. More...
 
template<typename DerivedA , typename DerivedB >
::testing::AssertionResult CompareMatrices (const Eigen::MatrixBase< DerivedA > &m1, const Eigen::MatrixBase< DerivedB > &m2, double tolerance=0.0, MatrixCompareType compare_type=MatrixCompareType::absolute)
 Compares two matrices to determine whether they are equal to within a certain threshold. More...
 
template<typename ToType , typename FromType >
::testing::AssertionResult is_dynamic_castable (const FromType *ptr)
 Checks if ptr, a pointer to FromType class, can be safely converted to a pointer to ToType class. More...
 
template<typename ToType , typename FromType >
::testing::AssertionResult is_dynamic_castable (std::shared_ptr< FromType > ptr)
 Checks if ptr, a shared pointer to FromType class, can be safely converted to a shared pointer to ToType class. More...
 
template<typename ToType , typename FromType >
::testing::AssertionResult is_dynamic_castable (const std::unique_ptr< FromType > &ptr)
 Checks if ptr, a shared pointer to FromType class, can be safely converted to a shared pointer to ToType class. More...
 
logging::loggerlog ()
 Retrieve an instance of a logger to use for logging; for example: More...
 
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. More...
 
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
 
const char *const kDrakeResourceRootEnvironmentVariableName
 The name of the environment variable that provides the first place where FindResource attempts to look. More...
 

Typedef Documentation

◆ AngleAxis

using AngleAxis = Eigen::AngleAxis<Scalar>

An AngleAxis templated on scalar type.

◆ AutoDiffd

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

An autodiff variable with num_vars partials.

◆ AutoDiffVecd

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

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

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:

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

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

An Isometry templated on scalar type.

◆ Matrix2

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

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

◆ Matrix2X

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

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

◆ Matrix3

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

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

◆ Matrix3X

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

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

◆ Matrix4

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

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

◆ Matrix4X

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

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

◆ Matrix6

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

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

◆ Matrix6X

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

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

◆ Matrix6xUpTo6

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

using MatrixLikewise = 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

using MatrixUpTo6 = 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

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

A matrix of dynamic size, templated on scalar type.

◆ Polynomiald

◆ Quaternion

using Quaternion = Eigen::Quaternion<Scalar>

A quaternion templated on scalar type.

◆ RowVector

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

A row vector templated on the number of columns.

◆ RowVector2

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

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

◆ RowVector3

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

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

◆ RowVector4

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

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

◆ RowVector6

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

A row vector of size 6.

◆ RowVectorX

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

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

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

using string_unordered_map = 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

using string_unordered_multimap = 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

using string_unordered_multiset = 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

using string_unordered_set = 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.

◆ type_check_always_true

using type_check_always_true = std::true_type

Provides a check which will return true for any type.

◆ type_pack_extract

using type_pack_extract = typename internal::type_pack_extract_impl<T>::type

Extracts the inner template arguments (typename only) for a typename which is a template instantiation.

◆ Vector

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

A column vector templated on the number of rows.

◆ Vector0

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

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

◆ Vector1

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

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

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

◆ Vector3

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

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

◆ Vector4

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

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

◆ Vector6

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

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

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

◆ MatrixCompareType

enum MatrixCompareType
strong
Enumerator
absolute 
relative 

◆ RandomDistribution

enum 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 ToleranceType
strong
Enumerator
kAbsolute 
kRelative 

Function Documentation

◆ all()

Derived::Scalar drake::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()

boolean<typename Derived::Scalar> drake::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()

Derived::Scalar drake::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()

boolean<typename Derived::Scalar> drake::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()

T drake::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.

◆ CompareMatrices()

::testing::AssertionResult drake::CompareMatrices ( const Eigen::MatrixBase< DerivedA > &  m1,
const Eigen::MatrixBase< DerivedB > &  m2,
double  tolerance = 0.0,
MatrixCompareType  compare_type = MatrixCompareType::absolute 
)

Compares two matrices to determine whether they are equal to within a certain threshold.

Parameters
m1The first matrix to compare.
m2The second matrix to compare.
toleranceThe tolerance for determining equivalence.
compare_typeWhether the tolereance is absolute or relative.
explanationA pointer to a string variable for saving an explanation of why m1 and m2 are unequal. This parameter is optional and defaults to nullptr. If this is nullptr and m1 and m2 are not equal, an explanation is logged as an error message.
Returns
true if the two matrices are equal based on the specified tolerance.

◆ cond() [1/4]

ScalarType drake::cond ( const ScalarType &  e)

◆ cond() [2/4]

ScalarType drake::cond ( const decltype(ScalarType()< ScalarType())&  f_cond,
const ScalarType &  e_then,
Rest...  rest 
)

◆ cond() [3/4]

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

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

◆ cond() [4/4]

symbolic::Expression drake::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()

std::unique_ptr<T> drake::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]

std::unique_ptr<T> drake::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]

T* drake::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()

auto drake::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/6]

double drake::ExtractDoubleOrThrow ( double  scalar)

Returns scalar as a double. Never throws.

◆ ExtractDoubleOrThrow() [2/6]

std::enable_if_t<std::is_same_v<typename Derived::Scalar, double>, MatrixLikewise<double, Derived> > drake::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/6]

double drake::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() [4/6]

auto drake::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/6]

double drake::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/6]

std::enable_if_t< std::is_same_v<typename Derived::Scalar, symbolic::Expression>, MatrixLikewise<double, Derived> > drake::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.

◆ FindResource()

FindResourceResult drake::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 drake::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 drake::FindRunfile ( const std::string &  resource_path)

(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. The resource_path looks like workspace/pkg/subpkg/file.ext, e.g., "drake/common/foo.txt".

◆ fmt_debug_string()

std::string drake::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()

internal::fmt_eigen_ref<typename Derived::Scalar> drake::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)));
}
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()

std::string drake::fmt_floating_point ( 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.

◆ fmt_runtime()

auto drake::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()

auto drake::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]

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

Provides hash_append generic hashing for integral constants.

◆ hash_append() [2/9]

void drake::hash_append ( HashAlgorithm &  hasher,
const T *  item 
)
noexcept

Provides hash_append generic hashing for bare pointers.

◆ hash_append() [3/9]

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

Provides hash_append generic hashing for enumerations.

◆ hash_append() [4/9]

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

Provides hash_append generic hashing for floating point values.

◆ hash_append() [5/9]

void drake::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() [6/9]

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

Provides hash_append generic hashing for std::pair.

◆ hash_append() [7/9]

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() [8/9]

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() [9/9]

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_range()

void drake::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 drake::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]

double drake::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() [2/3]

auto drake::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.

◆ if_then_else() [3/3]

Eigen::AutoDiffScalar< typename Eigen::internal::remove_all<DerType1>::type::PlainObject> drake::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).

◆ is_approx_equal_abstol()

bool drake::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.

◆ is_dynamic_castable() [1/3]

::testing::AssertionResult drake::is_dynamic_castable ( const FromType *  ptr)

Checks if ptr, a pointer to FromType class, can be safely converted to a pointer to ToType class.

Our motivation is to provide a good diagnostic for what ptr actually was when the test fails.

Here is an illustrative code snippet. We assume that Prius and Camry are derived classes of Car.

const Car* prius = new Prius{};
// The following assertion fails without diagnostic info.
EXPECT_TRUE(dynamic_cast<Camry>(ptr) != nullptr)
// The following assertion returns `::testing::AssertionFailure()` with
// diagnostic info attached.
EXPECT_TRUE(is_dynamic_castable<Camry>(prius));
// Output:
// Value of: is_dynamic_castable<Camry>(prius)
// Actual: false (is_dynamic_castable<Camry>(Car* ptr) failed
// because ptr is of dynamic type Prius.)
// Expected: true

◆ is_dynamic_castable() [2/3]

::testing::AssertionResult drake::is_dynamic_castable ( std::shared_ptr< FromType >  ptr)

Checks if ptr, a shared pointer to FromType class, can be safely converted to a shared pointer to ToType class.

Our motivation is to provide a good diagnostic for what ptr actually was when the test fails.

◆ is_dynamic_castable() [3/3]

::testing::AssertionResult drake::is_dynamic_castable ( const std::unique_ptr< FromType > &  ptr)

Checks if ptr, a shared pointer to FromType class, can be safely converted to a shared pointer to ToType class.

Our motivation is to provide a good diagnostic for what ptr actually was when the test fails.

◆ IsApproxEqualAbsTolWithPermutedColumns()

bool drake::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> drake::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* drake::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()

NameValue<T> drake::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()

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

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> drake::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()

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

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

◆ none_of()

boolean<typename Derived::Scalar> drake::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]

bool drake::operator!= ( const SortedPair< T > &  x,
const SortedPair< T > &  y 
)

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

◆ operator!=() [2/2]

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

◆ operator<() [1/2]

bool drake::operator< ( const SortedPair< T > &  x,
const SortedPair< T > &  y 
)

Compares two pairs using lexicographic ordering.

◆ operator<() [2/2]

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

◆ operator<<()

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

◆ operator<=() [1/2]

bool drake::operator<= ( const SortedPair< T > &  x,
const SortedPair< T > &  y 
)

Determines whether x <= y using operator<.

◆ operator<=() [2/2]

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

◆ operator==() [1/2]

bool drake::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]

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

◆ operator>() [1/2]

bool drake::operator> ( const SortedPair< T > &  x,
const SortedPair< T > &  y 
)

Determines whether x > y using operator<.

◆ operator>() [2/2]

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

◆ operator>=() [1/2]

bool drake::operator>= ( const SortedPair< T > &  x,
const SortedPair< T > &  y 
)

Determines whether x >= y using operator<.

◆ operator>=() [2/2]

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

◆ pow()

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

Provides power function for Polynomial.

◆ ReadFile()

std::optional<std::string> drake::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 drake::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]

constexpr auto drake::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.

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]

constexpr std::ptrdiff_t drake::ssize ( const T(&)  array[N])
noexcept

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

◆ static_pointer_cast()

std::unique_ptr<T> drake::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 drake::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]

std::string drake::to_string ( const FileSource source)

Returns a string representation.

◆ to_string() [2/2]

std::string drake::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.

◆ type_bind()

Tpl<Ts...> drake::type_bind ( type_pack< Ts... >  )

Returns an expression (only to be used in decltype) for inferring and binding a parameter pack to a template.

◆ type_hash()

constexpr size_t drake::type_hash ( )

Provides short-hand for hashing a type.

◆ type_visit()

void drake::type_visit ( Visitor &&  visitor,
type_pack< Ts... >  = {},
template_single_tag< Predicate >  = {} 
)

Visits each type in a type pack. This effectively implements a.

Template Parameters
VisitWithVisit helper.
See also
type_visit_with_default, type_visit_with_tag.
Template Parameters
PredicatePredicate operating on the type dictated by VisitWith.
Parameters
visitorLambda or functor for visiting a type.

◆ unused()

void drake::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();
}

Variable Documentation

◆ kDrakeResourceRootEnvironmentVariableName

const char* const kDrakeResourceRootEnvironmentVariableName

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.