int main() {
    RpcServer server;
    RpcServerOptions option;
    option.net_threads_num = 1;
    option.worker_threads_num = 1;
    server.set_options(option);

    comcfg::Configure conf;
    if (conf.load("./conf", "rpc_server.conf") != 0) {
        std::cerr << "load conf/rpc_server.conf fail" << std::endl;
    }
    comlog_init(conf["log"]);

    EchoServiceImpl echo_service_impl;
    if (server.RegisterService(&echo_service_impl) != 0) {
        std::cerr << "register service fail" << std::endl;
        return -1;
    }

    if (server.Start("127.0.0.1:60006")) {
        std::cerr << "start server fail" << std::endl;
        return -1;
    }

    return server.WaitForStop();
}
Example #2
0
    bool close()
    {
        rpc.interrupt();
        rpc.close();

        speaker.stop();

        return true;
    }
Example #3
0
 bool close()
 {
     rpcPort.interrupt();
     rpcPort.close();
     dumpPort.interrupt();
     dumpPort.close();
     opc.interrupt();
     opc.close();
     return true;
 }
Example #4
0
    bool configure(ResourceFinder &rf)
    {
        rf1=rf;

        if(algorithm==1)
            loc5=new UnscentedParticleFilter();
        else
            loc5=new ScalingSeries();

        loc5->configure(rf1);
        state=0;
        meas_given=1;

        if(loc5->measurementsString!=1)
        {
            namePorts = rf.check("namePorts", Value("visual-localization"), "Getting module name").asString();
            portIn.open("/"+namePorts+"/pnt:i");
            rpcOut.open("/"+namePorts+"/toolFeat:rpc");

            meas_given=0;
        }

        cout<<"meas_given "<<meas_given<<endl;
        error_thres=loc5->error_thres;
        cout<<"thresconf "<<error_thres<<endl;

        rpcPort.open(("/"+namePorts+"/rpc").c_str());
        attach(rpcPort);

        delete loc5;

        return true;

    }
Example #5
0
 bool close()
 {
     save();
     dispose();
     rpcPort.close();
     return true;
 }
Example #6
0
 bool interruptModule()
 {
     rpcPort.interrupt();
     dumpPort.interrupt();
     opc.interrupt();
     return true;
 }
 bool interruptModule()
 {
     closing = true;
     handlerPort.interrupt();
     cout<<"Interrupting your module, for port cleanup"<<endl;
     return true;
 }
Example #8
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)
 {
     count=0;
     handlerPort.open("/myModule");
     attach(handlerPort);
     return true;
 }
Example #9
0
 bool close()
 {
     rpcPort.close();
     iPort.close();
     oPort.close();
     return true;
 }
Example #10
0
    bool interruptModule()
    {
        imgInPort.interrupt();
        imgOutPort.interrupt();
        dataOutPort.interrupt();
        rpcPort.interrupt();

        return true;
    }
Example #11
0
    bool close()
    {
        imgInPort.close();
        imgOutPort.close();
        dataOutPort.close();
        rpcPort.close();

        return true;
    }
Example #12
0
    bool interruptModule()
    {

        cout<<"Interrupt caught!"<<endl;
		cout<<endl;
		handlerPort.interrupt();
		objectsPort.interrupt();
        return true;
    }
Example #13
0
    bool configure(ResourceFinder &rf)
    {
        iPort.open("/tracker:i");
        oPort.open("/tracker:o");
        rpcPort.open("/tracker:rpc");
        attach(rpcPort);

        state=idle;
        return true;
    }
Example #14
0
 bool close()
 {
     portDispIn.close();
     portDispOut.close();
     portOutPoints.close();
     portImgIn.close();
     portContour.close();
     portSFM.close();
     portRpc.close();
     return true;
 }
Example #15
0
 bool interruptModule()
 {
     portDispIn.interrupt();
     portDispOut.interrupt();
     portOutPoints.interrupt();
     portImgIn.interrupt();
     portContour.interrupt();
     portSFM.interrupt();
     portRpc.interrupt();
     return true;
 }
