Drake
Drake C++ Documentation
CartesianProduct Class Referencefinal

## Detailed Description

The Cartesian product of convex sets is a convex set: S = X₁ × X₂ × ⋯ × Xₙ = {(x₁, x₂, ..., xₙ) | x₁ ∈ X₁, x₂ ∈ X₂, ..., xₙ ∈ Xₙ}.

This class also supports a generalization of this concept in which the coordinates are transformed by the linear map, {x | y = Ax + b, y ∈ Y₁ × Y₂ × ⋯ × Yₙ}, with the default values set to the identity map. This concept is required for reasoning about cylinders in arbitrary poses as cartesian products, and more generally for describing any affine transform of a CartesianProduct.

Special behavior for IsEmpty: If there are no sets in the product, returns nonempty by convention. See: https://en.wikipedia.org/wiki/Empty_product#Nullary_Cartesian_product Otherwise, if any set in the cartesian product is empty, the whole product is empty.

#include <drake/geometry/optimization/cartesian_product.h>

## Public Member Functions

CartesianProduct ()
Constructs a default (zero-dimensional, nonempty) set. More...

CartesianProduct (const ConvexSets &sets)
Constructs the product from a vector of convex sets. More...

CartesianProduct (const ConvexSet &setA, const ConvexSet &setB)
Constructs the product from a pair of convex sets. More...

CartesianProduct (const ConvexSets &sets, const Eigen::Ref< const Eigen::MatrixXd > &A, const Eigen::Ref< const Eigen::VectorXd > &b)
Constructs the product of convex sets in the transformed coordinates: {x | y = Ax + b, y ∈ Y₁ × Y₂ × ⋯ × Yₙ}. More...

CartesianProduct (const QueryObject< double > &query_object, GeometryId geometry_id, std::optional< FrameId > reference_frame=std::nullopt)
Constructs a CartesianProduct from a SceneGraph geometry and pose in the reference_frame frame, obtained via the QueryObject. More...

~CartesianProduct () final

int num_factors () const
The number of factors (or sets) used in the product. More...

const ConvexSetfactor (int i) const
Returns a reference to the ConvexSet defining the index factor in the product. More...

bool PointInSet (const Eigen::Ref< const Eigen::VectorXd > &x, double tol=0) const
Returns true if each subvector is in its corresponding set with tolerance tol. More...

double CalcVolume () const

Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
CartesianProduct (const CartesianProduct &)=default

CartesianProductoperator= (const CartesianProduct &)=default

CartesianProduct (CartesianProduct &&)=default

CartesianProductoperator= (CartesianProduct &&)=default

Public Member Functions inherited from ConvexSet
virtual ~ConvexSet ()

std::unique_ptr< ConvexSetClone () const
Creates a unique deep copy of this set. More...

int ambient_dimension () const
Returns the dimension of the vector space in which the elements of this set are evaluated. More...

bool IntersectsWith (const ConvexSet &other) const
Returns true iff the intersection between this and other is non-empty. More...

bool IsBounded () const
Returns true iff the set is bounded, e.g., there exists an element-wise finite lower and upper bound for the set. More...

bool IsEmpty () const
Returns true iff the set is empty. More...

std::optional< Eigen::VectorXd > MaybeGetPoint () const
If this set trivially contains exactly one point, returns the value of that point. More...

std::optional< Eigen::VectorXd > MaybeGetFeasiblePoint () const
Returns a feasible point within this convex set if it is nonempty, and nullopt otherwise. More...

bool PointInSet (const Eigen::Ref< const Eigen::VectorXd > &x, double tol=0) const
Returns true iff the point x is contained in the set. More...

std::pair< VectorX< symbolic::Variable >, std::vector< solvers::Binding< solvers::Constraint > > > AddPointInSetConstraints (solvers::MathematicalProgram *prog, const Eigen::Ref< const solvers::VectorXDecisionVariable > &vars) const
Adds a constraint to an existing MathematicalProgram enforcing that the point defined by vars is inside the set. More...

std::vector< solvers::Binding< solvers::Constraint > > AddPointInNonnegativeScalingConstraints (solvers::MathematicalProgram *prog, const Eigen::Ref< const solvers::VectorXDecisionVariable > &x, const symbolic::Variable &t) const
Let S be this convex set. More...

std::vector< solvers::Binding< solvers::Constraint > > AddPointInNonnegativeScalingConstraints (solvers::MathematicalProgram *prog, const Eigen::Ref< const Eigen::MatrixXd > &A, const Eigen::Ref< const Eigen::VectorXd > &b, const Eigen::Ref< const Eigen::VectorXd > &c, double d, const Eigen::Ref< const solvers::VectorXDecisionVariable > &x, const Eigen::Ref< const solvers::VectorXDecisionVariable > &t) const
Let S be this convex set. More...

