示例#1
0
    virtual bool threadInit()
    {
        string name=rf.check("name",Value("faceTracker")).asString().c_str();
        string robot=rf.check("robot",Value("icub")).asString().c_str();
        int period=rf.check("period",Value(50)).asInt();
        eye=rf.check("eye",Value("left")).asString().c_str();
        arm=rf.check("arm",Value("right")).asString().c_str();
        eyeDist=rf.check("eyeDist",Value(1.0)).asDouble();
        holdoff=rf.check("holdoff",Value(3.0)).asDouble();

        Property optGaze("(device gazecontrollerclient)");
        optGaze.put("remote","/iKinGazeCtrl");
        optGaze.put("local",("/"+name+"/gaze_client").c_str());

        if (!clientGaze.open(optGaze))
            return false;

        clientGaze.view(igaze);
        igaze->storeContext(&startup_gazeContext_id);
        igaze->blockNeckRoll(0.0);

        if (arm!="none")
        {
            Property optArm("(device cartesiancontrollerclient)");
            optArm.put("remote",("/"+robot+"/cartesianController/"+arm+"_arm").c_str());
            optArm.put("local",("/"+name+"/arm_client").c_str());
    
            if (!clientArm.open(optArm))
                return false;
    
            clientArm.view(iarm);
            iarm->storeContext(&startup_armContext_id);
        }

        portImgIn.open(("/"+name+"/img:i").c_str());
        portImgOut.open(("/"+name+"/img:o").c_str());
        portTopDown.open(("/"+name+"/topdown:i").c_str());
        portSetFace.open(("/"+name+"/setFace:rpc").c_str());

        if (!fd.init(rf.findFile("descriptor").c_str()))
        {
            fprintf(stdout,"Cannot load descriptor!\n");
            return false;
        }

        Rand::init();

        resetState();
        armCmdState=0;
        queuedFaceExprFlag=false;

        setRate(period);
        cvSetNumThreads(1);

        t0=Time::now();

        return true;
    }
