void drawThreeRods(double deltaz) { glLoadIdentity(); glTranslated(0.0,0,trial.getCurrent()["AbsDepth"]); glRotated(trial.getCurrent()["Orientation"]*(str2num<double>(parameters.find("ThetaSign")))+theta,0,1,0); // Front rod glPushMatrix(); glTranslated(0, 0, deltaz/2); stimDrawer[0].draw(); glPopMatrix(); // Rear Left rod glPushMatrix(); glTranslated(-(trial.getCurrent()["RelDepthObj"]/2), 0, -deltaz/2); stimDrawer[1].draw(); glPopMatrix(); // Rear right rod glPushMatrix(); glTranslated((trial.getCurrent()["RelDepthObj"]/2), 0, -deltaz/2); stimDrawer[2].draw(); glPopMatrix(); }
/** * @brief advanceTrial * @param response */ void advanceTrial(int response) { responseFile << parameters.find("SubjectName") << "\t" << trialNumber << "\t" << focalDistance << "\t" << response << "\t" << trialTimer.getElapsedTimeInMilliSec() << "\t" << trial.getCurrent().at("ZWidth") << "\t" << trial.getCurrent().at("Slant") << "\t" << trial.getCurrent().at("Tilt") << "\t" << trial.getCurrent().at("StimulusAnchored") << " " << endl; if ( trial.isEmpty() ) { exit(0); } trial.next(); updateStimulus(); beepOk(); trialMode=BLACK_MODE; trialNumber++; trialTimer.start(); frame=0.0; }
void initVariables() { cam.setOrthoGraphicProjection((bool)str2num<int>(parameters.find("OrthographicMode"))); drawInfo = (bool)util::str2num<int>(parameters.find("DrawInfo")); //cam.setOrthoGraphicProjection(orthoMode); cerr << "COMPUTED IOD=" << interoculardistance << endl; trial.init(parameters); stimulusTime=util::str2num<double>(parameters.find("StimulusTime")); trialTimer.start(); trial.next(); interoculardistance = str2num<double>(parameters.find("IOD"))*trial.getCurrent().at("IODFactor"); int textureResolution = util::str2num<int>(parameters.find("TextureResolution")); int maxTextureResolutionZ = (int) std::ceil(textureResolution*util::str2num<double>(parameters.find("MaxCurvatureZ"))); // allocate the texture memory if (parameters.find("UsePolkaDots")=="1") { surface.resize(textureResolution,textureResolution, maxTextureResolutionZ); surface.initializeSurfaceShaders(VolumetricSurfaceIntersection::SurfaceParabolicCylinder); } updateStimulus(trial.getCurrent().at("CurvatureZ")); CurvatureZ=0.0; }
void drawStimulus() { if (fingerCalibrationDone==3) { glLoadIdentity(); // this fixes bottom at -40. it will break if values are changed, evces 121813. double posStimTopShifted = abs(40 - (trial.getCurrent()["ObjHeight"] - 10)); // here I lower it by another 15 mm to increase motor leeway, evces 010714. posStimTopShifted = posStimTopShifted-15; if(isStimulusDrawn) { // ###### draw rotated stimulus (adjusted) ###### glTranslated(0.0,posStimTopShifted,trial.getCurrent()["AbsDepth"]); //evces 121813 glRotated(theta, 1,0,0); if( !allVisibleFingers) drawNoFingers(); if(fingersShown) drawFingers(); if( timer.getElapsedTimeInMilliSec() <= str2num<double>(parameters.find("RodVisibleTime")) ) drawTrial(trial.getCurrent()["ObjHeight"]); } if(!training && handAtStart && started) // && (timer.getElapsedTimeInMilliSec() > 2000)) advanceTrial(); } }
void advanceTrial() { double timeElapsed = timer.getElapsedTimeInMilliSec(); responseFile.precision(3); responseFile << parameters.find("SubjectName") << "\t" << interoculardistance << "\t" << trialNumber << "\t" << trial.getCurrent()["AbsDepth"] <<"\t" << trial.getCurrent()["ObjHeight"] <<"\t" << timer.getElapsedTimeInMilliSec() << "\t" << trial.getCurrent()["HapticFB"] << "\t" << randCond << "\t" << randIncrement << "\t" << endl; trialFile.close(); trialNumber++; if( !trial.isEmpty() ) { trial.next(); initTrial(); } else { exit(0); } }
void drawStimulus() { if ( isStimulusDrawn ) { glLoadIdentity(); // ###### draw rotated stimulus (adjusted) ###### glTranslated(0.0,0,trial.getCurrent()["AbsDepth"]); // Front rod glPushMatrix(); glTranslated(0, 0, (trial.getCurrent()["RelDepthObj"]/2)+dz/2); stimDrawer[0].draw(); glPopMatrix(); // Front Left rod on focal plane glPushMatrix(); glTranslated(-(trial.getCurrent()["RelDepthObj"]/2)+dx, -15, dz/2); stimDrawer[1].draw(); glPopMatrix(); // Rear right rod shifted 2 cm behind the focal plane glPushMatrix(); glTranslated( (trial.getCurrent()["RelDepthObj"]/2) , 15, - dz/2 ); stimDrawer[2].draw(); glPopMatrix(); glLoadIdentity(); } }
void initTrial() { // initializing all variables frameN=0; started = false; handAtStart=true; reachedObject = false; fingersOccluded = 0; num_lost_frames = 0; isStimulusDrawn=false; stimPosn = trial.getCurrent()["StimPosn"]; cout << "initTrial: " + trialNumber << endl; cout << "initTrial: " + stimPosn << endl; // roll on drawGLScene(); // move the screen initProjectionScreen(trial.getCurrent()["AbsDepth"]); //evces 031414 if (!debug_no_motion) { if(trialNumber==0){ Vector3d pos1(0,-35,trial.getCurrent()["AbsDepth"]-25); moveObjectAbsolute(pos1, centercal, 7500); } } string trialFileName = "C:/Users/visionlab/Google Drive/DATA/Evan-haptic/spatial2/" + parameters.find("SubjectName") + "/" + parameters.find("SubjectName") + "trial_" + stringify<double>(trialNumber) + "_" + stringify<double>(attempt) + ".txt"; trialFile.open(trialFileName.c_str()); trialFile << fixed << "subjName\ttrialN\ttime\tframeN\tindexXYZraw\tthumbXYZraw\tfingersOccluded\tattempt\treachedObject\tnum_lost_frames" << endl; isStimulusDrawn=true; beepOk(0); timer.start(); }
void advanceTrial() { beepOk(0); double timeElapsed = timer.getElapsedTimeInMilliSec(); responseFile.precision(3); responseFile << fixed << parameters.find("SubjectName") << "\t" << (eyeLeft-eyeRight).norm() << "\t" << trialNumber << "\t" << trial.getCurrent()["AbsDepth"] << "\t" << trial.getCurrent()["RelDepthObj"] << "\t" << xedge << "\t" << xedge + jitter << "\t" << zedge << "\t" << zedge + (jitter/2) << "\t" << jitter << "\t" << jitterX << "\t" << theta << "\t" << trial.getCurrent()["Orientation"] << "\t" << timeElapsed << endl; trialNumber++; if(trial.getRemainingTrials() != 0) initTrial(); else { cleanup(); // shut down Optotrak exit(0); } }
void drawCylinder() { glLoadIdentity(); glPushMatrix(); glTranslated(0.0,0,trial.getCurrent()["AbsDepth"]); glRotated(trial.getCurrent()["Orientation"]*(str2num<double>(parameters.find("ThetaSign")))+theta,1,1,1); stimDrawer[4].draw(); glPopMatrix(); glEnd(); }
/** * @brief advanceTrial: This function to the next trial */ void advanceTrial() { fingersTimer.start(); // Here we change trial mode if (trialMode == HANDONSTARTMODE ) { // Wait to show the stimulus that the fingers points are projected in the screen trialMode = STIMULUSMODE; } else // trialMode == STIMULUSMODE { trialMode = HANDONSTARTMODE; paintGL(); beepTrial(); double oldDistance = factors.getCurrent().at("Distances"); // Reinsert the trial if too much occluded frames double maxInvisibleFramesPercent = util::str2num<double>(parameters.find("MaxPercentOccludedFrames"))/100.0; if ( (invisibleIndexFrames / ((double)drawingTrialFrame) > maxInvisibleFramesPercent ) || (invisibleThumbFrames / ((double)drawingTrialFrame) > maxInvisibleFramesPercent )|| (invisibleWristFrames / ((double)drawingTrialFrame) > maxInvisibleFramesPercent ) ) { map<string,double> currentFactorsList = factors.getCurrent(); beepBad(); cerr << "Reinserted current trial (InvIndex,InvThumb,drawingTrialFrame,totTrialFrame)" << invisibleIndexFrames << " " << invisibleThumbFrames << " " << drawingTrialFrame << " " << trialFrame << endl; factors.reinsert(currentFactorsList); } if (factors.isEmpty()) { beepLong(); beepLong(); beepLong(); plato_stop(); exit(0); } invisibleIndexFrames = invisibleThumbFrames = invisibleWristFrames = trialFrame = drawingTrialFrame = 0; totalTrialNumber++; factors.next(); if (oldDistance == factors.getCurrent().at("Distances")) { Timer sleepTimer; sleepTimer.sleep(1000); } double marker5z = markers.at(5).p.z(); generateSphereStimulus( factors.getCurrent().at("StimulusRadius") ); initProjectionScreen(factors.getCurrent().at("Distances")); moveStimulusObject(visualStimCenter,3500); } }
void advanceTrial() { double timeElapsed = timer.getElapsedTimeInMilliSec(); responseFile.precision(3); responseFile << parameters.find("SubjectName") << "\t" << //interoculardistance << "\t" << trialNumber << "\t" << stimPosn << "\t" << trial.getCurrent()["RodVisibleTime"] << "\t" << trial.getCurrent()["AbsDepth"] <<"\t" << //"50" << "\t" <<//trial.getCurrent()["ObjHeight"] <<"\t" << timer.getElapsedTimeInMilliSec() << "\t" << //trial.getCurrent()["HapticFB"] << "\t" << //randCond << "\t" << //randIncrement << "\t" << stimCond << "\t" << BG_WHITE << "\t" << endl; trialFile.close(); double percent_occluded_frames = num_lost_frames/TGA_frame; bool not_enough_frames = percent_occluded_frames > 0.20; cout << num_lost_frames << "_" << frameN << "_" << percent_occluded_frames << endl; int overwrite = 0; if (training || !reachedObject || not_enough_frames ) { cout << training << "_" << !reachedObject << "_" << not_enough_frames << endl; map<std::string,double> currentFactorsList = trial.getCurrent(); trial.reinsert(currentFactorsList); beepOk(1); overwrite = 1; } if( !trial.isEmpty() ) { if (!overwrite) trialNumber++; cout << trialNumber << endl; factors = trial.getNext(); initTrial(); } else { exit(0); } }
void drawSquare() { glLoadIdentity(); glTranslated(0.0,0,trial.getCurrent()["AbsDepth"]); glRotated(trial.getCurrent()["Orientation"]*(str2num<double>(parameters.find("ThetaSign")))+theta,1,1,0); edge = str2num<double>(parameters.find("SquareSize")) + jitterX; glColor3fv(glRed); glBegin(GL_LINE_LOOP); glVertex3d(edge,edge,0.0); glVertex3d(edge,-edge,0.0); glVertex3d(-edge,-edge,0.0); glVertex3d(-edge,edge,0.0); glEnd(); }
void drawSurfaces() { glLoadIdentity(); glTranslated(0.0,0,trial.getCurrent()["AbsDepth"]); glRotated(trial.getCurrent()["Orientation"]*(str2num<double>(parameters.find("ThetaSign")))+theta,1,1,0); glPushMatrix(); glTranslated(0, 0, -sepz/2); stimDrawer[6].draw(); glPopMatrix(); glPushMatrix(); glTranslated(0, 0, sepz/2); stimDrawer[7].draw(); glPopMatrix(); }
/** * @brief idle */ void idle() { // Update markers optotrak.updateMarkers(); markers = optotrak.getAllMarkers(); allVisiblePatch = isVisible(markers[1].p) && isVisible(markers[2].p) && isVisible(markers[3].p); allVisibleHead = isVisible(markers[17].p) && isVisible(markers[18].p) && allVisiblePatch; headEyeCoords.update(markers.at(1).p,markers.at(2).p,markers.at(3).p); if ( trialTimer.getElapsedTimeInMilliSec() >= parameters.get("WaitTime") && trialMode==BLACK_MODE ) { frame=0.0; trialMode++; trialTimer.start(); } if ( trialTimer.getElapsedTimeInMilliSec() >= parameters.get("ProbeTime") && trialMode==PROBE_MODE ) { frame=0.0; trialMode++; trialTimer.start(); } if ( trialTimer.getElapsedTimeInMilliSec() >= parameters.get("StimulusTime") && trialMode==STIMULUS_MODE ) { Beep(660,660); frame=0.0; trialMode=RESPONSE_MODE; trialTimer.start(); } markersFile << fixed << trialNumber << " " << headCalibrationDone << " " << trialMode << " " ; markersFile << setprecision(3) << ( isVisible(markers[1].p) ? markers[1].p.transpose() : junk ) << " " << ( isVisible(markers[2].p) ? markers[2].p.transpose() : junk ) << " " << ( isVisible(markers[3].p) ? markers[3].p.transpose() : junk ) << " " << ( isVisible(markers[17].p) ? markers[17].p.transpose() : junk ) << " " << ( isVisible(markers[18].p) ? markers[18].p.transpose() : junk ) << " " << ( isVisible(markers[18].p) ? markers[18].p.transpose() : junk ) << " " << ( isVisible(headEyeCoords.getLeftEye()) ? headEyeCoords.getLeftEye().transpose() : junk ) << " " << ( isVisible(headEyeCoords.getRightEye()) ? headEyeCoords.getRightEye().transpose() : junk ) << " " ; markersFile << setprecision(1) << trial.getCurrent().at("ZWidth") << " " << trial.getCurrent().at("Slant") << " " << trial.getCurrent().at("Tilt") << " " << trial.getCurrent().at("StimulusAnchored") << " " << endl; }
void drawStimulus() { if(fingerCalibrationDone==3) if(!allVisibleFingers) drawNoFingers(); if ( isStimulusDrawn && !isHandHome && !iGrasped ) { glLoadIdentity(); glTranslated(0, 0, trial.getCurrent()["AbsDepth"]); // Left rear glPushMatrix(); glTranslated(-objwidth/2, 0, -objdepth/2); stimDrawer[0].draw(); glPopMatrix(); // Right rear rod glPushMatrix(); glTranslated(objwidth/2, 0, -objdepth/2); stimDrawer[1].draw(); glPopMatrix(); // Front rod glPushMatrix(); glTranslated(0, 0, objdepth/2); stimDrawer[2].draw(); glPopMatrix(); } if (iGrasped && isHandHome) advanceTrial(); }
int CCONV PositionChangeHandlerServoRocking(CPhidgetAdvancedServoHandle ADVSERVO, void *usrptr, int Index, double Value) { // first we check that the static object has reached its final position // the callback is updated based on the most recent call to any motor // the program moves the static object first, so the value of the variable Value // refers to motor 2 (static object) as long as it is moving // resp is a logic variable that checks that the position of motor 2 corresponds to // its intended angle, according to the equation: pos = 40.0 + 8/9 * final_theta (found empirically) // specifically, when the absolute difference between the current position (Value) and the intended position // drops below 0.5, the motor is considered in place bool resp = abs(Value - (40.0 + (90 + trial.getCurrent()["Tilt_sign"] * final_theta) * 8/9)) < .5; // when the static object has reached its final orientation, the other object starts rocking // otherwise the screen is black (so the objects are not illuminated) if(resp & start_rotate) { usleep(500000); showStimuli = true; // screen is colored switch_on(1); servo_rotate(wedgeMotors, 2, -7.5); start_rotate = false; } // rocking is controlled by the following loop if(Index == 2 && abs(Value - 33.5) < .5) CPhidgetAdvancedServo_setPosition (ADVSERVO, 2, 46.5); if(Index == 2 && abs(Value - 46.5) < .5) CPhidgetAdvancedServo_setPosition (ADVSERVO, 2, 33.5); return 0; }
void drawLetter() { /* glLoadIdentity(); glTranslated(0.0,0,trial.getCurrent()["AbsDepth"]); edge = 15.0; glColor3fv(glRed); glBegin(GL_LINES); glVertex3d(-edge,edge,0.0); glVertex3d(-edge,-edge,0.0); glBegin(GL_LINES); glVertex3d(-edge,-edge,0.0); glVertex3d(0,-edge,0.0); glEnd(); */ glLoadIdentity(); glTranslated(0.0,0,trial.getCurrent()["AbsDepth"]); edge = 10.0; glColor3fv(glRed); glBegin(GL_LINE_LOOP); glVertex3d(-edge,-edge,0.0); glVertex3d(-edge,edge,0.0); glVertex3d(0.0,edge,0.0); glVertex3d(0.0,0.0,0.0); glVertex3d(-edge,0.0,0.0); glEnd(); }
void advanceTrial() { // Save trial responseFile << trialNumber << "\t" << trial.getCurrent().at("CurvatureZ") << "\t" << trial.getCurrent().at("IODFactor") << "\t" << CurvatureZ*util::str2num<double>(parameters.find("RadiusX")) << "\t" << endl; if (!trial.next()) exit(0); trialNumber++; interoculardistance = str2num<double>(parameters.find("IOD"))*trial.getCurrent().at("IODFactor"); updateStimulus(trial.getCurrent().at("CurvatureZ")); // Randomize CurvatureZ again CurvatureZ= 0;//(double)mathcommon::unifRand(1,10)/10; //This is needed to randomize between trials }
/** * @brief drawTrial */ void drawTrial() { if (!experimentStarted) return; if (drawInfo) { double radiusX = util::str2num<double>(parameters.find("RadiusX")); glPushAttrib(GL_ALL_ATTRIB_BITS); glDisable(GL_TEXTURE_3D); GLText text; text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite); text.enterTextInputMode(); text.draw("CurvatureZ = " + util::stringify<double>(CurvatureZ)); text.draw("CurvatureZ x RadiusX= " + util::stringify<double>(CurvatureZ*radiusX)); text.draw("Factor CurvatureZ = " + util::stringify<double>(trial.getCurrent().at("CurvatureZ"))); text.draw("IOD x k = " + util::stringify<double>(interoculardistance)); if (parameters.find("UsePolkaDots")=="1") text.draw("Actual curvature controlled= "+util::stringify<double>(surface.parabolicCylinderSurface.curvature)); text.leaveTextInputMode(); glPopAttrib(); } if ( trialMode == PROBEMODE ) drawProbe(); if (trialMode == STIMULUSMODE ) drawStimulus(); }
void advanceTrial() { double timeElapsed = globalTimer.getElapsedTimeInMilliSec(); responseFile.precision(3); // max three decimal positions responseFile << fixed << parameters.find("SubjectName") << "\t" << trialNumber << "\t" << repetitions << "\t" << starting_theta << "\t" << final_theta << "\t" << trial.getCurrent()["Tilt_sign"] << "\t" << timeElapsed << "\t" << endl; trialNumber++; if(trial.hasNext()) { trial.next(); initTrial(); } else if (repetitions < max_repetitions) { repetitions++; initVariables(); trial.next(); initTrial(); } else { responseFile.close(); expFinished = true; beepOk(4); } }
void drawStimulus() { if ( isStimulusDrawn ) { glLoadIdentity(); glTranslated(0, 0, trial.getCurrent()["AbsDepth"]); // Left rear glPushMatrix(); glTranslated(-objwidth/2, 0, -adjDz/2); stimDrawer[0].draw(); glPopMatrix(); // Right rear rod glPushMatrix(); glTranslated(objwidth/2, 0, -adjDz/2); stimDrawer[1].draw(); glPopMatrix(); // Front rod glPushMatrix(); glTranslated(0, 0, adjDz/2); stimDrawer[2].draw(); glPopMatrix(); } }
void drawStimulus() { if (fingerCalibrationDone==3) { glLoadIdentity(); if(isStimulusDrawn) { if( !allVisibleFingers) drawNoFingers(); if(fingersShown) drawFingers(); if (stim_vanish_when_reached) { if( !reachedObject ) { drawTrial(); } }else{ if( timer.getElapsedTimeInMilliSec() <= trial.getCurrent()["RodVisibleTime"] ) { drawTrial(); } } } if(handAtStart && started) // && (timer.getElapsedTimeInMilliSec() > 2000)) advanceTrial(); } }
void initTrial() { // draw an empty screen isStimulusDrawn=false; // set the width of the object to be randomly between 30 and 70 mm objwidth = unifRand(30.0, 70.0); // initial adjustment is zero offsetZ = 0.0; // set the depth of the object to be randomly between 30 and 70 mm adjDz = unifRand(25.0, 75.0); // refresh the scene drawGLScene(); // set the monitor at the right ditance initProjectionScreen(trial.getCurrent()["AbsDepth"]); timer.start(); // draw the stimulus isStimulusDrawn=true; }
void advanceTrial() { beepOk(0); double timeElapsed = timer.getElapsedTimeInMilliSec(); responseFile.precision(3); // max three decimal positions responseFile << fixed << parameters.find("SubjectName") << "\t" << interoculardistance << "\t" << trialNumber << "\t" << trial.getCurrent()["AbsDepth"] << "\t" << objwidth << "\t" << adjDz << "\t" << timeElapsed << endl; trialNumber++; if(trial.hasNext()) { trial.next(); initTrial(); } else { isStimulusDrawn=false; drawGLScene(); responseFile.close(); expFinished = true; } }
void drawInfo() { if ( visibleInfo ) { GLText text; text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12); text.enterTextInputMode(); text.draw("####### SUBJECT #######"); text.draw("#"); text.draw("# Name: " +parameters.find("SubjectName")); text.draw("# IOD: " +stringify<double>(interoculardistance)); text.draw("#"); text.draw("# trial: " +stringify<double>(trialNumber)); text.draw("#"); text.draw("# orientation: " +stringify<double>(trial.getCurrent()["Orientation"]*(str2num<double>(parameters.find("ThetaSign")))+theta)); text.draw("#"); /* for ( std::map<string,double>::iterator iter = trial.getCurrent().begin(); iter!=trial.getCurrent().end();++iter) { text.draw(iter->first + ": " + stringify<double>(iter->second)); } */ text.draw("#######################"); /* text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) ); if ( isVisible(markers[1].p) && isVisible(markers[2].p) ) glColor3fv(glGreen); else glColor3fv(glRed); text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" ); text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" ); glColor3fv(glWhite); text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" ); text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" ); if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) ) glColor3fv(glGreen); else glColor3fv(glRed); text.draw("Marker "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[5].p.transpose())+ " [mm]" ); text.draw("Marker "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[6].p.transpose())+ " [mm]" ); text.draw("Marker "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" ); text.draw("Marker "+ stringify<int>(9)+stringify< Eigen::Matrix<double,1,3> > (markers[9].p.transpose())+ " [mm]" ); glColor3fv(glWhite); text.draw("EyeRight= "+stringify< Eigen::Matrix<double,1,3> > (eyeRight.transpose())+ " [mm]" ); text.draw("EyeLeft= "+stringify< Eigen::Matrix<double,1,3> > (eyeLeft.transpose())+ " [mm]" ); text.draw("Alignment(X,Y)= " +stringify<double>(alignmentX)+","+stringify<double>(alignmentY)); text.draw(" "); text.draw("jitter = " +stringify<double>(jitter)); text.draw(" "); text.draw("size = " +stringify<double>((xedge + jitter))); text.draw("xedge = " +stringify<double>(xedge)); text.draw(" "); text.draw("depth = " +stringify<double>(zedge + (jitter/2))); text.draw("zedge = " +stringify<double>(zedge)); */ text.leaveTextInputMode(); } }
void generateSphereStimulus(double radius) { int nStimulusPoints=(int)(stimulusDensity*4*M_PI*radius*radius); /* cylinder.setNpoints(nStimulusPoints); cylinder.setAperture(0,2*M_PI); cylinder.setRadiusAndHeight(radius,height); cylinder.setFluffiness(0.001); cylinder.compute(); */ sphere.setNpoints(nStimulusPoints); sphere.setRadius(radius); sphere.setFluffiness(0.001); sphere.compute(); // Update the stimulus drawer stimDrawer.setSpheres(false); stimDrawer.setStimulus(&sphere); stimDrawer.initList(&sphere,glRed,3); //stimDrawer.setStimulus(&cylinder); //stimDrawer.initList(&cylinder,glRed,3); visualStimCenter << util::str2num<double>(parameters.find("OffsetX")),0,factors.getCurrent().at("Distances"); rodStart = visualStimCenter + r*Vector3d(sin(thetaRod)*cos(phiRod),cos(thetaRod),sin(thetaRod)*sin(phiRod)); rodEnd= visualStimCenter - r*Vector3d(sin(thetaRod)*cos(phiRod),cos(thetaRod),sin(thetaRod)*sin(phiRod)); }
void advanceTrial() { double timeElapsed = timer.getElapsedTimeInMilliSec(); double percent_occluded_frames = (double)framesOccluded/(frameN-frames_at_start-frames_post_grasp); bool not_enough_frames = percent_occluded_frames > 0.20; if(not_enough_frames) { beepOk(1); trial.reinsert(trial.getCurrent()); good_trial = 0; } else { beepOk(0); good_trial = 1; } responseFile.precision(3); // max three decimal positions responseFile << fixed << parameters.find("SubjectName") << "\t" << interoculardistance << "\t" << trialNumber << "\t" << trial.getCurrent()["AbsDepth"] << "\t" << objwidth << "\t" << objdepth << "\t" << timeElapsed << "\t" << good_trial << endl; markersFile.close(); trialNumber++; if(trial.hasNext()) { trial.next(); initTrial(); } else { responseFile.close(); expFinished = true; } }
/** * @brief initializeExperiment */ void initializeExperiment() { initStreams(); factors.init(parameters); factors.next(); generateSphereStimulus(factors.getCurrent().at("StimulusRadius") ); initProjectionScreen(factors.getCurrent().at("Distances")); vector<double> distances = util::str2num<double>(parameters.find("fDistances")," "); maxCoveredDistance = max(distances.begin(),distances.end()) - min(distances.begin(),distances.end()); selectedFinger = util::str2num<int>(parameters.find("SelectedFinger")); // For the rod initialization thetaRod = M_PI/180.0*parameters.get("RodLatitude"); phiRod = M_PI/180.0*parameters.get("RodLongitude"); r = parameters.get("RodRadius"); rodStart = visualStimCenter + r*Vector3d(sin(thetaRod)*cos(phiRod),cos(thetaRod),sin(thetaRod)*sin(phiRod)); rodEnd= visualStimCenter - r*Vector3d(sin(thetaRod)*cos(phiRod),cos(thetaRod),sin(thetaRod)*sin(phiRod)); }
void initTrial() { // reset counters frameN = 0; frameToGrasp = 0; framesOccluded = 0; frames_post_grasp = 0; frames_at_start = 0; // subject did not grasp yet iGrasped = false; // draw an empty screen isStimulusDrawn=false; // set the width of the object to be randomly between 30 and 70 mm objwidth = unifRand(30.0, 70.0); // set the depth of the object to be randomly between 30 and 70 mm objdepth = trial.getCurrent()["RelDepthObj"]; // refresh the scene drawGLScene(); // set the monitor at the right ditance initProjectionScreen(trial.getCurrent()["AbsDepth"]); // draw the stimulus isStimulusDrawn=true; // markers file (if haptic) string markersFileName = experiment_directory + subjectName + "/" + markersFile_name + subjectName + "_markers-trial_" + stringify(trialNumber) + ".txt"; markersFile.open(markersFileName.c_str()); markersFile << fixed << markersFile_headers << endl; timer.start(); }
void drawCube() { glLoadIdentity(); glTranslated(0.0,0,trial.getCurrent()["AbsDepth"]); glRotated(trial.getCurrent()["Orientation"]*(str2num<double>(parameters.find("ThetaSign")))+theta,0,1,1); edge = str2num<double>(parameters.find("SquareSize")) + dedge + jitterX; glColor3fv(glRed); //front surface glBegin(GL_LINE_LOOP); glVertex3d(edge,edge,0.0); glVertex3d(edge,-edge,0.0); glVertex3d(-edge,-edge,0.0); glVertex3d(-edge,edge,0.0); glEnd(); //upper surface glBegin(GL_LINE_LOOP); glVertex3d(-edge,edge,-2.0*edge); glVertex3d(edge,edge,-2.0*edge); glVertex3d(edge,edge,0.0); glVertex3d(-edge,edge,0.0); glEnd(); //lower surface glBegin(GL_LINE_LOOP); glVertex3d(edge,-edge,-2.0*edge); glVertex3d(-edge,-edge,-2.0*edge); glVertex3d(-edge,-edge,0.0); glVertex3d(edge,-edge,0.0); glEnd(); //back surface glBegin(GL_LINE_LOOP); glVertex3d(edge,edge,-2.0*edge); glVertex3d(edge,-edge,-2.0*edge); glVertex3d(-edge,-edge,-2.0*edge); glVertex3d(-edge,edge,-2.0*edge); glEnd(); }