Example #16
0
    bool close()
    {
        if(meas_given!=1)
        {
            portIn.close();
            rpcOut.close();
        }
        rpcPort.close();
        return true;

    }
Example #17
0
    bool configure(ResourceFinder &rf)
    {
        string name=rf.check("name",Value("cmt")).asString().c_str();

        imgInPort.open(("/"+name+"/img:i").c_str());
        imgOutPort.open(("/"+name+"/img:o").c_str());
        dataOutPort.open(("/"+name+"/data:o").c_str());
        rpcPort.open(("/"+name+"/rpc").c_str());
        attach(rpcPort);

        initBoundingBox=doCMT=false;
        return true;
    }
Example #18
0
    bool configure(ResourceFinder &rf)
    {
        // request high resolution scheduling
        Time::turboBoost();

        speaker.configure(rf);
        if (!speaker.start())
            return false;

        string name=rf.find("name").asString().c_str();
        rpc.open(("/"+name+"/rpc").c_str());
        attach(rpc);

        return true;
    }
Example #19
0
    bool interruptModule()
    {
        if(meas_given!=1)
        {
            portIn.interrupt();
            rpcOut.interrupt();
        }

        rpcPort.close();

        if(state==1)
            delete loc5;
        return true;

    }
Example #20
0
int main(int argc, char *argv[]) {
    Network yarp;
    RpcServer server;

    server.promiseType(Type::byNameOnWire("rospy_tutorials/AddTwoInts"));

    if (!server.open("/add_two_ints@/yarp_add_int_server")) {
        fprintf(stderr,"Failed to open port\n");
        return 1;
    }

    while (true) {
        Bottle msg, reply;
        if (!server.read(msg,true)) continue;
        int x = msg.get(0).asInt32();
        int y = msg.get(1).asInt32();
        int sum = x + y;
        reply.addInt32(sum);
        printf("Got %d + %d, answering %d\n", x, y, sum);
        server.reply(reply);
    }

    return 0;
}
Example #21
0
    bool close()
    {
        igaze->restoreContext(startup_context_gaze);
        drvGaze.close();

        iarm->restoreContext(startup_context_arm);
        drvArm.close();

        imgLPortIn.close();
        imgRPortIn.close();
        imgLPortOut.close();
        imgRPortOut.close();
        rpcPort.close();
        return true;
    }
Example #22
0
    bool close()
    {
        // Terminate model
        Controller_terminate(Controller_M);

        imod->setControlMode(joint,VOCAB_CM_POSITION);
        if (compliant)
            iint->setInteractionMode(joint,VOCAB_IM_STIFF);
        
        rpc.close();
        dataOut.close();
        dataIn.close();        
        drv.close();

        return true;
    }
Example #23
0
    bool configure(ResourceFinder &rf)
    {
        interrupting=false;
        closing=false;
        this->rf=&rf;

        Bottle &bGeneral=rf.findGroup("general");
        if (bGeneral.isNull())
        {
            yError("group [general] is missing!");
            return false;
        }

        string name=bGeneral.check("name",Value("fingersTuner")).asString().c_str();
        setName(name.c_str());

        if (Bottle *bParts=bGeneral.find("relevantParts").asList())
        {
            for (int i=0; (i<bParts->size()) && !interrupting; i++)
            {
                string part=bParts->get(i).asString().c_str();
                tuners[part]=new Tuner;
                Tuner *tuner=tuners[part];

                if (!tuner->configure(rf,part))
                {
                    dispose();
                    return false;
                }

                tuner->sync(Value("*"));
            }
        }
        else
        {
            yError("\"relevantParts\" option is missing!");
            return false;
        }

        rpcPort.open(("/"+name+"/rpc").c_str());
        attach(rpcPort);

        // request high resolution scheduling
        Time::turboBoost();

        return true;
    }
