Drake
Drake C++ Documentation
CspaceFreePolytopeBase Class Reference

Detailed Description

This virtual class is the base of CspaceFreePolytope and CspaceFreeBox.

We take the common functionality between these concrete derived class to this shared parent class.

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

Classes

struct  Options
 Optional argument for constructing CspaceFreePolytopeBase. More...
 

Public Types

using IgnoredCollisionPairs = std::unordered_set< SortedPair< geometry::GeometryId > >
 

Public Member Functions

virtual ~CspaceFreePolytopeBase ()
 
const multibody::RationalForwardKinematicsrational_forward_kin () const
 Getter for the rational forward kinematics object that computes the forward kinematics as rational functions. More...
 
const std::unordered_map< SortedPair< geometry::GeometryId >, int > & map_geometries_to_separating_planes () const
 separating_planes()[map_geometries_to_separating_planes.at(geometry1_id, geometry2_id)] is the separating plane that separates geometry 1 and geometry 2. More...
 
const std::vector< CSpaceSeparatingPlane< symbolic::Variable > > & separating_planes () const
 All the separating planes between each pair of geometries. More...
 
const Vector3< symbolic::Variable > & y_slack () const
 Get the slack variable used for non-polytopic collision geometries. More...
 
Does not allow copy, move, or assignment
 CspaceFreePolytopeBase (const CspaceFreePolytopeBase &)=delete
 
CspaceFreePolytopeBaseoperator= (const CspaceFreePolytopeBase &)=delete
 
 CspaceFreePolytopeBase (CspaceFreePolytopeBase &&)=delete
 
CspaceFreePolytopeBaseoperator= (CspaceFreePolytopeBase &&)=delete
 

Protected Types

enum  SForPlane { kAll, kOnChain }
 When we set up the separating plane {x | a(s)ᵀx + b(s) = 0} between a pair of geometries, we need to determine which s are used in a(s) and b(s). More...
 

Protected Member Functions

 CspaceFreePolytopeBase (const multibody::MultibodyPlant< double > *plant, const geometry::SceneGraph< double > *scene_graph, SeparatingPlaneOrder plane_order, SForPlane s_for_plane_enum, const Options &options=Options{})
 Constructor. More...
 
template<typename T >
void CalcSBoundsPolynomial (const VectorX< T > &s_lower, const VectorX< T > &s_upper, VectorX< symbolic::Polynomial > *s_minus_s_lower, VectorX< symbolic::Polynomial > *s_upper_minus_s) const
 Computes s-s_lower and s_upper - s as polynomials of s. More...
 
int GetSeparatingPlaneIndex (const SortedPair< geometry::GeometryId > &pair) const
 Returns the index of the plane which will separate the geometry pair. More...
 
const symbolic::Variablesget_s_set () const
 
const geometry::SceneGraph< double > & scene_graph () const
 
const std::map< multibody::BodyIndex, std::vector< std::unique_ptr< CIrisCollisionGeometry > > > & link_geometries () const
 
SeparatingPlaneOrder plane_order () const
 
const std::unordered_map< SortedPair< multibody::BodyIndex >, std::array< VectorX< symbolic::Monomial >, 4 > > & map_body_to_monomial_basis_array () const
 Maps a pair of body (body1, body2) to an array of monomial basis monomial_basis_array. More...
 
bool with_cross_y () const
 Check Options::with_cross_y for more details. More...
 
const std::unordered_map< SortedPair< multibody::BodyIndex >, std::vector< int > > & map_body_pair_to_s_on_chain () const
 For a pair of bodies body_pair, returns the indices of all s on the kinematics chain from body_pair.first() to body_pair.second(). More...
 
VectorX< symbolic::VariableGetSForPlane (const SortedPair< multibody::BodyIndex > &body_pair, SForPlane s_for_plane_enum) const
 Returns a vector of s variable used in a(s), b(s), which parameterize the separating plane {x | a(s)ᵀx+b(s) = 0}. More...
 
