//go to see the previous grasp and show the corresponding image void DBaseDlg::previousGrasp() { if (mGraspList.empty()) return; if (mCurrentFrame == 0) { mCurrentFrame = mGraspList.size() - 1; } else { mCurrentFrame --; } showGrasp(mCurrentFrame); }
void DBaseDlg::loadGraspButton_clicked(){ PROF_RESET_ALL; PROF_START_TIMER(GET_GRASPS); //get the current hand and check its validity Hand *hand = graspItGUI->getIVmgr()->getWorld()->getCurrentHand(); if (!hand) { DBGA("Load and select a hand before viewing grasps!"); return; } //check the currently loaded model if(!mCurrentLoadedModel){ DBGA("Load model first!"); return; } //clear the previously loaded grasps deleteVectorElements<db_planner::Grasp*, GraspitDBGrasp*>(mGraspList); mGraspList.clear(); mCurrentFrame = 0; //get new grasps from database manager PROF_START_TIMER(GET_GRASPS_CALL); if(!mDBMgr->GetGrasps(*mCurrentLoadedModel,hand->getDBName().toStdString(), &mGraspList)){ DBGA("Load grasps failed"); mGraspList.clear(); return; } PROF_STOP_TIMER(GET_GRASPS_CALL); for(std::vector<db_planner::Grasp*>::iterator it = mGraspList.begin(); it != mGraspList.end(); ){ if( QString((*it)->GetSource().c_str()) == typesComboBox->currentText() || typesComboBox->currentText() == "ALL") ++it; else{ delete (*it); mGraspList.erase(it); } } //set corresponding indices and show the grasp QString numTotal, numCurrent; numTotal.setNum(mGraspList.size()); if(!mGraspList.empty()){ numCurrent.setNum(mCurrentFrame + 1); graspsGroup->setEnabled(TRUE); showGrasp(0); showMarkers(); } else{ numCurrent.setNum(0); graspsGroup->setEnabled(FALSE); } graspIndexLabel->setText(numCurrent + "/" + numTotal); PROF_STOP_TIMER(GET_GRASPS); PROF_PRINT_ALL; }
void DBaseDlg::sortButton_clicked() { if (mGraspList.empty()) return; VisualQualityFunctor func; if (sortBox->currentText()== "Energy") { std::sort(mGraspList.begin(), mGraspList.end(), db_planner::Grasp::CompareEnergy); func.mType = VisualQualityFunctor::ENERGY; } else if (sortBox->currentText()== "Epsilon") { std::sort(mGraspList.begin(), mGraspList.end(), db_planner::Grasp::CompareEpsilon); func.mType = VisualQualityFunctor::EPSILON; } else if (sortBox->currentText()== "Volume") { std::sort(mGraspList.begin(), mGraspList.end(), db_planner::Grasp::CompareVolume); func.mType = VisualQualityFunctor::VOLUME; } else { assert(0); } mCurrentFrame = 0; showGrasp(mCurrentFrame); if (showMarkersBox->isChecked()) { double min = func(mGraspList.front()); double max = func(mGraspList.back()); if (max==min) max=min+1.0; std::vector<db_planner::Grasp*>::iterator it; for (it=mGraspList.begin(); it!=mGraspList.end(); it++) { double r = (func(*it) - min) / (max - min); double g = 1-r; double b = 0.0; GraspPlanningState *state; if(showPreGraspRadioButton->isChecked()) { state = static_cast<GraspitDBGrasp*>(*it)->getPreGraspPlanningState(); } else { state = static_cast<GraspitDBGrasp*>(*it)->getFinalGraspPlanningState(); } state->setIVMarkerColor(r,g,b); } } }
//go to see the next grasp and show the corresponding image void DBaseDlg::nextGrasp() { if (mGraspList.empty()) return; mCurrentFrame ++; if (mCurrentFrame == mGraspList.size()) mCurrentFrame = 0; showGrasp(mCurrentFrame); }
//trigger when the grasp type is changed between pregrasp and final grasp void DBaseDlg::graspTypeChanged(){ showGrasp(mCurrentFrame); showMarkers(); }
//go to see the previous grasp and show the corresponding image void DBaseDlg::previousGrasp() { if (mGraspList.empty()) return; mCurrentFrame --; if (mCurrentFrame < 0) mCurrentFrame = mGraspList.size() - 1; showGrasp(mCurrentFrame); }