Example #24
0
    void terminate()
    {

        imgInPort.close();
        imgOutPort.close();
        dataInPort.close();     // close prior to shutting down motor-interfaces
        logPort.close();
        rpcPort.close();

        if (drvArmL.isValid())
            drvArmL.close();

        if (drvArmR.isValid())
            drvArmR.close();

        if (drvGaze.isValid())
            drvGaze.close();
    }
    bool configure(yarp::os::ResourceFinder &rf)
    {
	path = rf.find("clouds_path").asString();        
	printf("Path: %s",path.c_str());		
	handlerPort.open("/mergeModule");
        attach(handlerPort);

	/* Module rpc parameters */
	visualizing = false;
	saving = true;
        closing = false;

	/*Init variables*/
	initF = true;	
	filesScanned = 0;

	cout<<"Configuring done."<<endl;

        return true;
    }
Example #26
0
    bool configure(ResourceFinder &rf)
    {
        portDispIn.open("/3d-points/disp:i");
        portDispOut.open("/3d-points/disp:o");
        portImgIn.open("/3d-points/img:i");
        portOutPoints.open("/3d-points/pnt:o");
        portContour.open("/3d-points/contour:i");
        portSFM.open("/3d-points/SFM:rpc");
        portRpc.open("/3d-points/rpc");

        portContour.setReader(*this);
        attach(portRpc);

        homeContextPath=rf.getHomeContextPath().c_str();
        downsampling=std::max(1,rf.check("downsampling",Value(1)).asInt());
        spatial_distance=rf.check("spatial_distance",Value(0.004)).asDouble();
        color_distance=rf.check("color_distance",Value(6)).asInt();
        go=flood3d=flood=false;

        return true;
    }
Example #27
0
    bool configure(ResourceFinder &rf)
    {
        agentName=rf.check("agent-name",Value("partner")).asString();
        period=rf.check("period",Value(0.05)).asDouble();

        if (!opc.connect("OPC"))
        {
            yError()<<"OPC seems unavailabe!";
            return false;
        }

        dumpPort.open("/actionRecogDataDumper/data/dump:o");
        rpcPort.open("/actionRecogDataDumper/rpc");
        attach(rpcPort);

        actionTag="none";
        objectTag="none";
        gate=0;

        return true;
    }
Example #28
0
    bool close()
    {
        handlerPort.close();
		objectsPort.close();

		igaze->stopControl();
		igaze->restoreContext(startupGazeContextID);
		igaze->deleteContext(startupGazeContextID);
		igaze->deleteContext(currentGazeContextID);

		if (clientGazeCtrl.isValid())
			clientGazeCtrl.close();

		icartLeft->stopControl();
		icartLeft->restoreContext(startupArmLeftContextID);
		icartLeft->deleteContext(startupArmLeftContextID);
		icartLeft->deleteContext(currentArmLeftContextID);

		if (clientArmLeft.isValid())
			clientArmLeft.close();

		icartRight->stopControl();
		icartRight->restoreContext(startupArmRightContextID);
		icartRight->deleteContext(startupArmRightContextID);
		icartRight->deleteContext(currentArmRightContextID);

		if (clientArmLeft.isValid())
			clientArmLeft.close();

		itorsoVelocity->stop();
		
		if (clientTorso.isValid())
		clientTorso.close();
		
        return true;
    }
