maliput
ValueToAbstractValue Class Reference

Detailed Description

Implements Drake policy for taking a concrete value object and storing it in a Drake abstract object (for example, an abstract-valued port) as a type-erased AbstractValue.

We call this "AbstractPolicy" to distinguish it from the "VectorPolicy" implemented by ValueToVectorValue.

Usage

This class can be used in conjunction with ValueToVectorValue to store an arbitrary value object into a Drake abstract or vector object, using the appropriate policy. Here is an example:

std::unique_ptr<AbstractValue> abstract_value =
is_vector_port
: internal::ValueToAbstractValue::ToAbstract(__func__, value);

Note that for this to work both ToAbstract() methods must compile successfully. Thus where one policy is more restrictive than the other, it must issue runtime (not compile time) errors for values that are unacceptable.

See also
ValueToVectorValue

AbstractPolicy

  1. Any given AbstractValue object is simply cloned.
  2. A char * type is copied into a Value<std::string>.
  3. Eigen objects and expressions are not accepted directly under AbstractPolicy as they are under VectorPolicy. The caller must instead provide the storage type explicitly via Value<EigenType>.
  4. For any other type V
    • if V is copy-constructible it is copied into a Value<V>;
    • if V has an accessible Clone() method that returns unique_ptr<V> it is cloned into a Value<V>;
    • if V has an accessible Clone() method that returns unique_ptr<B>, where B is a base class of V, then V is cloned into a Value<B>;
    • otherwise, compilation fails with a static_assert message.
Warning
Eigen expressions typically don't have simple Vector or Matrix types. That doesn't matter under the VectorPolicy (as long as the size and shape are acceptable). However, under the AbstractPolicy you must specify the storage type explicitly by suppling a Value<EigenType>(your_expression) object.

#include <src/maliput/drake/systems/framework/value_to_abstract_value.h>

Static Public Member Functions

static std::unique_ptr< AbstractValueToAbstract (const char *api_name, const AbstractValue &value)
 
static std::unique_ptr< AbstractValueToAbstract (const char *api_name, const char *c_string)
 
template<typename ValueType , typename = std::enable_if_t<is_eigen_refable<ValueType>()>>
static std::unique_ptr< AbstractValueToAbstract (const char *api_name, const ValueType &eigen_value,...)
 
template<typename ValueType >
static constexpr bool has_accessible_clone ()
 
template<typename ValueType , typename = std::enable_if_t<!(std::is_base_of_v<AbstractValue, ValueType> || is_eigen_refable<ValueType>())>>
static std::unique_ptr< AbstractValueToAbstract (const char *api_name, const ValueType &value)
 

Member Function Documentation

◆ has_accessible_clone()

static constexpr bool has_accessible_clone ( )
staticconstexpr

◆ ToAbstract() [1/4]

static std::unique_ptr<AbstractValue> ToAbstract ( const char *  api_name,
const AbstractValue value 
)
static

◆ ToAbstract() [2/4]

static std::unique_ptr<AbstractValue> ToAbstract ( const char *  api_name,
const char *  c_string 
)
static

◆ ToAbstract() [3/4]

static std::unique_ptr<AbstractValue> ToAbstract ( const char *  api_name,
const ValueType &  eigen_value,
  ... 
)
static

◆ ToAbstract() [4/4]

static std::unique_ptr<AbstractValue> ToAbstract ( const char *  api_name,
const ValueType &  value 
)
static

The documentation for this class was generated from the following file:
maliput::drake::systems::internal::ValueToVectorValue::ToAbstract
static std::unique_ptr< AbstractValue > ToAbstract(const char *api_name, const Eigen::Ref< const VectorX< T >> &vector)
Definition: value_to_abstract_value.h:215
maliput::drake::systems::internal::ValueToAbstractValue::ToAbstract
static std::unique_ptr< AbstractValue > ToAbstract(const char *api_name, const AbstractValue &value)
Definition: value_to_abstract_value.h:88