Grasp Class Reference

A grasp occurs between a hand and an object and has quality measures associated with it. More...

#include <grasp.h>

Inheritance diagram for Grasp:
Inheritance graph
[legend]

List of all members.

Signals

void graspUpdated ()
 Called when contacts have changes and the wrench spaces need to be updated.

Public Member Functions

void accumulateAndDisplayObjectWrenches (std::list< Contact * > *contacts, const Matrix &objectWrenches)
 Accumulates object wrenches in the external wrench accumulator for the objects.
GWSaddGWS (const char *type)
 Adds a GWS of a given type to the grasp, unless one exists already.
void addProjection (GWSprojection *gp)
void addQM (QualityMeasure *qm)
 Adds a quality measure to this grasp.
void collectContacts ()
 Collects all the contacts between the hand and the object in an internal list.
void collectVirtualContacts ()
 Collects all the virtual contacts on the hand n an internal list.
void collectVirtualContactsOnObject ()
 Collect all the virtual contacts on the object.
int computeQuasistaticForces (const Matrix &robotTau)
 Given a vector of joint torques, computes the contact forces that balance the system.
int computeQuasistaticForcesAndTorques (Matrix *robotTau, int computation)
 Computes the contact forces and joint torques that give the most robust equilibrium.
Matrix contactJacobian (const std::list< Joint * > &joints, const std::list< VirtualContact * > &contacts)
 A convenience version of the Jacobian function that takes in a list of virtual contacts.
Matrix contactJacobian (const std::list< Joint * > &joints, const std::list< Contact * > &contacts)
 A convenience version of the Jacobian function that takes in a list of contacts.
Matrix contactJacobian (const std::list< Joint * > &joints, const std::list< std::pair< transf, Link * > > &contact_locations)
 A version of the contact grasp Jacobian, used for GFO routines.
void displayContactWrenches (std::list< Contact * > *contacts, const Matrix &contactWrenches)
 Sets local contact wrenches into the contact wrench slots so they can be rendered.
position getCoG ()
 Returns the c.o.g. used in GWS computations, either from the object of from virtual contacts.
ContactgetContact (int i) const
GWSgetGWS (const char *type)
std::list< Joint * > getJointsOnContactChains ()
 Gets a list with only the joints on chains that have contacts on them.
double getMaxRadius ()
 Returns the max radius used in GWS computations, either from the object of from virtual contacts.
void getMinWrench (double *w) const
int getNumContacts () const
int getNumQM () const
GraspableBodygetObject () const
QualityMeasuregetQM (int which)
 Returns one of the quality measures that have been associated with this grasp.
 Grasp (Hand *h)
bool isGravitySet ()
bool isValid () const
void removeGWS (GWS *gws)
 Decrements the reference count on a GWS of the given type, and deletes it if the ref count reaches 0.
void removeProjection (GWSprojection *gp)
void removeQM (int which)
 Removes a quality measure that has been associated with this grasp.
void replaceQM (int which, QualityMeasure *qm)
 Replaces a QM in the list associated with this grasp with another QM.
void setGravity (bool g)
 Sets whether QM's should take gravity into account; not very thoroughly tested yet.
void setMinWrench (double *w)
void setObject (GraspableBody *g)
void setObjectNoUpdate (GraspableBody *g)
void update (std::vector< int > useDimensions=ALL_DIMENSIONS)
 Collects all the contacts in the internal list and updates the wrench spaces.
void updateWrenchSpaces (std::vector< int > useDimensions=ALL_DIMENSIONS)
 Updates (re-computes) the wrench spaces of this grasp and all of their projections.
 ~Grasp ()

Static Public Member Functions

static void destroyProjection (void *user, SoQtComponent *component)
static Matrix graspMapMatrix (const Matrix &R, const Matrix &D)
 Computes the grasp map matrix G from friction and normal force matrices R and D.

Static Public Attributes

static const std::vector< int > ALL_DIMENSIONS = std::vector<int>(6, 1)
 Default option for building a GWS on all 6 dimensions.
