void calibration_fingers(int phase) { switch (phase) { case 1: { if(allVisibleObject) { upperPinMarker=markers[1].p; upperPin.init(upperPinMarker, markers.at(8).p, markers.at(11).p, markers.at(12).p ); } } break; case 2: { if(allVisibleObject) { lowerPinMarker=markers[2].p; lowerPin.init(lowerPinMarker, markers.at(8).p, markers.at(11).p, markers.at(12).p ); } } break; case 3: { indexCoords.init(upperPin.getP1(), markers.at(13).p, markers.at(14).p, markers.at(16).p ); thumbCoords.init(lowerPin.getP1(), markers.at(15).p, markers.at(17).p, markers.at(18).p ); } break; } }
void initCalibration() { // Now wind the input points file while the head calibration isn't done while ( true ) { // Here we load the variables needed to keep track of the experiment status readline(inputStream, trialNumber, headCalibration, trialMode, pointMatrix ); //First phase of calibration (equivalent when spacebar is pressed first time ) if ( (headCalibration== 1) && (headCalibrationDone==0 )) { headEyeCoords.init(pointMatrix.col(3),pointMatrix.col(4), pointMatrix.col(0),pointMatrix.col(1),pointMatrix.col(2),interoculardistance ); headCalibrationDone=headCalibration; //cerr << headCalibrationDone << endl; } // Second phase of calibration (equivalent when space bar is pressed second time ) if ( (headCalibration== 2) && (headCalibrationDone==1 )) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), pointMatrix.col(0),pointMatrix.col(1),pointMatrix.col(2),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); headCalibrationDone=headCalibration; } // Third and final phase of calibration ( equivalent when spacebar is pressed third time ) if ((headCalibration==3)) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), pointMatrix.col(0),pointMatrix.col(1),pointMatrix.col(2),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); headCalibrationDone=3; break; // exit the while cycle } // simulates the update of head and eyes positions if ( headCalibration==headCalibrationDone) headEyeCoords.update(pointMatrix.col(0),pointMatrix.col(1),pointMatrix.col(2)); } }
void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'q': case 27: { cleanup(); exit(0); } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisibleHead ) { headEyeCoords.init(markers.at(17).p,markers.at(18).p, markers.at(1).p,markers.at(2).p,markers.at(3).p,interoculardistance ); headCalibrationDone=1; beepOk(); } break; } break; case 13: whichColor=(bool)(rand()%2); break; case 'f': case 'F': { // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { platformIndex=markers.at(16).p; platformThumb=markers.at(15).p; fingerCalibrationDone=1; beepOk(); break; } if ( (fingerCalibrationDone==1) && allVisibleFingers ) { thumbCoords.init(platformThumb, markers.at(11).p, markers.at(12).p, markers.at(13).p); indexCoords.init(platformIndex, markers.at(7).p, markers.at(8).p, markers.at(9).p ); fingerCalibrationDone=3; beepOk(); RoveretoMotorFunctions::homeObjectAsynchronous(3500); break; } } break; case '+': { mirrorAngle+=10; mirrorPlane = Eigen::Hyperplane<double,3>(Vector3d(sin(toRadians(mirrorAngle)),0,cos(toRadians(mirrorAngle))),focalDistance); cout << mirrorAngle << endl; } break; case '-': { mirrorAngle-=10; mirrorPlane = Eigen::Hyperplane<double,3>(Vector3d(sin(toRadians(mirrorAngle)),0,cos(toRadians(mirrorAngle))),focalDistance); cout << mirrorAngle << endl; } break; } }
void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'q': case 27: { cleanup(); exit(0); } break; case '4': alignmentX-=0.5; initProjectionScreen(focalDistance,Affine3d::Identity()); break; case '6': alignmentX+=0.5; initProjectionScreen(focalDistance,Affine3d::Identity()); break; case '2': alignmentY+=0.5; initProjectionScreen(focalDistance,Affine3d::Identity()); break; case '8': alignmentY-=0.5; initProjectionScreen(focalDistance,Affine3d::Identity()); break; case '+': scaleZ+=0.01; break; case '-': scaleZ-=0.01; break; /* case 'a': rotZ+=0.5; break; case 'z': rotZ-=0.5; break; */ case ' ': { if ( headCalibrationDone==0 && allVisibleHead && allVisibleModel ) { headEyeCoords.init(markers[17],markers[18], markers[1],markers[2],markers[3],interoculardistance ); modelCoordinates.init(markers[14],markers[10],markers[19],markers[20]); headCalibrationDone=1; break; } } break; } }
void calibration_head(int phase) { switch (phase) { case 1: { headEyeCoords.init(markers[3].p-Vector3d(70,0,0),markers[3].p, markers[10].p,markers[11].p,markers[12].p,interoculardistance ); } break; case 2: { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[10].p, markers[11].p,markers[12].p,interoculardistance ); } break; } }
void initVariables() { totalTimer.start(); interoculardistance = str2num<double>(parameters.find("IOD")); trial.init(parameters); factors = trial.getNext(); // Initialize the factors in order to start from trial 1 useCircularMask = util::str2num<int>( parameters.find("CircularMask")) == 1 ; circularMaskRadius = util::str2num<int>(parameters.find("CircularMaskRadius")); if (useCircularMask) glEnable(GL_STENCIL_TEST); else glDisable(GL_STENCIL_TEST); fixationDurationInSeconds = util::str2num<double>(parameters.find("AdaptationDurationInSeconds")); // Imposta stimolo e drawer redDotsPlane.setNpoints(util::str2num<int>(parameters.find("NumStimulusPoints"))); redDotsPlane.setDimensions( util::str2num<int>(parameters.find("StimulusEdgeLength")), util::str2num<int>(parameters.find("StimulusEdgeLength")),0.1); redDotsPlane.compute(); stimDrawer.initList(&redDotsPlane,glRed); resetPointStrip(); stimulusDurationInMilliSeconds = util::str2num<double>(parameters.find("StimulusDuration")); initialAdaptationTimeInSeconds = util::str2num<double>(parameters.find("InitialAdaptationTime")); initialAdaptationFlowIncrement = util::str2num<double>(parameters.find("InitialAdaptationFlowIncrement")); stimMotion=SINUSOIDAL_MOTION; trialMode = INITIALADAPTATION; headEyeCoords.init(Vector3d(interoculardistance/2,0,0),Vector3d(interoculardistance/2,0,0), Vector3d(0,0,0),Vector3d(0,10,0),Vector3d(0,0,10),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); }
void initVariables() { interoculardistance = str2num<double>(parameters.find("IOD")); stimulusEmiCycles= atoi(parameters.find("StimulusEmiCycles").c_str()); trial.init(parameters); factors = trial.getNext(); // Initialize the factors in order to start from trial 1 if ( atoi(parameters.find("DrawOccluder").c_str()) ==1 ) { redDotsPlane.setNpoints(500); //XXX controllare densita di distribuzione dei punti redDotsPlane.setDimensions(200,200,0.1); } else { redDotsPlane.setNpoints(75); //XXX controllare densita di distribuzione dei punti redDotsPlane.setDimensions(50,50,0.1); } //redDotsPlane.setSlantTilt( factors["Slant"], (int) factors["Tilt"] ); redDotsPlane.compute(); stimDrawer.setStimulus(&redDotsPlane); stimDrawer.initList(&redDotsPlane); /** Bound check things **/ signsX.push_back(false); signsX.push_back(false); signsY.push_back(false); signsY.push_back(false); headEyeCoords.init(Vector3d(-32.5,0,0),Vector3d(32.5,0,0), Vector3d(0,0,0),Vector3d(0,10,0),Vector3d(0,0,10),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); model.load("../data/objmodels/occluder.obj"); }
/*** GRASP ***/ void calibration_fingers(int phase) { switch (phase) { case 1: { index_marker = markers.at(indexcal).p; thumb_marker = markers.at(thumbcal).p; } case 2: { indexCoords.init(index_marker, markers.at(ind1).p, markers.at(ind2).p, markers.at(ind3).p); thumbCoords.init(thumb_marker, markers.at(thu1).p, markers.at(thu2).p, markers.at(thu3).p); } break; } }
void calibration_fingers(int phase) { switch (phase) { case 1: { platformIndex=markers[1].p; platformThumb=markers[2].p; } break; case 2: { indexCoords.init(platformIndex, markers.at(13).p, markers.at(14).p, markers.at(16).p ); thumbCoords.init(platformThumb, markers.at(15).p, markers.at(17).p, markers.at(18).p ); } break; } }
void recordHeadEyeRelativePositions() { bool allVisible=false; for (int i=0; i<10; i++) { optotrak.updateMarkers(); markers=optotrak.getAllMarkers(); allVisible= isVisible(markers[17].p) && isVisible(markers[18].p) && isVisible(markers[1].p) && isVisible(markers[2].p) && isVisible(markers[3].p) ; cerr << "Move the head such that all markers are visible: Trial num " << i << endl; cin.ignore( std::numeric_limits <std::streamsize> ::max(), '\n' ); cerr << allVisible << endl; cerr << markers[17].p.transpose() << " " << markers[18].p.transpose() << endl; if ( allVisible ) { headEyeCoords.init(markers[17].p,markers[18].p, markers[1].p,markers[2].p,markers[3].p,interoculardistance); break; } } }
void initVariables() { totalTimer.start(); interoculardistance = str2num<double>(parameters.find("IOD")); trial.init(parameters); factors = trial.getNext(); // Initialize the factors in order to start from trial 1 // Imposta stimolo e drawer redDotsPlane.setNpoints(75); redDotsPlane.setDimensions(50,50,0.1); redDotsPlane.compute(); stimDrawer.initList(&redDotsPlane,glRed); // Imposta striscia del fixation e drawer stripPlane.setNpoints(N_STRIP_POINTS); stripPlane.setDimensions(STRIP_WIDTH,STRIP_HEIGHT,0.01); stripPlane.compute(); stripDrawer.initList(&stripPlane,glRed); stimMotion=SINUSOIDAL_MOTION; headEyeCoords.init(Vector3d(-32.5,0,0),Vector3d(32.5,0,0), Vector3d(0,0,0),Vector3d(0,10,0),Vector3d(0,0,10),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); }
// Funzione di callback per gestire pressioni dei tasti void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'x': // Facendo cosi si cancella lo stimolo durante il movimento (SINCRONO) del monitor. // Si imposta il isStimulusDrawn a FALSE e si riaggiorna la schermata con una drawGLScene() // infine si muove il monitor, la chiamata blocca il programma per x secondi, si // simula lo spostamento dello schermo di proiezione ed infine si reimposta isStimulusDrawn a TRUE // cosi' la prossima chiamata di drawStimulus() lo disegna correttamente a schermo. Provare per credere... //factors = trial.getNext(); trial.next(); isStimulusDrawn=false; drawGLScene(); initProjectionScreen(trial.getCurrent()["AbsDepth"]); isStimulusDrawn=true; break; case 'i': visibleInfo=!visibleInfo; break; case 'm': interoculardistance += 0.5; break; case 'n': interoculardistance -= 0.5; break; case '+': { // Il trucco per avanzare alla modalita' trial successiva: incrementi di uno e poi tieni il resto della // divisione per due, in questo caso ad esempio sara' sempre: // 0,1,0,1,0,1 // se metti il resto della divisione per 3 invece la variabile trialMode sar' // 0,1,2,0,1,2 // ogni ciclo della variabile trialMode normalmente e' un trial (1) // puoi anche definire una funzione void advanceTrial() che si occupa di andare al trial successivo, // deve contenere una chiamata alla BalanceFactor::getNext() cosi' passi alla nuova lista di fattori // Ad esempio trialMode++; trialMode=trialMode%3; } break; case 't': { if (trial.isEmpty()) exit(0); trial.next(); break; } case 'Q': case 'q': case 27: //corrisponde al tasto ESC { // Ricorda quando chiami una funzione exit() di chiamare prima cleanup cosi // spegni l'Optotrak ed i markers (altrimenti loro restano accesi e li rovini) cleanup(); exit(0); } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisiblePatch ) { headEyeCoords.init(markers[1].p-Vector3d(230,0,0),markers[1].p, markers[5].p,markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=1; beepOk(0); break; } // Second calibration, you must look a fixed fixation point if ( headCalibrationDone==1 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=2; break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[1].p, markers[2].p,markers[3].p,interoculardistance ); headCalibrationDone=3; visibleInfo=false; } } break; case '5': { if(dz/2>10) zedge -= .25; else zedge = zedge; } break; case '8': { zedge += .25; } break; case '4': { xedge -= .25; } break; case '6': { xedge += .25; } break; case 'a': { theta -= M_PI/2.0; } break; case 's': { theta += M_PI/2.0; } break; case '0': { advanceTrial(); } break; } }
// Funzione di callback per gestire pressioni dei tasti void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'x': // Facendo cosi si cancella lo stimolo durante il movimento (SINCRONO) del monitor. // Si imposta il isStimulusDrawn a FALSE e si riaggiorna la schermata con una drawGLScene() // infine si muove il monitor, la chiamata blocca il programma per x secondi, si // simula lo spostamento dello schermo di proiezione ed infine si reimposta isStimulusDrawn a TRUE // cosi' la prossima chiamata di drawStimulus() lo disegna correttamente a schermo. Provare per credere... factors = trial.getNext(); isStimulusDrawn=false; drawGLScene(); initProjectionScreen(factors["AbsDepth"]); isStimulusDrawn=true; break; case 'i': visibleInfo=!visibleInfo; break; case 'm': interoculardistance += 0.5; break; case 'n': interoculardistance -= 0.5; break; case 'd': visibleFingers=!visibleFingers; break; case '+': { // Il trucco per avanzare alla modalita' trial successiva: incrementi di uno e poi tieni il resto della // divisione per due, in questo caso ad esempio sara' sempre: // 0,1,0,1,0,1 // se metti il resto della divisione per 3 invece la variabile trialMode sar' // 0,1,2,0,1,2 // ogni ciclo della variabile trialMode normalmente e' un trial (1) // puoi anche definire una funzione void advanceTrial() che si occupa di andare al trial successivo, // deve contenere una chiamata alla BalanceFactor::getNext() cosi' passi alla nuova lista di fattori // Ad esempio // trialMode++; // trialMode=trialMode%3; } break; case 'Q': case 'q': case 27: //corrisponde al tasto ESC { // Ricorda quando chiami una funzione exit() di chiamare prima cleanup cosi // spegni l'Optotrak ed i markers (altrimenti loro restano accesi e li rovini) cleanup(); exit(0); } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisiblePatch ) { headEyeCoords.init(markers[1].p-Vector3d(230,0,0),markers[1].p, markers[5].p,markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=1; beepOk(0); break; } // Second calibration, you must look a fixed fixation point if ( headCalibrationDone==1 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=2; break; } } break; case 'f': case 'F': { // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { //platformFingers=markers[1].p; platformIndex=markers[1].p; platformThumb=markers[2].p; fingerCalibrationDone=1; beepOk(0); break; } if ( (fingerCalibrationDone==1) && allVisibleFingers ) { thumbCoords.init(platformThumb, markers.at(15).p, markers.at(17).p, markers.at(18).p); indexCoords.init(platformIndex, markers.at(13).p, markers.at(14).p, markers.at(16).p ); fingerCalibrationDone=2; beepOk(0); break; } if ( fingerCalibrationDone==2 && allVisibleFingers ) { physicalRigidBodyTip = index; fingerCalibrationDone=3; fingerDistance = (thumb-index).norm(); visibleInfo=!visibleInfo; initTrial(); break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=3; } } break; case '2': { } break; case '8': { } break; case '4': { } break; case '6': { } break; // In genere a me piace attaccare al tasto p una funzione che stampi // le tue variabili di interesse su standard output ad esempio la lista dei fattori attuali con nome case 'p': { for (map<string,double>::iterator iter = factors.begin(); iter!=factors.end(); ++iter ) { cout << iter->first << " " << iter->second << endl; } } break; } }
/** * @brief keyPressEvent * @param key * @param x * @param y */ void keyPressEvent(unsigned char key, int x, int y) { switch (key) { //Quit program case 'q': case 27: { exit(0); break; } case 'i': { infoDraw=!infoDraw; break; } case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisibleHead && trialMode==PRECALIBRATION_MODE) { headEyeCoords.init(markers.at(17).p,markers.at(18).p, markers.at(1).p,markers.at(2).p,markers.at(3).p,interocularDistance ); headCalibrationDone=1; beepOk(); break; } // Second calibration the user must be in the red circle if ( headCalibrationDone==1 && allVisiblePatch && trialMode==PRECALIBRATION_MODE) { headEyeCoords.init(headEyeCoords.getLeftEye(),headEyeCoords.getRightEye(), markers.at(1).p,markers.at(2).p,markers.at(3).p,interocularDistance ); headCalibrationDone=2; beepOk(); break; } break; } case 13: { // Third calibration the user must look toward the green/red circle and be in the correct z position, then the experiment starts if ( readyToStart && allVisiblePatch ) { headEyeCoords.init(headEyeCoords.getLeftEye(),headEyeCoords.getRightEye(), markers.at(1).p,markers.at(2).p,markers.at(3).p,interocularDistance ); eyeCalibration = headEyeCoords.getRightEye(); headCalibrationDone=3; trialMode=BLACK_MODE; beepOk(); trialTimer.start(); break; } } case '4': { if (trialMode==RESPONSE_MODE) { advanceTrial(4); } break; } case '6': { if (trialMode==RESPONSE_MODE) { advanceTrial(6); } break; } } }
void handleKeypress(unsigned char key, int x, int y) { switch (key) { case 'i': visibleInfo=!visibleInfo; break; case 'm': interoculardistance += 0.5; break; case '.': { trial[round].next(); initTrial(); } break; case 'n': interoculardistance -= 0.5; break; case 'Q': case 'q': case 27: //corrisponde al tasto ESC { cleanup(); exit(0); } break; case 'd': { fingersShown = !fingersShown; } break; case 'f': case 'F': { if(calib == 1){ // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { //platformFingers=markers[1].p; platformIndex=markers[1].p; platformThumb=markers[2].p; //centercal = markers[4].p; fingerCalibrationDone=1; beepOk(0); break; } if ( (fingerCalibrationDone==1) && allVisibleFingers ) { indexCoords.init(platformIndex, markers.at(13).p, markers.at(14).p, markers.at(16).p ); thumbCoords.init(platformThumb, markers.at(15).p, markers.at(17).p, markers.at(18).p ); fingerCalibrationDone=2; trial[round].next(); beepOk(0); break; } if ( fingerCalibrationDone==2 && allVisibleFingers ) { beepOk(0); fingerCalibrationDone=3; platformPos = markers[4].p.transpose(); visibleInfo=!visibleInfo; initTrial(); break; } }else { beepOk(0); fingerCalibrationDone=3; platformPos = markers[4].p.transpose(); visibleInfo=!visibleInfo; trial[round].next(); initTrial(); break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=3; visibleInfo=false; } } break; case ' ': { advanceTrial(); } break; case '5': { theta -= M_PI/2.0; } break; case '8': { theta += M_PI/2.0; } break; case '0': { half = !half; } } }
void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'o': orthographicMode=!orthographicMode; cam.setOrthoGraphicProjection(orthographicMode); break; case 'z': zOnFocalPlane=!zOnFocalPlane; break; case 'p': passiveMode=!passiveMode; break; case 'q': case 27: { cleanup(); exit(0); } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisibleHead ) { headEyeCoords.init(markers[17],markers[18], markers[1],markers[2],markers[3],interoculardistance ); headCalibrationDone=1; break; } // Second calibration, you must look a fixed fixation point if ( headCalibrationDone==1 ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[1], markers[2],markers[3],interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); headCalibrationDone=2; break; } if ( headCalibrationDone==2 ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[1], markers[2],markers[3],interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[1], markers[2],markers[3],interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); headCalibrationDone=3; } } break; case '2': { probeAngle=270; keyPressed(); } break; case '8': { probeAngle=90; keyPressed(); } break; case '4': { probeAngle=180; keyPressed(); } break; case '6': { probeAngle=0; keyPressed(); } break; } }
// Funzione di callback per gestire pressioni dei tasti void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'x': // Facendo cosi si cancella lo stimolo durante il movimento (SINCRONO) del monitor. // Si imposta il isStimulusDrawn a FALSE e si riaggiorna la schermata con una drawGLScene() // infine si muove il monitor, la chiamata blocca il programma per x secondi, si // simula lo spostamento dello schermo di proiezione ed infine si reimposta isStimulusDrawn a TRUE // cosi' la prossima chiamata di drawStimulus() lo disegna correttamente a schermo. Provare per credere... //factors = trial.getNext(); // trial.next(); drawGLScene(); // initProjectionScreen(trial.getCurrent()["AbsDepth"]); break; case 'i': visibleInfo=!visibleInfo; break; case 'm': interoculardistance += 0.5; break; case 'n': interoculardistance -= 0.5; break; case '+': { // Il trucco per avanzare alla modalita' trial successiva: incrementi di uno e poi tieni il resto della // divisione per due, in questo caso ad esempio sara' sempre: // 0,1,0,1,0,1 // se metti il resto della divisione per 3 invece la variabile trialMode sar' // 0,1,2,0,1,2 // ogni ciclo della variabile trialMode normalmente e' un trial (1) // puoi anche definire una funzione void advanceTrial() che si occupa di andare al trial successivo, // deve contenere una chiamata alla BalanceFactor::getNext() cosi' passi alla nuova lista di fattori // Ad esempio trialMode++; trialMode=trialMode%4; } break; case 'Q': case 'q': case 27: //corrisponde al tasto ESC { // Ricorda quando chiami una funzione exit() di chiamare prima cleanup cosi // spegni l'Optotrak ed i markers (altrimenti loro restano accesi e li rovini) cleanup(); exit(0); } break; case 'd': { fingersShown = !fingersShown; } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisiblePatch ) { headEyeCoords.init(markers[1].p-Vector3d(230,0,0),markers[1].p, markers[5].p,markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=1; beepOk(0); break; } // Second calibration, you must look a fixed fixation point if ( headCalibrationDone==1 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=2; break; } } break; case 'f': case 'F': { // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { //platformFingers=markers[1].p; platformIndex=markers[1].p; platformThumb=markers[2].p; //centercal = markers[4].p; fingerCalibrationDone=1; beepOk(0); break; } if ( (fingerCalibrationDone==1) && allVisibleFingers ) { indexCoords.init(platformIndex, markers.at(13).p, markers.at(14).p, markers.at(16).p ); thumbCoords.init(platformThumb, markers.at(15).p, markers.at(17).p, markers.at(18).p ); fingerCalibrationDone=2; beepOk(0); break; } if ( fingerCalibrationDone==2 && allVisibleFingers ) { beepOk(0); fingerCalibrationDone=3; visibleInfo=!visibleInfo; trial.next(); initTrial(); break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=3; visibleInfo=false; } } break; case '5': { theta += 1; } break; case '8': { theta -= 1; } break; case 's': { advanceTrial(); } break; case '0': { training=!training; } break; case 'c': { pulsingColors=!pulsingColors; } break; case 'l': //L { //hapticLarger=!hapticLarger; } } }
// Funzione di callback per gestire pressioni dei tasti void handleKeypress(unsigned char key, int x, int y) { switch (key) { case 'x': { } break; case 'i': { visibleInfo=!visibleInfo; } break; case 't': { training = !training; } break; case '*': { } break; case 'q': { } break; case 27: //ESC { exit(0); } break; case 'f': { if (!objectsForward) { beepOk(2); objectsForward = true; RoveretoMotorFunctions::moveObjectAbsolute(mountDisplayPosn, motorHomePosn, 3000); break; } if ( objectsForward && (startPosCalibration==0) && (fingerCalibrationDone==0) && allVisiblePlatform) { platformIndex=markers[16].p; platformThumb=markers[15].p; fingerCalibrationDone=1; beepOk(2); break; } if ( (startPosCalibration==0) && (fingerCalibrationDone==1) && allVisibleFingers ) { indexCoords.init(platformIndex, markers.at(19).p, markers.at(23).p, markers.at(24).p ); thumbCoords.init(platformThumb, markers.at(20).p, markers.at(21).p, markers.at(22).p ); fingerCalibrationDone=2; beepOk(2); break; } if ( (startPosCalibration==0) && (fingerCalibrationDone==2) && allVisibleFingers) { startPos_front = index.z()-20; startPos_right = index.x()+20; startPos_top = index.y()+20; startPos_rear = thumb.z()+20; startPos_left = thumb.x()-20; startPos_bottom = thumb.y()-20; startPosCalibration=1; beepOk(2); break; } if ( (startPosCalibration==1) && (fingerCalibrationDone==2)) { startPosCalibration = 2; beepOk(2); RoveretoMotorFunctions::moveObjectAbsolute(showTopMidBoard,motorHomePosn,4000); break; } if ( (startPosCalibration==2) && (fingerCalibrationDone==2) ) { objL_X = markers[10].p.x(); objL_Y = markers[10].p.y(); objL_Z = markers[10].p.z(); startPosCalibration=3; beepOk(2); break; } if ( (startPosCalibration==3) && (fingerCalibrationDone==2) ) { objR_X = markers[10].p.x(); objR_Y = markers[10].p.y(); objR_Z = markers[10].p.z(); startPosCalibration=4; beepOk(2); break; } if ( (startPosCalibration==4) && (fingerCalibrationDone==2) && allVisibleFingers) { fingerCalibrationDone=3; visibleInfo=false; training=false; factors = trial.getNext(); initTrial(); break; } } break; case 's': { advanceTrial(); } break; case '0': { } break; case 'e': { cout << "Hand at start: " << handAtStart << endl; cout << "Started: " << started << endl; cout << "Reached Object: " << reachedObject << endl; } break; case 'j': { cout << "Distance to Object: sqrt(" << x_dist << "^2 + " << y_dist << "^2 + " << z_dist << "^2) = " << grip_distanceToTarget << endl; cout << "Start Pos Corner: " << startPos_right << "\t" << startPos_top << "\t" << startPos_front << endl; } break; case '5': //down { } break; case '8': //up { } break; case '4': //left { } break; case '6': //right { } break; case '1': //left 2 { } break; case '3': //right 2 { } break; } }