grasp_tester Class Reference

This class is used to evaluate a set of candidate grasps. More...

#include <grasp_tester.h>

List of all members.

Signals

void testingComplete ()

Public Member Functions

bool callTestIt (std::list< plannedGrasp * > &graspList_in, bool render_in)
void continueTests ()
void get_testingParameters (int &itStepNr, double &stepSize)
 grasp_tester ()
void pauseTests ()
void saveGraspsToFile (const QString &filename, bool append)
bool set_testingParameters (int itStepNr, double stepSize)
void setupGraspVisWindow (GraspableBody *myBody, SoGroup *prim)
void useQM (int qmNum)
void visualizePlannedGrasps (std::list< plannedGrasp * > grList)
 ~grasp_tester ()

Private Member Functions

bool checkContactToHand (GraspableBody *gb)
bool handCollision ()
bool iteration (plannedGrasp &pg)
bool moveIt (cartesianGraspDirection gd, bool render_in=false)
void orderGraspListByQuality (std::list< plannedGrasp * > &grl)
bool preshapeIt (preshape p, bool render_in=false)
bool putIt (plannedGrasp *pg, bool render_in=false)
void saveGrasp (double quality)
void savePosition (plannedGrasp &pg)
void testIt ()
void updateGlobals ()

Static Private Member Functions

static void testItCB (void *, SoSensor *sensor)

Private Attributes

int actualGraspNr
 Number of grasps that have been tested.
double backStepSize
 Distance in mm of on backstep.
CollisionReport colReport
 Collision report for testing hand collisions.
double * dofs
 An array of the original DOF values for the hand stored before testing begins.
SoSeparator * glRoot
 All visualized grasps are added to this separator.
QFile graspFile
 The output file for testing results.
std::list< plannedGrasp * > * graspList
 The list of grasps to be evaluated.
QTextStream graspOut
 Output stream that results are written to.
SoSensor * idleSensor
 A pointer to the Inventor sensor that allows testing only when the user isn't doing anything.
std::list< plannedGrasp * >
::iterator 
it_gr
 An iterator into the graspList.
IVmgrivmgr
 A pointer to the Inventor manager.
int maxItStepNr
 Maximum number of backsteps that may be taken.
GraspableBodymy_body
 A pointer to the grasped body.
Graspmy_grasp
 A pointer to the hand's grasp class.
Handmy_hand
 A pointer to the hand doing the grasping.
Worldmy_world
 A pointer to the world containing the hand and object.
SoQtExaminerViewermyViewer
 A pointer to the main viewer.
int nrOfGrasps
 Number of grasps to be tested.
transf origTran
 Stores original pose of the grasping hand before testing begins.
SoGroup * primitives
 A pointer to the scene graph containing the shape primitives of the grasped object.
SoQtRenderAreaprojectionViewer
 A pointer to the grasp visualization window.
bool render
 Whether or not to render hand motion during testing.
bool saveToFile
 Whether or not to save evaluation results to a text file.
int whichQM
 Index of the quality measure used for evaluation.

Detailed Description

This class is used to evaluate a set of candidate grasps.

Given a set of candidate grasps to test, this will perform each one and evaluate it using a quality measure of the user's choice. For each grasp it performs the following steps:

If it is not a force closure grasp, it moves the hand back by a small step and tries the grasp again. This is repeated until a force closure grasp is found or a max number of back steps is reached. The results of the evaluations can be saved in a text file.

In order to allow user interaction during the testing process (it takes a while), an Inventor idle sensor is used to test one grasp at a time when the system is otherwise idle.

This class also handles setting up the grasp visualization window which shows all the position and orientation of all candidate grasps with respect to the object or the shape primitives. As the testing process continues, this is updated to show the relative quality of each evaluated grasp.

The result after testing is a list of the force closure grasps sorted in quality order from best to worst.

When the testing is complete a signal is emitted (which is why this class must be derived from QObject).

Definition at line 115 of file grasp_tester.h.


Constructor & Destructor Documentation

grasp_tester::grasp_tester (  ) 

Initializes variables to default values.

Definition at line 94 of file grasp_tester.cpp.

grasp_tester::~grasp_tester (  ) 

Puts the hand back where it was originally before testing began. If we used a separate world for testing this would not be necessary.

Definition at line 116 of file grasp_tester.cpp.


Member Function Documentation

bool grasp_tester::callTestIt ( std::list< plannedGrasp * > &  graspList_in,
bool  render_in 
)

Begins the testing process. The list of grasps to test is provided in graspList_in , and render_in controls whether the movement of the hand will be shown during the testing process. It helps to understand what is going on, but slows down the process.