static const int CONTACT_FORCE_EXISTENCE = 0
static const int CONTACT_FORCE_OPTIMIZATION = 1
static const int GRASP_FORCE_EXISTENCE = 2
static const int GRASP_FORCE_OPTIMIZATION = 3

Protected Member Functions

double * getLinkJacobian (int f, int l)
 Computes the Jacobian of a link wrt the base of the finger, in link coordinates.
void setRealCentroid (GraspableBody *body)
 Sets the reference points of all virtual contacts using the c.o.g of the given object.
void setVirtualCentroid ()
 Sets the reference point that is used for grasp wrench computations as the center of the virtual contacts.
vec3 virtualCentroid ()
 Computes the virtual center of the internally assembled list of virtual contacts.

Protected Attributes

std::vector< Contact * > contactVec
 A vector of pointers to the contacts on the object where it touches the hand.
std::list< GWS * > gwsList
 A list of pointers to the associated grasp wrench spaces.
Handhand
 A pointer to the hand that owns this grasp object.
double minWrench [6]
 Minimum grasp wrench that can be applied given contact forces that sum to 1.
int numContacts
 Number of grasp contacts.
int numQM
 Number of quality meausre in the list.
GraspableBodyobject
 A pointer to the object that is the focus of this grasp.
std::list< GWSprojection * > projectionList
 A list of pointer to the associated grasp wrench space projections.
std::list< QualityMeasure * > qmList
 A list of pointers to the associated quality measures.
bool useGravity
 Tells us if quality metrics should take into account gravity.
bool valid
 TRUE if the grasp has been updated since the last time the contacts changed

Friends

class LMIOptimizer
class QMDlg

Detailed Description

A grasp occurs between a hand and an object and has quality measures associated with it.

Each hand object has a grasp associated with it, and the grasp occurs between the hand and a graspableBody. Each grasp is incharge of maintaining a set of computed grasp wrench spaces, which are then used by various quality measures. When contacts change between the two, the grasp is updated, meaning each grasp wrench space associated with the grasp is rebuilt, as well as any grasp wrench space projections. All grasp quality measures are also re-evaluated.

The grasp wrench spaces are designed to be shared by different quality metrics. When a new metric is added, if a GWS of the needed type already exists in the list maintained by thhis grasp, the new QM will use it, and a reference count on the GWS is increased. GWS are automatically deleted when no QM that needs them exist anymore.

A grasp can also perform many of the same services on set of VirtualCotacts (see documentation of that class for details). This part however has not neen competely tested, and might produce behavior that is not entirely consistent with how it handles traditional contacts.

This class also provides the mechanism for performing Grasp Force Optimization (GFO) computations using a Quadratic Program (QP) formulation. There are many variants of this computation; some of them are already written. You can generally mix and match between optimization criteria and constraints in any way you want. A good starting point is the computeQuasistaticForcesAndTorques(...) function.

Definition at line 94 of file grasp.h.


Constructor & Destructor Documentation

Grasp::Grasp ( Hand h  ) 

Initialize grasp object variables. A grasp should only be created by a hand constructor, which passes a pointer to itself.

Definition at line 86 of file grasp.cpp.

Grasp::~Grasp (  ) 

Deletes all quality measures, grasps wrench spaces, and projections associated with this grasp. Frees all of the dynamically allocated vectors and matrics used for GFO.

Definition at line 106 of file grasp.cpp.


Member Function Documentation

void Grasp::accumulateAndDisplayObjectWrenches ( std::list< Contact * > *  contacts,
const Matrix objectWrenches 
)

Accumulates object wrenches in the external wrench accumulator for the objects.

This is a helper function for grasp force optimization routines. Given a set of contacts, and a matrix of contact wrenches expressed in *world* coordinates and relative to object origin (as computed in gfo routines) this function will convert them to object coordinate system and accumulate them in the object's external wrench accumulator. This can serve as an output of the gfo functions and also for rendering purposes, as the external wrench accumulator can then be rendered.

Definition at line 1386 of file grasp.cpp.