示例#2
0
    /* 
    * Configure function. Receive a previously initialized
    * resource finder object. Use it to configure your module.
    * Open port and attach it to message handler.
    */
    bool configure(yarp::os::ResourceFinder &rf)
    {
/*
        list.push_back("The market is open.");          // 4
        list.push_back("The orange is sweet.");         // 4
        list.push_back("I love to play guitar.");       // 5
        list.push_back("He is in the kitchen.");        // 5
        list.push_back("I can speak English.");         // 4
        list.push_back("He is going home.");            // 4
        list.push_back("Tom is a funny man.");          // 5
        list.push_back("I have three apples.");         // 4

        list.push_back("The music; was good.");         // 4
        list.push_back("I am not a robot.");            // 5
        list.push_back("She is very pretty.");          // 4
        list.push_back("This song is great.");          // 4
        list.push_back("My friend has a horse.");       // 5
        list.push_back("The apple tasted good.");       // 4
        list.push_back("I like red flowers.");          // 4
        list.push_back("My horse runs very fast.");     // 5

        list.push_back("I have a nice house.");         // 5
        list.push_back("Jill wants a doll.");           // 4
        list.push_back("I have a computer.");           // 4
        list.push_back("Tom is stronger than Dan.");    // 5
        list.push_back("We, sing; a song.");            // 4
        list.push_back("I was very happy yesterday.");  // 5
        list.push_back("He eats white bread.");         // 4
        list.push_back("Jack wants a toy.");            // 4

        list.push_back("She is in the shower.");        // 5
        list.push_back("The baby plays with toys.");    // 5
        list.push_back("She is a teacher.");            // 4
        list.push_back("I have a nice box.");           // 5
        list.push_back("You look very happy.");         // 4
        list.push_back("The baby fell asleep.");        // 4
        list.push_back("They are; my friends.");        // 4
        list.push_back("I went to school.");            // 4
*/

	english = 1;
	if(english)
	{
		list.push_back("Benvenuti.");
		list.push_back("Io sono AICAB.");
		list.push_back("Sono felice di vederti.");
		list.push_back("Ciao.");
		list.push_back("Come va?");
		list.push_back("Questa e casa mia.");
		list.push_back("Io sono un robot.");
		list.push_back("Ciao.");

/*		list.push_back("Hi, how are you?");
		list.push_back("Hello.");
		list.push_back("I'm looking at you.");
		list.push_back("How is it going?");
		list.push_back("Hello, I'm eye cub.");
		list.push_back("Welcome to my home.");
		list.push_back("Hi there.");
		list.push_back("Hello.");
*/
/*		list.push_back("We sing a song.");
		list.push_back("I was very happy yesterday.");
		list.push_back("I have a computer.");
		list.push_back("Jill wants a doll.");
		list.push_back("He eats white bread.");
		list.push_back("I love to play guitar.");
		list.push_back("He is in the kitchen.");
		list.push_back("She has a nice bike.");

		list.push_back("I went to school.");
		list.push_back("Tom is stronger than Dan.");
		list.push_back("She is a teacher.");
		list.push_back("I like red flowers.");
		list.push_back("The music was good.");
		list.push_back("The apple tasted good.");
		list.push_back("You look very happy.");
		list.push_back("I have three apples.");

		list.push_back("Jack wants a toy.");
		list.push_back("The baby plays with toys.");
		list.push_back("I have a nice box.");
		list.push_back("This song is great.");
		list.push_back("Tom is a funny man.");
		list.push_back("My friend has a horse.");
		list.push_back("The baby fell asleep.");
		list.push_back("I can speak English.");

		list.push_back("I am not a robot.");
		list.push_back("My horse runs very fast.");
		list.push_back("They are going home.");
		list.push_back("She is very pretty.");
		list.push_back("The market is open.");
		list.push_back("She is in the shower.");
		list.push_back("They are; my friends.");
		list.push_back("The apple is sweet.");*/
	}
	else
	{
		list.push_back("Il bar è aperto.");
		list.push_back("Mi piace molto ballare."); 
		list.push_back("Non bevo il caffè.");
		list.push_back("Marco ha tanti cani.");
		list.push_back("Il mare è calmo.");
		list.push_back("Il cane abbaia spesso.");
		list.push_back("Sono allergico al latte.");
		list.push_back("La sedia è in camera.");

		list.push_back("La luce è rossa.");
		list.push_back("Lui ha sempre ragione.");
		list.push_back("Giovedí scorso era festa.");
		list.push_back("Oggi splende il sole.");
		list.push_back("Ho comprato il pane.");
		list.push_back("Guido tutti i giorni.");
		list.push_back("Vado spesso al mare.");
		list.push_back("La notte è buia.");

		list.push_back("Mi piace il gelato.");
		list.push_back("Devo scrivere un tema.");
		list.push_back("Lei ama cucire.");
		list.push_back("Io ballo la polka.");
		list.push_back("Gino canta molto bene.");
		list.push_back("Vado a dormire presto.");
		list.push_back("La lettera è firmata.");
		list.push_back("Gioco spesso a carte.");

		list.push_back("Mi piace l'opera.");
		list.push_back("Ho mangiato le mele.");
		list.push_back("Sua nonna sta bene.");
		list.push_back("Ho una maglia blu.");
		list.push_back("Il piatto è sul tavolo.");
		list.push_back("La giornata è piovosa.");
		list.push_back("Il film dura due ore.");
		list.push_back("La bottiglia è piena.");

	}
        gazeCount=0;
        speech_counter=0;
		online=1;
        prev = Time::now();
        waittime=5.0;
        
        withgaze=1;
        prevyes=0;
        state=1;
        order=2;
        initstate=1;
        prevStr = "quiet";
        donespeaking=1;
        wordnumber=0;
	charnumber=0;
        prevgaze=0;
        facecounter=0;
        gazelength=0.0;
	gazelen=0.0;
        motorson=1;
        firstspeech=0;

        if(motorson==1)
        {
            Property optGaze("(device gazecontrollerclient)");
            optGaze.put("remote","/iKinGazeCtrl");
            optGaze.put("local","/icub_eyetrack/gaze");
                printf("\nHello.\n");
            if (!clientGaze.open(optGaze))
            {
                printf("\nGAZE FAILED\n");
                return false;
            }
            else
                printf("\nGAZE OPEN\n");

            clientGaze.view(igaze);
	    igaze->blockNeckRoll(0.0);
            igaze->setNeckTrajTime(0.8);
            igaze->setEyesTrajTime(0.4);
	    yarp::sig::Vector azelr(3);
///	    azelr[0] = -30.0;
///	    azelr[1] = 0.0;
	    azelr[0] = 0.0;
	    azelr[1] = 20.0;
	    azelr[2] = 0.0;
            igaze->lookAtAbsAngles(azelr);
        }
        handlerPort.open("/dictationcontroller");
        gazeIn.open( "/dictationcontroller/gaze:i" );
        speechOut.open( "/dictationcontroller/speech:o" );
        logOut.open( "/dictationcontroller/log:o" );
        attach(handlerPort);
        Network::connect("/dlibgazer/out", "/dictationcontroller/gaze:i");
        Network::connect("/dictationcontroller/speech:o", "/iSpeak");
        speechStatusPort.open("/dictationcontroller/iSpeakrpc");
        Network::connect("/dictationcontroller/iSpeakrpc", "/iSpeak/rpc");

	frame_counter=0;
        cout<<"Done configuring!" << endl;
        return true;
    }