Example #29
0
    bool configure(ResourceFinder &rf)
    {
        printf(" Starting Configure\n");
        this->rf=&rf;

        //****************** PARAMETERS ******************
        robot     = rf.check("robot",Value("icub")).asString().c_str();
        name      = rf.check("name",Value("demoINNOROBO")).asString().c_str();
        arm       = rf.check("arm",Value("right_arm")).asString().c_str();
        verbosity = rf.check("verbosity",Value(0)).asInt();    
        rate      = rf.check("rate",Value(0.5)).asDouble();

        if (arm!="right_arm" && arm!="left_arm")
        {
            printMessage(0,"ERROR: arm was set to %s, putting it to right_arm\n",arm.c_str());
            arm="right_arm";
        }

        printMessage(1,"Parameters correctly acquired\n");
        printMessage(1,"Robot: %s \tName: %s \tArm: %s\n",robot.c_str(),name.c_str(),arm.c_str());
        printMessage(1,"Verbosity: %i \t Rate: %g \n",verbosity,rate);

        //****************** DETECTOR ******************
        certainty     = rf.check("certainty", Value(10.0)).asInt();
        strCascade = rf.check("cascade", Value("haarcascade_frontalface_alt.xml")).asString().c_str();

        detectorL=new Detector();
        detectorL->open(certainty,strCascade);
        detectorR=new Detector();
        detectorR->open(certainty,strCascade);

        printMessage(1,"Detectors opened\n");

        //****************** DRIVERS ******************
        Property optionArm("(device remote_controlboard)");
        optionArm.put("remote",("/"+robot+"/"+arm).c_str());
        optionArm.put("local",("/"+name+"/"+arm).c_str());
        if (!drvArm.open(optionArm))
        {
            printf("Position controller not available!\n");
            return false;
        }

        Property optionCart("(device cartesiancontrollerclient)");
        optionCart.put("remote",("/"+robot+"/cartesianController/"+arm).c_str());
        optionCart.put("local",("/"+name+"/cart/").c_str());
        if (!drvCart.open(optionCart))
        {
            printf("Cartesian controller not available!\n");
            // return false;
        }

        Property optionGaze("(device gazecontrollerclient)");
        optionGaze.put("remote","/iKinGazeCtrl");
        optionGaze.put("local",("/"+name+"/gaze").c_str());
        if (!drvGaze.open(optionGaze))
        {
            printf("Gaze controller not available!\n");
            // return false;
        }

        // quitting conditions
        bool andArm=drvArm.isValid()==drvCart.isValid()==drvGaze.isValid();
        if (!andArm)
        {
            printMessage(0,"Something wrong occured while configuring drivers... quitting!\n");
            return false;
        }

        drvArm.view(iencs);
        drvArm.view(iposs);
        drvArm.view(ictrl);
        drvArm.view(iimp);
        drvCart.view(iarm);
        drvGaze.view(igaze);
        iencs->getAxes(&nEncs);

        iimp->setImpedance(0,  0.4, 0.03);
        iimp->setImpedance(1, 0.35, 0.03);
        iimp->setImpedance(2, 0.35, 0.03);
        iimp->setImpedance(3,  0.2, 0.02);
        iimp->setImpedance(4,  0.2, 0.00);

        ictrl -> setImpedancePositionMode(0);
        ictrl -> setImpedancePositionMode(1);
        ictrl -> setImpedancePositionMode(2);
        ictrl -> setImpedancePositionMode(3);
        ictrl -> setImpedancePositionMode(2);
        ictrl -> setImpedancePositionMode(4);

        igaze -> storeContext(&contextGaze);
        igaze -> setSaccadesStatus(false);
        igaze -> setNeckTrajTime(0.75);
        igaze -> setEyesTrajTime(0.5);

        iarm -> storeContext(&contextCart);

        printMessage(1,"Drivers opened\n");

        //****************** PORTS ******************
        imagePortInR        -> open(("/"+name+"/imageR:i").c_str());
        imagePortInL        -> open(("/"+name+"/imageL:i").c_str());
        imagePortOutR.open(("/"+name+"/imageR:o").c_str());
        imagePortOutL.open(("/"+name+"/imageL:o").c_str());
        portOutInfo.open(("/"+name+"/info:o").c_str());

        if (robot=="icub")
        {
            Network::connect("/icub/camcalib/left/out",("/"+name+"/imageL:i").c_str());
            Network::connect("/icub/camcalib/right/out",("/"+name+"/imageR:i").c_str());
        }
        else
        {
            Network::connect("/icubSim/cam/left",("/"+name+"/imageL:i").c_str());
            Network::connect("/icubSim/cam/right",("/"+name+"/imageR:i").c_str());
        }

        Network::connect(("/"+name+"/imageL:o").c_str(),"/demoINN/left");
        Network::connect(("/"+name+"/imageR:o").c_str(),"/demoINN/right");
        Network::connect(("/"+name+"/info:o").c_str(),"/iSpeak");

        rpcClnt.open(("/"+name+"/rpc:o").c_str());
        rpcSrvr.open(("/"+name+"/rpc:i").c_str());
        attach(rpcSrvr);
        
        printMessage(0,"Configure Finished!\n");
        return true;
    }
Example #30
0
int main()
{
	RpcServer server;
	server.serve(20001);
	return 0;
}