GWS * Grasp::addGWS ( const char *  type  ) 

Adds a GWS of a given type to the grasp, unless one exists already.

Creates a new GWS of type type and adds it to the list of GWS's associated with this grasp if it does not exist already. Current possible types of GWS's are "L1 Norm", and "LInfinity Norm". Returns a pointer to a gws of the requested type that was either created or found.

Definition at line 146 of file grasp.cpp.

void Grasp::addProjection ( GWSprojection gp  ) 

Add a grasp wrench space projection to the grasp's list of projections.

Definition at line 254 of file grasp.cpp.

void Grasp::addQM ( QualityMeasure qm  ) 

Adds a quality measure to this grasp.

Adds the quality measure to the grasp's list of quality measures.

Definition at line 190 of file grasp.cpp.

void Grasp::collectContacts (  ) 

Collects all the contacts between the hand and the object in an internal list.

Gathers the contacts on all links of the hand that are mated with contacts on the grasped object and adds them to the contactVec.

It also collects all contacts from hands attached to this one, and treats all of them as one big grasp. This allows us to do grasp analysis for complex robots, such as the M7, which has manipulators attached at the end of the arms. If you want to do grasp analysis just for the contacts on one of the manipulators, use the instance of Grasp of that particular hand.

Definition at line 377 of file grasp.cpp.

void Grasp::collectVirtualContacts (  ) 

Collects all the virtual contacts on the hand n an internal list.

Gathers the virtual contacts on all links of the hand and adds them to the internal list in contactVec. Any GWS computations should then be able to proceed regardless of the fact that these are virtual contacts. However, since we might not have an object, information about the centroid to be used as reference point, and the max radius used for converting torques, are also computed and stored in the virtual contacts themselves.

Definition at line 481 of file grasp.cpp.

void Grasp::collectVirtualContactsOnObject (  ) 

Collect all the virtual contacts on the object.

When we are dealing with an object but no hand, gathers the virtual contacts from the object and adds them to the contactVec, doing the same thing as collectContacts() and collectVirtualContacts() do for the hand-and-object and the hand-only cases.

Definition at line 527 of file grasp.cpp.

int Grasp::computeQuasistaticForces ( const Matrix robotTau  ) 

Given a vector of joint torques, computes the contact forces that balance the system.

One possible version of the GFO problem.

Given a matrix of joint torques applied to the robot joints, this will check if there exists a set of legal contact forces that balance them. If so, it will compute the set of contact forces that adds up to the wrench of least magnitude on the object.

For now, this output of this function is to set the computed contact forces on each contact as dynamic forces, and also to accumulate the resulting wrench on the object in its external wrench accumulator.

Return codes: 0 is success, >0 means finger slip, no legal contact forces exist; <0 means error in computation

Definition at line 763 of file grasp.cpp.

int Grasp::computeQuasistaticForcesAndTorques ( Matrix robotTau,
int  computation 
)

Computes the contact forces and joint torques that give the most robust equilibrium.

This function is the equivalent of the Grasp Force Optimization, but done with the quasi-static formulation cast as a Quadratic Program.

It can perform four types of computation:

  • contact force existence: are there contact forces that balance out on the object
  • contact force optimization: what are the optimal contact forces (as far as possible from the edges of the friction cones) that balance out on the object
  • grasp force existence: are there joint forces which produce contact forces which balance out on the object
  • grasp force optimization: what are the optimal joint forces, producing contact forces that are as far as possible from the edges of the friction cones and balance out on the object. See individual computation routines for more details.

There might exist cases of grasps that are reported as form-closed where grasp force existence fails, as this function also asks that the contact forces that balance the object must be possible to apply from actuated DOF's.

For now, this function displays the computed contact forces on the contacts, rather than returning them. It also copies the computed joint forces in the matrix robotTau which is assumed to be large enough for all the joints of the robot and use the robot's numbering scheme.

Return codes: 0 is success, >0 means problem is unfeasible, no equilibrium forces exist; <0 means error in computation

Definition at line 1240 of file grasp.cpp.

Matrix Grasp::contactJacobian ( const std::list< Joint * > &  joints,
const std::list< VirtualContact * > &  contacts 
)

A convenience version of the Jacobian function that takes in a list of virtual contacts.

Simply gets the locations of all the contacts in the list and calls the more general version that takes in std::list< std::pair<transf, Link*> > &contact_locations

Definition at line 703 of file grasp.cpp.

Matrix Grasp::contactJacobian ( const std::list< Joint * > &  joints,
const std::list< Contact * > &  contacts 
)

A convenience version of the Jacobian function that takes in a list of contacts.

Simply gets the locations of all the contacts in the list and calls the more general version that takes in std::list< std::pair<transf, Link*> > &contact_locations

Definition at line 684 of file grasp.cpp.

Matrix Grasp::contactJacobian ( const std::list< Joint * > &  joints,
const std::list< std::pair< transf, Link * > > &  contact_locations 
)

A version of the contact grasp Jacobian, used for GFO routines.

Computes the contact jacobian J. J relates joint angle motion to contact motion. Its transpose, JT, relates contact forces to joint forces.

The joints and the contacts must both be passed in. Their order in the incoming vectors will determine their indices in the Jacobian. This function will make sure that only the right joints affect each contact: joints that come before the link in contact, on the same chain.

The Jacobian is ALWAYS computed in the local coordinate system of each contact. When multiplied by joint torques, it will thus yield contact forces and torques in the local contact coordinate system of each contact. It is easy to do computations in world coordinates too, but then it is impossible to discards rows that correspond to directions that the contact can not apply force or torque in.

Definition at line 636 of file grasp.cpp.

void Grasp::destroyProjection ( void *  user,
SoQtComponent component 
) [static]

This is the projection window close callback function. When the projection window is closed, this removes the associated GWSprojection.

Definition at line 275 of file grasp.cpp.

void Grasp::displayContactWrenches ( std::list< Contact * > *  contacts,
const Matrix contactWrenches 
)

Sets local contact wrenches into the contact wrench slots so they can be rendered.

This is a helper function for grasp force optimization routines. Given a set of contacts and a matrix of contact wrenches expressed in *local* contact coordinates, it will set these wrenches in the dynamic wrench slot of the contacts for rendering purposes.

Definition at line 1353 of file grasp.cpp.

position Grasp::getCoG (  ) 

Returns the c.o.g. used in GWS computations, either from the object of from virtual contacts.

Definition at line 558 of file grasp.cpp.

Contact* Grasp::getContact ( int  i  )  const [inline]

Return a pointer to the i-th grasp contact on the object.

Definition at line 177 of file grasp.h.

GWS * Grasp::getGWS ( const char *  type  ) 

Returns a pointer to the GWS of type type if one exists. If one doesn't it returns NULL

Definition at line 126 of file grasp.cpp.

std::list< Joint * > Grasp::getJointsOnContactChains (  ) 

Gets a list with only the joints on chains that have contacts on them.

Retrieve all the joints of the robot, but only if their chains have contacts on them. Joints on chains with no contact have a trivial 0 solution so they only make the problem larger for no good reason. we could go even further and only keep the joints that come *before* the contacts in the chain.

Definition at line 1201 of file grasp.cpp.

double * Grasp::getLinkJacobian ( int  f,
int  l 
) [protected]

Computes the Jacobian of a link wrt the base of the finger, in link coordinates.

Computes the jacobian for the base frame of link l on finger f relative to the base frame of the finger. This is wrt THE FRAME OF LINK!!!

Distances USED TO BE converted to meters (check why this is...). Now they are kept in MILLIMETERS!

Definition at line 573 of file grasp.cpp.

double Grasp::getMaxRadius (  ) 

Returns the max radius used in GWS computations, either from the object of from virtual contacts.

Definition at line 550 of file grasp.cpp.

void Grasp::getMinWrench ( double *  w  )  const [inline]

Definition at line 179 of file grasp.h.

int Grasp::getNumContacts (  )  const [inline]

Return the number of grasp contacts.

Definition at line 174 of file grasp.h.

int Grasp::getNumQM (  )  const [inline]

Returns whether the grasp force optimization problem is feasible.

Returns the number of quality measures defined for this grasp.

Definition at line 168 of file grasp.h.

GraspableBody* Grasp::getObject (  )  const [inline]

Return a pointer to the object that is the focus of this grasp.

Definition at line 171 of file grasp.h.

QualityMeasure * Grasp::getQM ( int  which  ) 

Returns one of the quality measures that have been associated with this grasp.

Returns a pointer to the requested quality measure. which is the index of the qm to return, where 0 is the first qm in the list.

Definition at line 221 of file grasp.cpp.

Matrix Grasp::graspMapMatrix ( const Matrix R,
const Matrix D 
) [static]

Computes the grasp map matrix G from friction and normal force matrices R and D.

Computes the grasp map G. D is the matrix that relates friction edge amplitudes to contact force and R is the matrix that transorms contact forces to world coordinate system. We then need to sum all of them up by multiplication with a summation matrix to get the grasp map

G = S R D

G relates friction edge amplitudes from all contacts to resultant object wrench.

Definition at line 730 of file grasp.cpp.

void Grasp::graspUpdated (  )  [signal]

Called when contacts have changes and the wrench spaces need to be updated.

Definition at line 81 of file moc_grasp.cpp.

bool Grasp::isGravitySet (  )  [inline]

Definition at line 233 of file grasp.h.

bool Grasp::isValid (  )  const [inline]

Returns whether the grasp has been updated since the last time grasp contacts have changed.

Definition at line 162 of file grasp.h.

void Grasp::removeGWS ( GWS gws  ) 

Decrements the reference count on a GWS of the given type, and deletes it if the ref count reaches 0.

Given a pointer to the GWS to remove, this decrements the reference count for that GWS. If the reference count becomes 0, the GWS is deleted.

Definition at line 173 of file grasp.cpp.

void Grasp::removeProjection ( GWSprojection gp  ) 

Removes a grasp wrench space projection from the list and deletes it.

Definition at line 264 of file grasp.cpp.

void Grasp::removeQM ( int  which  ) 

Removes a quality measure that has been associated with this grasp.

Removes a quality measure from the list and deletes it. which is the index of the qm to remove, where 0 is the first qm in the list.

Definition at line 236 of file grasp.cpp.

void Grasp::replaceQM ( int  which,
QualityMeasure qm 
)

Replaces a QM in the list associated with this grasp with another QM.

Replaces an existing quality measure with a new one and deletes the old one. which selects which qm to replace where the index of the first qm in the list is 0.

Definition at line 202 of file grasp.cpp.

void Grasp::setGravity ( bool  g  )  [inline]

Sets whether QM's should take gravity into account; not very thoroughly tested yet.

Definition at line 232 of file grasp.h.

void Grasp::setMinWrench ( double *  w  )  [inline]

Definition at line 184 of file grasp.h.

void Grasp::setObject ( GraspableBody g  )  [inline]

Sets graspableBody g to be the new focus of the grasp and updates the grasp.

Definition at line 191 of file grasp.h.

void Grasp::setObjectNoUpdate ( GraspableBody g  )  [inline]

Definition at line 194 of file grasp.h.

void Grasp::setRealCentroid ( GraspableBody body  )  [protected]

Sets the reference points of all virtual contacts using the c.o.g of the given object.

Assumes that all contacts are virtual, but we do have an object so we set its centroid (IN WORLD COORDINATES) and maxradius to all virtual contacts.

Definition at line 462 of file grasp.cpp.

void Grasp::setVirtualCentroid (  )  [protected]

Sets the reference point that is used for grasp wrench computations as the center of the virtual contacts.

Assumes all the contacts in the list are virtual, and computes the centroid and max radius for the grasp based on these virtual contacts.

Definition at line 431 of file grasp.cpp.

void Grasp::update ( std::vector< int >  useDimensions = ALL_DIMENSIONS  ) 