std::pair< std::unique_ptr< Shape >, math::RigidTransformd > ToShapeWithPose () const
Constructs a Shape and a pose of the set in the world frame for use in the SceneGraph geometry ecosystem. More...

double CalcVolume () const
Computes the exact volume for the convex set. More...

SampledVolume CalcVolumeViaSampling (RandomGenerator *generator, const double desired_rel_accuracy=1e-2, const int max_num_samples=1e4) const
Calculates an estimate of the volume of the convex set using sampling and performing Monte Carlo integration. More...

bool has_exact_volume () const
Returns true if the exact volume can be computed for this convex set instance. More...

Protected Member Functions inherited from ConvexSet
ConvexSet (int ambient_dimension, bool has_exact_volume)
For use by derived classes to construct a ConvexSet. More...

template<typename Archive >
void Serialize (Archive *a)
Implements non-virtual base class serialization. More...

std::optional< symbolic::VariableHandleZeroAmbientDimensionConstraints (solvers::MathematicalProgram *prog, const ConvexSet &set, std::vector< solvers::Binding< solvers::Constraint >> *constraints) const
Instances of subclasses such as CartesianProduct and MinkowskiSum can have constituent sets with zero ambient dimension, which much be handled in a special manner when calling methods such as DoAddPointInSetConstraints. More...

ConvexSet (const ConvexSet &)=default

ConvexSetoperator= (const ConvexSet &)=default

ConvexSet (ConvexSet &&)=default

ConvexSetoperator= (ConvexSet &&)=default

## ◆ CartesianProduct() [1/7]

 CartesianProduct ( const CartesianProduct & )
default

## ◆ CartesianProduct() [2/7]

 CartesianProduct ( CartesianProduct && )
default

## ◆ CartesianProduct() [3/7]

 CartesianProduct ( )

Constructs a default (zero-dimensional, nonempty) set.

## ◆ CartesianProduct() [4/7]

 CartesianProduct ( const ConvexSets & sets )
explicit

Constructs the product from a vector of convex sets.

## ◆ CartesianProduct() [5/7]

 CartesianProduct ( const ConvexSet & setA, const ConvexSet & setB )

Constructs the product from a pair of convex sets.

## ◆ CartesianProduct() [6/7]

 CartesianProduct ( const ConvexSets & sets, const Eigen::Ref< const Eigen::MatrixXd > & A, const Eigen::Ref< const Eigen::VectorXd > & b )

Constructs the product of convex sets in the transformed coordinates: {x | y = Ax + b, y ∈ Y₁ × Y₂ × ⋯ × Yₙ}.

Exceptions
 std::exception when A is not full column rank.

## ◆ CartesianProduct() [7/7]

 CartesianProduct ( const QueryObject< double > & query_object, GeometryId geometry_id, std::optional< FrameId > reference_frame = std::nullopt )

Constructs a CartesianProduct from a SceneGraph geometry and pose in the reference_frame frame, obtained via the QueryObject.

If reference_frame frame is std::nullopt, then it will be expressed in the world frame.

Although any geometry that can be used as a ConvexSet could also be a (trivial) CartesianProduct, we restrict this constructor to handling Cylinder geometry, which constructs the (non-trivial) Cartesian product of a HyperEllipsoid and an HPolyhedron. Most other SceneGraph geometry types are supported by at least one of the ConvexSet class constructors.

Exceptions
 std::exception if geometry_id does not correspond to a Cylinder.

## ◆ ~CartesianProduct()

 ~CartesianProduct ( )
final

## ◆ CalcVolume()

 double CalcVolume
Exceptions
 if set.has_exact_volume() == false for any of the sets in the product.

## ◆ factor()

 const ConvexSet& factor ( int i ) const

Returns a reference to the ConvexSet defining the index factor in the product.

## ◆ num_factors()

 int num_factors ( ) const

The number of factors (or sets) used in the product.

## ◆ operator=() [1/2]

 CartesianProduct& operator= ( CartesianProduct && )
default

## ◆ operator=() [2/2]

 CartesianProduct& operator= ( const CartesianProduct & )
default

## ◆ PointInSet()

 bool PointInSet

Returns true if each subvector is in its corresponding set with tolerance tol.

Note: Tolerance support for this query varies in the different convex set implementations.

The documentation for this class was generated from the following file: