00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "gloveCalibrationDlg.h"
00027
00028 #include <QFileDialog>
00029
00030 #include "world.h"
00031 #include "graspitGUI.h"
00032 #include "ivmgr.h"
00033 #include "robot.h"
00034 #include "gloveInterface.h"
00035
00036 void GloveCalibrationDlg::init()
00037 {
00038
00039
00040 World *w=graspItGUI->getIVmgr()->getWorld();
00041 mInterface = w->getCurrentHand()->getGloveInterface();
00042
00043 mInterface->saveRobotPose();
00044
00045 calibrationTypeBox->insertItem( "Fist" );
00046 calibrationTypeBox->insertItem( "Simple thumb" );
00047 calibrationTypeBox->insertItem( "Complex thumb" );
00048 calibrationTypeBox->insertItem( "Abd. - Add." );
00049 calibrationTypeBox->insertItem( "Mean Pose" );
00050 calibrationTypeBox->setCurrentItem(2);
00051 mInterface->initCalibration( GloveInterface::COMPLEX_THUMB );
00052
00053 poseDistanceBox->insertItem("0");
00054 poseDistanceBox->insertItem("17");
00055 poseDistanceBox->insertItem("61");
00056 poseDistanceBox->insertItem("82");
00057 poseDistanceBox->setCurrentItem(0);
00058
00059 update();
00060 }
00061
00062 void GloveCalibrationDlg::prevPose()
00063 {
00064 mInterface->nextPose(-1);
00065 mInterface->showCurrentPose();
00066 update();
00067 }
00068
00069
00070 void GloveCalibrationDlg::nextPose()
00071 {
00072 mInterface->nextPose( 1);
00073 mInterface->showCurrentPose();
00074 update();
00075 }
00076
00077
00078 void GloveCalibrationDlg::record()
00079 {
00080 int d = poseDistanceBox->currentText().toInt();
00081 mInterface->recordPoseFromGlove(d);
00082 mInterface->showCurrentPose();
00083 update();
00084 }
00085
00086 void GloveCalibrationDlg::update()
00087 {
00088 if ( mInterface->poseSet() ){
00089 textLabel2->setText("Pose recorded");
00090
00091 } else {
00092 textLabel2->setText("No values recorded");
00093 }
00094
00095 if ( mInterface->readyToCalibrate() ) {
00096 calibrateButton->setEnabled(true);
00097 } else
00098 calibrateButton->setEnabled(false);
00099
00100 numberPosesLabel->setNum( mInterface->getNumPoses() );
00101 }
00102
00103 void GloveCalibrationDlg::calibrate()
00104 {
00105 mInterface->performCalibration();
00106 update();
00107 }
00108
00109
00110 void GloveCalibrationDlg::save()
00111 {
00112 QString fn( QFileDialog::getSaveFileName( this, QString(), QString(getenv("GRASPIT"))+QString("/models/CyberGlove"),
00113 "Glove Pose Files (*.txt)") );
00114 if ( !fn.isEmpty() ) {
00115 if (fn.section('.',1).isEmpty())
00116 fn.append(".txt");
00117 mInterface->saveCalibration( fn.latin1() );
00118 }
00119 }
00120
00121
00122 void GloveCalibrationDlg::done()
00123 {
00124
00125 QDialog::accept();
00126 }
00127
00128
00129 void GloveCalibrationDlg::savePoses()
00130 {
00131 QString fn( QFileDialog::getSaveFileName(this, QString(), QString(getenv("GRASPIT"))+QString("/models/CyberGlove"),
00132 "Glove Pose Files (*.pos)" ) );
00133 if ( !fn.isEmpty() ) {
00134 if (fn.section('.',1).isEmpty())
00135 fn.append(".pos");
00136 mInterface->saveCalibrationPoses( fn.latin1() );
00137 }
00138 }
00139
00140
00141 void GloveCalibrationDlg::loadPoses()
00142 {
00143 QString fn( QFileDialog::getOpenFileName(this, QString(), QString(getenv("GRASPIT"))+QString("/models/CyberGlove"),
00144 "Glove Pose Files (*.pos)") );
00145 if ( !fn.isEmpty() ) {
00146 mInterface->loadCalibrationPoses( fn.latin1() );
00147 }
00148 update();
00149 }
00150
00151 void GloveCalibrationDlg::loadCalibration()
00152 {
00153 QString fn( QFileDialog::getOpenFileName(this, QString(), QString(getenv("GRASPIT"))+QString("/models/CyberGlove"),
00154 "Glove Pose Files (*.txt)") );
00155 if ( !fn.isEmpty() ) {
00156 mInterface->loadCalibration( fn.latin1() );
00157 }
00158 }
00159
00160
00161 void GloveCalibrationDlg::initCalibration()
00162 {
00163 switch( calibrationTypeBox->currentItem() ) {
00164 case 0:
00165 mInterface->initCalibration( GloveInterface::FIST );
00166 break;
00167 case 1:
00168 mInterface->initCalibration( GloveInterface::SIMPLE_THUMB );
00169 break;
00170 case 2:
00171 mInterface->initCalibration( GloveInterface::COMPLEX_THUMB );
00172 break;
00173 case 3:
00174 mInterface->initCalibration( GloveInterface::ABD_ADD );
00175 break;
00176 case 4:
00177 mInterface->initCalibration( GloveInterface::MEAN_POSE );
00178 break;
00179 default:
00180 break;
00181 }
00182 }
00183
00184
00185 void GloveCalibrationDlg::clearPoses()
00186 {
00187 mInterface->clearPoses();
00188 update();
00189 }
00190
00191
00192 void GloveCalibrationDlg::startGlove()
00193 {
00194 mInterface->startGlove();
00195 }