This saves the current hand configuration, so that after testing is complete it can be returned to it's original state. However, we may want to create a separate copy of the main world in which to perform the testing, so we don't make any changes to the main world.

An Inventor idleSensor is created to call the testing callback whenever the user is idle. This means that the testing won't interfere with user interaction like changing the camera viewpoint.

Definition at line 216 of file grasp_tester.cpp.

bool grasp_tester::checkContactToHand ( GraspableBody gb  )  [private]

Examines the contacts on grasped body gb , to see if at least one of them is between the object and the hand.

Definition at line 665 of file grasp_tester.cpp.

void grasp_tester::continueTests (  ) 

Creates a new idleSensor to call the testing callback. This will resume testing from wherever it left off.

Definition at line 194 of file grasp_tester.cpp.

void grasp_tester::get_testingParameters ( int &  itStepNr,
double &  stepSize 
)

Returns the values of the testing parameters.

Definition at line 859 of file grasp_tester.cpp.

bool grasp_tester::handCollision (  )  [private]

Checks to see if the hand is in collision with anything.

Definition at line 471 of file grasp_tester.cpp.

bool grasp_tester::iteration ( plannedGrasp pg  )  [private]

Moves the hand a distance of backStepDist back along the grasp approach vector, and tries the grasp again. If the grasp is of minumum quality, it saves it and exits with TRUE. Otherwise it continues stepping the hand back and evaluating grasps until the hand collides with another object or the fingers no longer touch the object, or the max number of back steps, maxItStepNr , is reached. If no grasp has a quality greater than 0, then FALSE is returned.

Definition at line 495 of file grasp_tester.cpp.

bool grasp_tester::moveIt ( cartesianGraspDirection  gd,
bool  render_in = false 
) [private]

Moves the hand to a position that is 1 meter away from its current position in the direction of the hand approach vector gd. Since the hand's moveTo function is used, the motion will stop if it encounters any obstructions, i.e. the object to be grasped, along the way. If render_in is TRUE, the result of this motion is rendered.

Definition at line 737 of file grasp_tester.cpp.

void grasp_tester::orderGraspListByQuality ( std::list< plannedGrasp * > &  grl  )  [private]

Sorts the grasps in grl in quality order from highest to lowest, and deletes those grasps that have a quality < 0.

Definition at line 632 of file grasp_tester.cpp.

void grasp_tester::pauseTests (  ) 

Deletes the idleSensor so that the testing process will stop, but can be resumed later.

Definition at line 183 of file grasp_tester.cpp.

bool grasp_tester::preshapeIt ( preshape  p,
bool  render_in = false 
) [private]

Sets the DOF values of the hand to values associated with preshape p , and if render_in is TRUE, this new configuration is rendered.

Definition at line 711 of file grasp_tester.cpp.

bool grasp_tester::putIt ( plannedGrasp pg,
bool  render_in = false 
) [private]

Sets the transform of the hand to the pose of the candidate grasp pg . If render_in is TRUE, the new pose of the hand is rendered.

Definition at line 688 of file grasp_tester.cpp.

void grasp_tester::saveGrasp ( double  quality  )  [private]

Saves a completed grasp along with the result of the evaluation as one line in the results file.

Definition at line 455 of file grasp_tester.cpp.

void grasp_tester::saveGraspsToFile ( const QString &  filename,
bool  append 
)

Opens a text result file with the name filename to which the results of the evaluations will be saved. The results are saved such that each line represents one tested grasps. Each line has the following format:

  • first 3 numbers are the world position of the palm
  • the next 4 are the components of a quaternion representing the hand orientation,
  • the next 1 is the spread angle of the fingers in radians
  • the last 1 is the value of the quality metric used for evaluation

If append is TRUE, the results will be appended to an existing file. In this case a line of 0's with a quality result of -2 is added at the end of the file before the new results to mark a new set of grasps.

Definition at line 158 of file grasp_tester.cpp.

void grasp_tester::savePosition ( plannedGrasp pg  )  [private]

Stores the final hand configuration after it has been moved and the grasp has performed in the associated candidate grasp record.

Definition at line 569 of file grasp_tester.cpp.

bool grasp_tester::set_testingParameters ( int  itStepNr,
double  stepSize 
)

Sets the testing parameters. itStepNr is the max number of backsteps that can be taken, and stepSize is the length in millimeters of each backstep.

Definition at line 847 of file grasp_tester.cpp.

void grasp_tester::setupGraspVisWindow ( GraspableBody myBody,
SoGroup *  prim 
)