void SolveCertificationForEachPlaneInParallel (const std::vector< int > &active_plane_indices, const std::function< std::pair< bool, int >(int)> &solve_plane_sos, Parallelism parallelism, bool verbose, bool terminate_at_failure) const
 For each pair of geometries, solve the certification problem to find their separation plane in parallel. More...
 
int GetGramVarSizeForPolytopeSearchProgram (const std::vector< PlaneSeparatesGeometries > &plane_geometries_vec, const IgnoredCollisionPairs &ignored_collision_pairs, const std::function< int(const symbolic::RationalFunction &rational, const std::array< VectorX< symbolic::Monomial >, 4 > &monomial_basis_array)> &count_gram_per_rational) const
 Get the total size of all the decision variables for the Gram matrices, so as to search for the polytope with given Lagrangian multipliers. More...
 

Friends

class CspaceFreePolytopeBaseTester
 

Member Typedef Documentation

◆ IgnoredCollisionPairs

using IgnoredCollisionPairs = std::unordered_set<SortedPair<geometry::GeometryId> >

Member Enumeration Documentation

◆ SForPlane

enum SForPlane
strongprotected

When we set up the separating plane {x | a(s)ᵀx + b(s) = 0} between a pair of geometries, we need to determine which s are used in a(s) and b(s).

Enumerator
kAll 

Use all s in the robot tangent-configuration space.

kOnChain 

Use s on the kinematics chain between the pair of geometries.

Constructor & Destructor Documentation

◆ CspaceFreePolytopeBase() [1/3]

◆ CspaceFreePolytopeBase() [2/3]

◆ ~CspaceFreePolytopeBase()

virtual ~CspaceFreePolytopeBase ( )
virtual

◆ CspaceFreePolytopeBase() [3/3]

CspaceFreePolytopeBase ( const multibody::MultibodyPlant< double > *  plant,
const geometry::SceneGraph< double > *  scene_graph,
SeparatingPlaneOrder  plane_order,
SForPlane  s_for_plane_enum,
const Options options = Options{} 
)
protected

Constructor.

We put the constructor in protected method to make sure that the user cannot instantiate a CspaceFreePolytopeBase instance.

Precondition
plant and scene_graph should be non-null pointers.

Member Function Documentation

◆ CalcSBoundsPolynomial()

void CalcSBoundsPolynomial ( const VectorX< T > &  s_lower,
const VectorX< T > &  s_upper,
VectorX< symbolic::Polynomial > *  s_minus_s_lower,
VectorX< symbolic::Polynomial > *  s_upper_minus_s 
) const
protected

Computes s-s_lower and s_upper - s as polynomials of s.

◆ get_s_set()

const symbolic::Variables& get_s_set ( ) const
protected

◆ GetGramVarSizeForPolytopeSearchProgram()

int GetGramVarSizeForPolytopeSearchProgram ( const std::vector< PlaneSeparatesGeometries > &  plane_geometries_vec,
const IgnoredCollisionPairs ignored_collision_pairs,
const std::function< int(const symbolic::RationalFunction &rational, const std::array< VectorX< symbolic::Monomial >, 4 > &monomial_basis_array)> &  count_gram_per_rational 
) const
protected

Get the total size of all the decision variables for the Gram matrices, so as to search for the polytope with given Lagrangian multipliers.

Parameters
plane_geometries_vecThis struct contains the information on the rationals that we need to certify, so as to prove the existence of separating planes.
ignored_collision_pairsThe collision pairs that we ignore.
count_gram_per_rationalWe will impose the sos condition that certain rational is always non-negative within a semialgebraic set. This function returns the number of variables in the Gram matrices for this rational.

◆ GetSeparatingPlaneIndex()

int GetSeparatingPlaneIndex ( const SortedPair< geometry::GeometryId > &  pair) const
protected

Returns the index of the plane which will separate the geometry pair.

Returns -1 if the pair is not in map_geometries_to_separating_planes_.

◆ GetSForPlane()

VectorX<symbolic::Variable> GetSForPlane ( const SortedPair< multibody::BodyIndex > &  body_pair,
SForPlane  s_for_plane_enum 
) const
protected

Returns a vector of s variable used in a(s), b(s), which parameterize the separating plane {x | a(s)ᵀx+b(s) = 0}.