Collects all the contacts in the internal list and updates the wrench spaces.

Updates the grasp by collecting all the current contacts on the hand and rebuilding any grasp wrench spaces and their projections. This is usually called after the contacts on the hand have changed.

Also collects and uses any contacts on robots that are attached to this one. See collectContacts() for details.

You can ask for the GWS to be built using only a subset of the 6 dimensions of force and torque normally available. These are, in this order:

fx, fy, fz, tx, ty, tz

If you want only a subset to be used, pass a vector of 6 ints with 1 for the dimensions you want or 0 for those that you do not want. For example, if you want a GWS that only uses fx, fy and tz, pass the following vector:

1, 1, 0, 0, 0, 1

If you want to use all 6 dimensions, pass the default value of Grasp::ALL_DIMENSIONS.

Note that the dimensions along which the GWS is built affects any subsequent projections that are created

Definition at line 307 of file grasp.cpp.

void Grasp::updateWrenchSpaces ( std::vector< int >  useDimensions = ALL_DIMENSIONS  ) 

Updates (re-computes) the wrench spaces of this grasp and all of their projections.

See Grasp::update() for details about useDimensions which affect the dimensions that are used to build the GWS.

Definition at line 333 of file grasp.cpp.

vec3 Grasp::virtualCentroid (  )  [protected]

Computes the virtual center of the internally assembled list of virtual contacts.

Definition at line 395 of file grasp.cpp.


Friends And Related Function Documentation

friend class LMIOptimizer [friend]

Definition at line 102 of file grasp.h.

friend class QMDlg [friend]

Definition at line 149 of file grasp.h.


Member Data Documentation

const std::vector< int > Grasp::ALL_DIMENSIONS = std::vector<int>(6, 1) [static]

Default option for building a GWS on all 6 dimensions.

This replicates GWS::ALL_DIMENSIONS, but it was needed here too so that we don't have to give any caller access to GWS.

Definition at line 99 of file grasp.h.

const int Grasp::CONTACT_FORCE_EXISTENCE = 0 [static]

Definition at line 237 of file grasp.h.

const int Grasp::CONTACT_FORCE_OPTIMIZATION = 1 [static]

Definition at line 238 of file grasp.h.

std::vector<Contact *> Grasp::contactVec [protected]

A vector of pointers to the contacts on the object where it touches the hand.

Definition at line 126 of file grasp.h.

const int Grasp::GRASP_FORCE_EXISTENCE = 2 [static]

Definition at line 239 of file grasp.h.

const int Grasp::GRASP_FORCE_OPTIMIZATION = 3 [static]

Definition at line 240 of file grasp.h.

std::list<GWS *> Grasp::gwsList [protected]

A list of pointers to the associated grasp wrench spaces.

Definition at line 114 of file grasp.h.

Hand* Grasp::hand [protected]

A pointer to the hand that owns this grasp object.

Definition at line 105 of file grasp.h.

double Grasp::minWrench[6] [protected]

Minimum grasp wrench that can be applied given contact forces that sum to 1.

Definition at line 132 of file grasp.h.

int Grasp::numContacts [protected]

Number of grasp contacts.

Definition at line 129 of file grasp.h.

int Grasp::numQM [protected]

Number of quality meausre in the list.

Definition at line 123 of file grasp.h.

A pointer to the object that is the focus of this grasp.

Definition at line 108 of file grasp.h.

std::list<GWSprojection *> Grasp::projectionList [protected]

A list of pointer to the associated grasp wrench space projections.

Definition at line 120 of file grasp.h.

std::list<QualityMeasure *> Grasp::qmList [protected]

A list of pointers to the associated quality measures.

Definition at line 117 of file grasp.h.

bool Grasp::useGravity [protected]

Tells us if quality metrics should take into account gravity.

Definition at line 135 of file grasp.h.

bool Grasp::valid [protected]

TRUE if the grasp has been updated since the last time the contacts changed

Definition at line 111 of file grasp.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


graspit
Author(s):
autogenerated on Wed Jan 25 11:00:21 2012