Drake
Drake C++ Documentation
drake::schema Namespace Reference

Classes

class  Deterministic
 A single deterministic value. More...
 
class  DeterministicVector
 A single deterministic vector value. More...
 
class  Distribution
 Base class for a single distribution, to be used with YAML archives. More...
 
class  DistributionVector
 Base class for a vector of distributions, to be used with YAML archives. More...
 
class  Gaussian
 A gaussian distribution with mean and stddev. More...
 
class  GaussianVector
 A gaussian distribution with vector mean and vector or scalar stddev. More...
 
class  Rotation
 A specification for an SO(3) rotation, to be used for serialization purposes, e.g., to define stochastic scenarios. More...
 
class  Transform
 A specification for a 3d rotation and translation, optionally with respect to a base frame. More...
 
class  Uniform
 A uniform distribution with min inclusive and max exclusive. More...
 
class  UniformDiscrete
 Chooses from among discrete values with equal probability. More...
 
class  UniformVector
 A uniform distribution with vector min inclusive and vector max exclusive. More...
 

Typedefs

using DistributionVariant = std::variant< double, Deterministic, Gaussian, Uniform, UniformDiscrete >
 Variant over all kinds of distributions. More...
 
template<int Size>
using DistributionVectorVariant = std::variant< drake::Vector< double, Size >, DeterministicVector< Size >, GaussianVector< Size >, UniformVector< Size >, std::conditional_t<(Size==Eigen::Dynamic||Size==1), Deterministic, internal::InvalidVariantSelection< Deterministic > >, std::conditional_t<(Size==Eigen::Dynamic||Size==1), Gaussian, internal::InvalidVariantSelection< Gaussian > >, std::conditional_t<(Size==Eigen::Dynamic||Size==1), Uniform, internal::InvalidVariantSelection< Uniform > >>
 Variant over all kinds of vector distributions. More...
 
using DistributionVectorVariantX = DistributionVectorVariant< Eigen::Dynamic >
 DistributionVectorVariant that permits any vector size dynamically. More...
 

Functions

std::unique_ptr< DistributionToDistribution (const DistributionVariant &var)
 Copies the given variant into a Distribution base class. More...
 
double Sample (const DistributionVariant &var, drake::RandomGenerator *generator)
 Like Distribution::Sample, but on a DistributionVariant instead. More...
 
double Mean (const DistributionVariant &var)
 Like Distribution::Mean, but on a DistributionVariant instead. More...
 
drake::symbolic::Expression ToSymbolic (const DistributionVariant &var)
 Like Distribution::ToSymbolic, but on a DistributionVariant instead. More...
 
Eigen::VectorXd Sample (const std::vector< DistributionVariant > &vec, drake::RandomGenerator *generator)
 Like Distribution::Sample, but elementwise over a collection of possibly-heterogenous DistributionVariant instead. More...
 
Eigen::VectorXd Mean (const std::vector< DistributionVariant > &vec)
 Like Distribution::Mean, but elementwise over a collection of possibly-heterogenous DistributionVariant instead. More...
 
drake::VectorX< drake::symbolic::ExpressionToSymbolic (const std::vector< DistributionVariant > &vec)
 Like Distribution::ToSymbolic, but elementwise over a collection of possibly-heterogenous DistributionVariant instead. More...
 
bool IsDeterministic (const DistributionVariant &var)
 Returns true iff var is set to a deterministic value. More...
 
double GetDeterministicValue (const DistributionVariant &var)
 If var is deterministic, retrieves its value. More...
 
template<int Size>
std::unique_ptr< DistributionVectorToDistributionVector (const DistributionVectorVariant< Size > &vec)
 Copies the given variant into a DistributionVector base class. More...
 
template<int Size>
bool IsDeterministic (const DistributionVectorVariant< Size > &vec)
 Returns true iff all of vec's elements are set to a deterministic value. More...
 
template<int Size>
Eigen::VectorXd GetDeterministicValue (const DistributionVectorVariant< Size > &vec)
 If vec is deterministic, retrieves its value. More...
 

Typedef Documentation

◆ DistributionVariant

Variant over all kinds of distributions.

◆ DistributionVectorVariant

using DistributionVectorVariant = std::variant< drake::Vector<double, Size>, DeterministicVector<Size>, GaussianVector<Size>, UniformVector<Size>, std::conditional_t<(Size == Eigen::Dynamic || Size == 1), Deterministic, internal::InvalidVariantSelection<Deterministic> >, std::conditional_t<(Size == Eigen::Dynamic || Size == 1), Gaussian, internal::InvalidVariantSelection<Gaussian> >, std::conditional_t<(Size == Eigen::Dynamic || Size == 1), Uniform, internal::InvalidVariantSelection<Uniform> >>

Variant over all kinds of vector distributions.

If the Size parameter allows for 1-element vectors (i.e, is either 1 or Eigen::Dynamic), then this variant also offers the single distribution types (Deterministic, Gaussian, Uniform). If the Size parameter is 2 or greater, the single distribution types are not allowed.

Template Parameters
Sizerows at compile time (max 6) or else Eigen::Dynamic.

◆ DistributionVectorVariantX

DistributionVectorVariant that permits any vector size dynamically.

Function Documentation

◆ GetDeterministicValue() [1/2]

double drake::schema::GetDeterministicValue ( const DistributionVariant var)

If var is deterministic, retrieves its value.

Exceptions
std::exceptionif var is not deterministic.

◆ GetDeterministicValue() [2/2]

Eigen::VectorXd drake::schema::GetDeterministicValue ( const DistributionVectorVariant< Size > &  vec)

If vec is deterministic, retrieves its value.

Exceptions
std::exceptionif vec is not deterministic.
Template Parameters
Sizerows at compile time (max 6) or else Eigen::Dynamic.

◆ IsDeterministic() [1/2]

bool drake::schema::IsDeterministic ( const DistributionVariant var)

Returns true iff var is set to a deterministic value.

◆ IsDeterministic() [2/2]

bool drake::schema::IsDeterministic ( const DistributionVectorVariant< Size > &  vec)

Returns true iff all of vec's elements are set to a deterministic value.

Template Parameters
Sizerows at compile time (max 6) or else Eigen::Dynamic.

◆ Mean() [1/2]

double drake::schema::Mean ( const DistributionVariant var)

Like Distribution::Mean, but on a DistributionVariant instead.

◆ Mean() [2/2]

Eigen::VectorXd drake::schema::Mean ( const std::vector< DistributionVariant > &  vec)

Like Distribution::Mean, but elementwise over a collection of possibly-heterogenous DistributionVariant instead.

◆ Sample() [1/2]

double drake::schema::Sample ( const DistributionVariant var,
drake::RandomGenerator generator 
)

Like Distribution::Sample, but on a DistributionVariant instead.

◆ Sample() [2/2]

Eigen::VectorXd drake::schema::Sample ( const std::vector< DistributionVariant > &  vec,
drake::RandomGenerator generator 
)

Like Distribution::Sample, but elementwise over a collection of possibly-heterogenous DistributionVariant instead.

◆ ToDistribution()

std::unique_ptr<Distribution> drake::schema::ToDistribution ( const DistributionVariant var)

Copies the given variant into a Distribution base class.

◆ ToDistributionVector()

std::unique_ptr<DistributionVector> drake::schema::ToDistributionVector ( const DistributionVectorVariant< Size > &  vec)

Copies the given variant into a DistributionVector base class.

Template Parameters
Sizerows at compile time (max 6) or else Eigen::Dynamic.

◆ ToSymbolic() [1/2]

drake::symbolic::Expression drake::schema::ToSymbolic ( const DistributionVariant var)

Like Distribution::ToSymbolic, but on a DistributionVariant instead.

◆ ToSymbolic() [2/2]

drake::VectorX<drake::symbolic::Expression> drake::schema::ToSymbolic ( const std::vector< DistributionVariant > &  vec)

Like Distribution::ToSymbolic, but elementwise over a collection of possibly-heterogenous DistributionVariant instead.