◆ link_geometries()

const std::map< multibody::BodyIndex, std::vector<std::unique_ptr<CIrisCollisionGeometry> > >& link_geometries ( ) const
protected

◆ map_body_pair_to_s_on_chain()

const std::unordered_map<SortedPair<multibody::BodyIndex>, std::vector<int> >& map_body_pair_to_s_on_chain ( ) const
protected

For a pair of bodies body_pair, returns the indices of all s on the kinematics chain from body_pair.first() to body_pair.second().

For each pair of collidable collision geometry (A, B), we denote their body as (bodyA, bodyB). This keys in this map include all these (bodyA, bodyB), together with (body_middle, bodyA) and (body_middle, bodyB), where body_middle is the body in the middle of the kinematics chain between bodyA and bodyB.

◆ map_body_to_monomial_basis_array()

const std::unordered_map< SortedPair<multibody::BodyIndex>, std::array<VectorX<symbolic::Monomial>, 4> >& map_body_to_monomial_basis_array ( ) const
protected

Maps a pair of body (body1, body2) to an array of monomial basis monomial_basis_array.

monomial_basis_array[0] contains all the monomials of form ∏ᵢ pow(sᵢ, dᵢ), dᵢ=0 or 1, sᵢ correspond to the revolute/prismatic joint on the kinematic chain between body1 and body2. monomial_basis_array[i+1] = y_slack_[i] * monomial_basis_array[0]

◆ map_geometries_to_separating_planes()

const std::unordered_map<SortedPair<geometry::GeometryId>, int>& map_geometries_to_separating_planes ( ) const

separating_planes()[map_geometries_to_separating_planes.at(geometry1_id, geometry2_id)] is the separating plane that separates geometry 1 and geometry 2.

◆ operator=() [1/2]

CspaceFreePolytopeBase& operator= ( CspaceFreePolytopeBase &&  )
delete

◆ operator=() [2/2]

CspaceFreePolytopeBase& operator= ( const CspaceFreePolytopeBase )
delete

◆ plane_order()

SeparatingPlaneOrder plane_order ( ) const
protected

◆ rational_forward_kin()

const multibody::RationalForwardKinematics& rational_forward_kin ( ) const

Getter for the rational forward kinematics object that computes the forward kinematics as rational functions.

◆ scene_graph()

const geometry::SceneGraph<double>& scene_graph ( ) const
protected

◆ separating_planes()

const std::vector<CSpaceSeparatingPlane<symbolic::Variable> >& separating_planes ( ) const

All the separating planes between each pair of geometries.

◆ SolveCertificationForEachPlaneInParallel()

void SolveCertificationForEachPlaneInParallel ( const std::vector< int > &  active_plane_indices,
const std::function< std::pair< bool, int >(int)> &  solve_plane_sos,
Parallelism  parallelism,
bool  verbose,
bool  terminate_at_failure 
) const
protected

For each pair of geometries, solve the certification problem to find their separation plane in parallel.

Parameters
active_plane_indicesWe will search for the plane in this->separating_planes()[active_plane_indices[i]].
solve_plane_sosThe solve_plane_sos(plane_count) returns the pair (is_success, plane_count), where is_success indicates whether the solve for this->separating_planes()[active_plane_indices[plane_count]] is successful or not. This function returns the input plane_count as one of the output. This is because when we access the return value of solve_small_sos, we need to know the plane_count, and the return value and the input plane_count live in different part of the code due to multi-threading.
parallelismThe number of threads in the parallel solve.
verboseWhether to print out some messages during the parallel solve.
terminate_at_failureIf set to true, then terminate this function when we failed to find a separating plane.

◆ with_cross_y()

bool with_cross_y ( ) const
protected

Check Options::with_cross_y for more details.

◆ y_slack()

const Vector3<symbolic::Variable>& y_slack ( ) const

Get the slack variable used for non-polytopic collision geometries.

Check Options class for more details.

Friends And Related Function Documentation

◆ CspaceFreePolytopeBaseTester

friend class CspaceFreePolytopeBaseTester
friend

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