Sets up the grasp visualization window. If one exists already it is deleted. The window consists of a render area, and the scene graph uses the same camera as the main viewer. The primitives sub-graph, pointed to by prim , is added using the same transform as myBody has in the main world. The candidate grasps can then be added to this scene later.

Definition at line 758 of file grasp_tester.cpp.

void grasp_tester::testingComplete (  )  [signal]

This signal is emitted after the last grasp has been tested.

Definition at line 81 of file moc_grasp_tester.cpp.

void grasp_tester::testIt (  )  [private]

This is the main testing function. It is called whenever the user is idle, and it tests the next grasp in the graspList. It follows the testing process defined above. When the last grasp is reached, the hand is returned to its position before the testing began, the graspList is sorted in quality order, and the testingComplete signal is emitted.

Definition at line 285 of file grasp_tester.cpp.

void grasp_tester::testItCB ( void *  ,
SoSensor *  sensor 
) [static, private]

Static callback function called by the idle sensor. This calls the private testIt function to test one grasp.

Definition at line 272 of file grasp_tester.cpp.

void grasp_tester::updateGlobals (  )  [private]

Makes local copies of several global values.

Definition at line 136 of file grasp_tester.cpp.

void grasp_tester::useQM ( int  qmNum  )  [inline]

Sets the index of the quality measure to use for evalutation.

Definition at line 229 of file grasp_tester.h.

void grasp_tester::visualizePlannedGrasps ( std::list< plannedGrasp * >  grList  ) 

Given a list of candidate grasps, grList , this creates a new grasp representation for each one. These representations can be seen in the grasp visualization window.

Definition at line 803 of file grasp_tester.cpp.


Member Data Documentation

Number of grasps that have been tested.

Definition at line 185 of file grasp_tester.h.

double grasp_tester::backStepSize [private]

Distance in mm of on backstep.

Definition at line 191 of file grasp_tester.h.

Collision report for testing hand collisions.

Definition at line 158 of file grasp_tester.h.

double* grasp_tester::dofs [private]

An array of the original DOF values for the hand stored before testing begins.

Definition at line 173 of file grasp_tester.h.

SoSeparator* grasp_tester::glRoot [private]

All visualized grasps are added to this separator.

Definition at line 179 of file grasp_tester.h.

QFile grasp_tester::graspFile [private]

The output file for testing results.

Definition at line 146 of file grasp_tester.h.

std::list<plannedGrasp*>* grasp_tester::graspList [private]

The list of grasps to be evaluated.

Definition at line 161 of file grasp_tester.h.

QTextStream grasp_tester::graspOut [private]

Output stream that results are written to.

Definition at line 149 of file grasp_tester.h.

SoSensor* grasp_tester::idleSensor [private]

A pointer to the Inventor sensor that allows testing only when the user isn't doing anything.

Definition at line 176 of file grasp_tester.h.

std::list<plannedGrasp*>::iterator grasp_tester::it_gr [private]

An iterator into the graspList.

Definition at line 167 of file grasp_tester.h.

A pointer to the Inventor manager.

Definition at line 137 of file grasp_tester.h.

Maximum number of backsteps that may be taken.

Definition at line 188 of file grasp_tester.h.

A pointer to the grasped body.

Definition at line 131 of file grasp_tester.h.

A pointer to the hand's grasp class.

Definition at line 134 of file grasp_tester.h.

A pointer to the hand doing the grasping.

Definition at line 128 of file grasp_tester.h.

A pointer to the world containing the hand and object.

Definition at line 125 of file grasp_tester.h.

A pointer to the main viewer.

Definition at line 122 of file grasp_tester.h.

int grasp_tester::nrOfGrasps [private]

Number of grasps to be tested.

Definition at line 182 of file grasp_tester.h.

Stores original pose of the grasping hand before testing begins.

Definition at line 170 of file grasp_tester.h.

SoGroup* grasp_tester::primitives [private]

A pointer to the scene graph containing the shape primitives of the grasped object.

Definition at line 155 of file grasp_tester.h.

A pointer to the grasp visualization window.

Definition at line 152 of file grasp_tester.h.

bool grasp_tester::render [private]

Whether or not to render hand motion during testing.

Definition at line 164 of file grasp_tester.h.

bool grasp_tester::saveToFile [private]

Whether or not to save evaluation results to a text file.

Definition at line 143 of file grasp_tester.h.

int grasp_tester::whichQM [private]

Index of the quality measure used for evaluation.

Definition at line 140 of file grasp_tester.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