Changeset 2ff6bfa in robotics-hold_release


Ignore:
Timestamp:
08/15/13 04:39:25 (8 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master
Parents:
1f1f1b7
Message:
  • merge between working robot control and working linux build
File:
1 edited

Legend:

Unmodified
Added
Removed
  • wheelchair/bci2000/deploy/BCI2000/src/shared/modules/application/StimulusTask.cpp

    r1f1f1b7 r2ff6bfa  
    268268 
    269269        //Ramses Alcaide 07.08.2014 Edits for Hold Begin 
    270         int maxThresh, minThresh, consecutiveTrialsBeforeSelection, heldTarget, previousClassifierValue, previousTarget,currentTarget,currentStimulusCode; 
     270        int maxThresh, minThresh, consecutiveTrialsBeforeSelection, heldTarget, previousClassifierValue, currentStimulusCode; 
    271271        double currentClassifierValue; 
     272 
    272273        maxThresh = 40; 
    273         minThresh =10;  
     274        minThresh = 40; // Currently using only one threshold.  
    274275        consecutiveTrialsBeforeSelection = 0; 
    275         heldTarget = -1; 
    276         previousClassifierValue = 0;  
    277         previousTarget = 0; 
    278         currentTarget = 0; 
     276        previousClassifierValue = 0; 
     277 
     278        // Initialize Target to "Halt". 
     279        heldTarget = 5; 
     280         
    279281        currentStimulusCode = 0;  
    280         currentClassifierValue =0; 
    281  
     282        currentClassifierValue = 0; 
    282283        currentStimulusCode = stimulusCodeRes; 
    283284        currentClassifierValue = Input(0,0); 
    284         if (currentStimulusCode == 1 || currentStimulusCode == 7||currentStimulusCode== 6|| currentStimulusCode== 12){ 
    285         if(currentStimulusCode== 1 || currentStimulusCode== 7){ 
    286                 currentTarget = 0;       
    287                 if (currentClassifierValue >maxThresh) { 
    288                         heldTarget = currentTarget; 
    289  
    290                 }else if(currentClassifierValue <minThresh){ 
    291                         heldTarget = 1;  
    292                 } 
    293                  
     285         
     286        if ((currentStimulusCode == 1 || currentStimulusCode == 7) && (currentClassifierValue > maxThresh)){ // Forward row/col is intensified and classifier is above the threshold. 
     287                heldTarget = 1; // Decision is 1 = Forward  
    294288        } 
    295         else{ 
    296                 currentTarget = 1;  
    297                 if (currentClassifierValue >maxThresh) { 
    298                         heldTarget = currentTarget; 
    299  
    300                 }else if(currentClassifierValue <minThresh){ 
    301                         heldTarget = 0;  
    302                 } 
     289         
     290        else if((currentStimulusCode == 5 || currentStimulusCode == 9) && (currentClassifierValue > maxThresh)) { // Backward. 
     291                heldTarget = 2; 
    303292        }                
    304 } 
    305  
    306         AppLog <<"Input "<<Input(0,0)<<" " <<"CurrentStimulusCode "<<currentStimulusCode<<" "<<"StimulusCodeRes "<<stimulusCodeRes<<endl; 
    307         AppLog<<"CurrentClassifierValue "<<currentClassifierValue<<" "<<"HeldTarget "<<heldTarget << endl;  
    308  
    309         //Ramses Alcaide 07.08.2014 Edits for Hold End */ 
    310            
    311  
    312         //Ramses Alcaide 07.08.2014 Edits for UDP out Begin 
    313         //const char* address = "localhost:20320"; 
    314         const char* address = "172.16.5.1:20320"; 
    315          
    316         //  write to socket. 
     293         
     294        else if((currentStimulusCode == 4 || currentStimulusCode == 6) && (currentClassifierValue > maxThresh)) { // Rotate left. 
     295                heldTarget = 3; 
     296        }                
     297         
     298        else if((currentStimulusCode == 2 || currentStimulusCode == 10) && (currentClassifierValue > maxThresh)) { // Rotate right. 
     299                heldTarget = 4; 
     300        }                
     301         
     302        else if((currentStimulusCode == 3 || currentStimulusCode == 8) && (currentClassifierValue > maxThresh)) { // Halt. 
     303                heldTarget = 5; 
     304        } 
     305         
     306        else if (currentClassifierValue < minThresh) { 
     307                                heldTarget = 0; // Carry on the last decision.   
     308        } 
     309         
     310        AppLog << "Current Classifier Value: " << currentClassifierValue << " - Held Target: " << heldTarget << endl; 
     311 
     312        // Ramses Alcaide 07.08.2014 Edits for UDP out Begin 
     313        // const char* address = "localhost:20320"; 
     314        // const char* address = "192.168.1.5:20320"; // McHawking 
     315        const char* address = "172.16.5.1:20320"; // Linux Virtual Host 
     316        // Read from stdin, write to socket. 
    317317    sending_udpsocket socket( address ); 
    318318    sockstream output( socket ); 
    319     if( !output.is_open() ) 
    320       cerr << "Could not open " << address 
    321            << " for output." << endl; 
    322  
    323     string line; 
    324         line = "1"; 
    325       output << line << endl; 
    326  
    327         //Ramses Alcaide 07.08.2014 Edits for UDP out End*/ 
     319    if(!output.is_open()) 
     320      cerr << "Could not open " << address << " for output." << endl; 
     321 
     322    //string line; 
     323        //line = "1"; 
     324    //while( getline( cin, line ) ) 
     325        //AppLog << heldTarget << endl; 
     326        output << heldTarget << endl; 
     327   
     328 
     329 
     330        // Ramses Alcaide 07.08.2014 Edits for UDP out End 
    328331 
    329332    bcidbg( 2 ) << "Event: ClassInput" << endl; 
Note: See TracChangeset for help on using the changeset viewer.