bool ArNetCameraRequest::requestPanTiltAbs(double pan, double tilt) { empty(); byte2ToBuf((ArTypes::Byte2)(pan * 1000.0)); byte2ToBuf((ArTypes::Byte2)(tilt * 1000.0)); finalizePacket(); return myClient->requestOnce(myAbsReqName.c_str(), this); }
int main(int argc, char **argv) { Aria::init(); ArClientBase client; std::string host; ArArgumentParser parser(&argc, argv); ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); /* Check for -help, and unhandled arguments: */ if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed()) { clientConnector.logOptions(); exit(0); } /* Connect our client object to the remote server: */ if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server rejected connection, exiting\n"); else printf("Could not connect to server, exiting\n"); exit(1); } client.requestOnce("reloadConfig"); ArTime start; start.setToNow(); while (Aria::getRunning() && client.isConnected()) { client.loopOnce(); ArUtil::sleep(ArMath::random() % 10000); client.requestOnce("reloadConfig"); } Aria::shutdown(); return 0; }
int main(int argc, char **argv) { Aria::init(); //ArLog::init(ArLog::StdOut, ArLog::Verbose); ArClientBase client; ArArgumentParser parser(&argc, argv); ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed()) { clientConnector.logOptions(); exit(0); } if (parser.getArgc() < 4 || parser.getArgc() > 6) { printf("usage: %s <x> <y> <th> <optional:xyspread> <optional:thspread>", argv[0]); exit(1); } if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server '%s' rejected connection, exiting\n", client.getHost()); else printf("Could not connect to server '%s', exiting\n", client.getHost()); exit(1); } client.runAsync(); ArNetPacket sending; // put in the arguments (you can see what they are from doing -lcl on clientDemo) sending.byte4ToBuf(atoi(parser.getArg(1))); sending.byte4ToBuf(atoi(parser.getArg(2))); sending.byte4ToBuf(atoi(parser.getArg(3))); if (parser.getArgc() > 4) sending.uByte4ToBuf(atoi(parser.getArg(4))); if (parser.getArgc() > 5) sending.uByte4ToBuf(atoi(parser.getArg(5))); // send the packet client.requestOnce("localizeToPose", &sending); // you have to give the client some time to send the command ArUtil::sleep(500); Aria::shutdown(); return 0; }
void InputHandler::unsafeDrive() { /* Construct a request packet. The data is a single byte, with value * 1 to enable safe drive, 0 to disable. */ ArNetPacket p; p.byteToBuf(0); /* Send the packet as a single request: */ if(myPrinting) printf("Sending setSafeDrive 0.\n"); myClient->requestOnce("setSafeDrive",&p); if(myPrinting) printf("\nSent disable safe drive command. Your robot WILL run over things if you're not careful.\n"); }
void InputHandler::safeDrive() { /* Construct a request packet. The data is a single byte, with value * 1 to enable safe drive, 0 to disable. */ ArNetPacket p; p.byteToBuf(1); /* Send the packet as a single request: */ if(myPrinting) printf("Sending setSafeDrive 1.\n"); myClient->requestOnce("setSafeDrive",&p); if(myPrinting) printf("\nSent enable safe drive.\n"); }
int main(int argc, char **argv) { ArGlobalFunctor1<ArNetPacket *> getMapNameCB(handleGetMapName); ArGlobalFunctor1<ArNetPacket *> getMapCB(handleGetMap); Aria::init(); //ArLog::init(ArLog::StdOut, ArLog::Verbose); ArArgumentParser parser(&argc, argv); ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); /* Check for -help, and unhandled arguments: */ if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); exit(0); } /* Connect our client object to the remote server: */ if (!clientConnector.connectClient(&client)) { exit(1); } client.addHandler("getMap", &getMapCB); client.addHandler("getMapName", &getMapNameCB); client.requestOnce("getMapName"); start.setToNow(); client.requestOnce("getMap"); client.run(); }
int main(int argc, char **argv) { Aria::init(); //ArLog::init(ArLog::StdOut, ArLog::Verbose); ArClientBase client; ArArgumentParser parser(&argc, argv); ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed()) { clientConnector.logOptions(); exit(0); } if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server '%s' rejected connection, exiting\n", client.getHost()); else printf("Could not connect to server '%s', exiting\n", client.getHost()); exit(1); } client.runAsync(); ArNetPacket sending; // We have to tell it what section we're sending sending.strToBuf("Section"); // The map is in the files section sending.strToBuf("Files"); // The parameter name sending.strToBuf("Map"); // The value of the parameter sending.strToBuf("entire2.map"); // you could put in however many of these you want... client.requestOnce("setConfig", &sending); // you have to give the client some time to send the command ArUtil::sleep(500); Aria::shutdown(); return 0; }
int main(int argc, char **argv) { std::string hostname; ArGlobalFunctor1<ArNetPacket *> drawingCB(&drawing); Aria::init(); //ArLog::init(ArLog::StdOut, ArLog::Verbose); ArArgumentParser parser(&argc, argv); ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); /* Check for -help, and unhandled arguments: */ if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); exit(0); } /* Connect our client object to the remote server: */ if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server '%s' rejected connection, exiting\n", client.getHost()); else printf("Could not connect to server '%s', exiting\n", client.getHost()); exit(1); } printf("Connected to server.\n"); client.addHandler("listDrawings", &drawingCB); client.requestOnce("listDrawings"); client.runAsync(); while (client.getRunningWithLock()) { ArUtil::sleep(1); //printf("%d ms since last data\n", client.getLastPacketReceived().mSecSince()); } Aria::shutdown(); return 0; }
int main(int argc, char **argv) { Aria::init(); //ArLog::init(ArLog::StdOut, ArLog::Verbose); ArClientBase client; ArArgumentParser parser(&argc, argv); ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed()) { clientConnector.logOptions(); exit(0); } if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server '%s' rejected connection, exiting\n", client.getHost()); else printf("Could not connect to server '%s', exiting\n", client.getHost()); exit(1); } client.runAsync(); ArNetPacket sending; // We have to tell it what route we want to patrol sending.strToBuf("hallways"); // tell it how much many times we want to patrol (<= 0 == forever) sending.byte4ToBuf(0); client.requestOnce("patrolRouteCount", &sending); // note that there's also another call (patrol) that just has it always // patrol forever but this gives you more options and is only // slightly more complicated (just give it that byte4) // you have to give the client some time to send the command ArUtil::sleep(500); Aria::shutdown(); return 0; }
int main(int argc, char **argv) { ArClientBase client; ArGlobalFunctor1<ArNetPacket *> testCB(&test); Aria::init(); //ArLog::init(ArLog::StdOut, ArLog::Verbose); ArTime startTime; startTime.setToNow(); if (!client.blockingConnect("localhost", 7273)) { printf("Could not connect to server, exiting\n"); exit(1); } printf("Took %ld msec to connect\n", startTime.mSecSince()); client.runAsync(); client.lock(); client.addHandler("test", &testCB); client.addHandler("test2", &testCB); client.addHandler("test3", &testCB); client.logDataList(); client.requestOnce("test"); client.request("test2", 100); client.request("test3", -1); client.unlock(); ArUtil::sleep(1000); printf("Changing speed\n"); client.lock(); client.request("test2", 300); client.unlock(); ArUtil::sleep(1000); client.lock(); client.requestStop("test2"); client.unlock(); ArUtil::sleep(1000); client.lock(); client.disconnect(); client.unlock(); ArUtil::sleep(50); exit(0); }
int main(int argc, char **argv) { Aria::init(); ArLog::init(ArLog::StdOut, ArLog::Normal); ArClientBase client; ArArgumentParser parser(&argc, argv); ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed()) { clientConnector.logOptions(); exit(0); } if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server '%s' rejected connection, exiting\n", client.getHost()); else printf("Could not connect to server '%s', exiting\n", client.getHost()); exit(1); } ArGlobalFunctor1<ArNetPacket *> getModeDataListCB(&getModeDataList); ArGlobalFunctor1<ArNetPacket *> getModeInfoCB(&getModeInfo); client.addHandler("getModeDataList", &getModeDataListCB); client.requestOnce("getModeDataList"); client.addHandler("getModeInfo", &getModeInfoCB); client.request("getModeInfo", -1); client.runAsync(); while (client.getRunningWithLock()) { ArUtil::sleep(1); //printf("%d ms since last data\n", client.getLastPacketReceived().mSecSince()); } Aria::shutdown(); return 0; }
int main(int argc, char **argv) { Aria::init(); ArGlobalFunctor1<ArNetPacket *> clientListHandlerCB(&clientListHandler); ArGlobalFunctor1<ArNetPacket *> clientAddedHandlerCB(&clientAddedHandler); ArGlobalFunctor1<ArNetPacket *> clientRemovedHandlerCB(&clientRemovedHandler); ArNetPacket packet; ArClientBase client; ArArgumentParser parser(&argc, argv); ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); exit(0); } if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server '%s' rejected connection, exiting\n", client.getHost()); else printf("Could not connect to server '%s', exiting\n", client.getHost()); exit(1); } printf("Connected to server.\n"); client.addHandler("clientList", &clientListHandlerCB); client.requestOnce("clientList"); client.addHandler("clientRemoved", &clientRemovedHandlerCB); client.request("clientRemoved", -1); client.addHandler("clientAdded", &clientAddedHandlerCB); client.request("clientAdded", -1); client.run(); Aria::shutdown(); return 0; }
/** Initialize the robot connection */ JNIEXPORT jint JNICALL Java_com_adept_arandroid_ArjRobot_initialize (JNIEnv *env, jobject obj, jstring host, jint port) { // Get the host ip address const char *cHost = env->GetStringUTFChars(host, 0); // Try to connect Aria::init(); ArLog::setFunctor(new ArGlobalFunctor1<const char*>(ariaLogDebugPrint)); debugPrintS("Connecting to ", cHost); if (!myClient.blockingConnect(cHost, port, true, NULL, NULL, NULL)) { debugPrint("Error connecting"); return -1; } debugPrint("Connected"); // Run the client connection in a different thread myClient.runAsync(); // Download the map, maybe move this to it's own function later debugPrint("getting map"); myClient.requestOnce("getMapBinary"); // Create the OutputHandler myOutputHandler = new OutputHandler(&myClient); /* Block until the connection is closed. We will use this time to get * status update information at a regular rate. */ myShutdown = false; while (myClient.getRunningWithLock() && !myShutdown) { ArUtil::sleep(100); myServerStatus = myOutputHandler->getServerStatus(); myOutputHandler->getRobotStatus(myRobotStatus); } debugPrint("Shutting down Aria"); myClient.disconnect(); Aria::shutdown(); return 0; }
void InputHandler::sendInput(void) { /* This method is called by the main function to send a ratioDrive * request with our current velocity values. If the server does * not support the ratioDrive request, then we abort now: */ if(!myClient->dataExists("ratioDrive")) return; /* Construct a ratioDrive request packet. It consists * of three doubles: translation ratio, rotation ratio, and an overall scaling * factor. */ ArNetPacket packet; packet.doubleToBuf(myTransRatio); packet.doubleToBuf(myRotRatio); packet.doubleToBuf(50); // use half of the robot's maximum. packet.doubleToBuf(myLatRatio); if (myPrinting) printf("Sending\n"); myClient->requestOnce("ratioDrive", &packet); myTransRatio = 0; myRotRatio = 0; myLatRatio = 0; }
int main(int argc, char **argv) { Aria::init(); ArClientBase client; ArArgumentParser parser(&argc, argv); /* This will be used to connect our client to the server. * It will get the hostname from the -host command line argument: */ ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); /* Check for -host, -help, ARIA arguments, and unhandled arguments: */ if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); Aria::exit(0); } /* Connect our client object to the remote server: */ if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server '%s' rejected connection, exiting\n", client.getHost()); else printf("Could not connect to server '%s', exiting\n", client.getHost()); Aria::exit(1); } printf("Connected to server.\n"); client.setRobotName(client.getHost()); // include server name in log messages client.runAsync(); ArNetPacket request; // request. // client.requestOnceByCommand(ArCommands::ENABLE, ) ArClientHandlerRobotUpdate updates(&client); // client.requestOnce("enableMotor"); ArGlobalFunctor1<ArNetPacket*> enableCB(&enable); ArGlobalFunctor1<ArNetPacket *> getFileCB(&netGetFile); ArGlobalFunctor1<ArNetPacket*> recieveDataCB(&recieveData); client.addHandler("requestEnableMotor", &enableCB); client.addHandler("handleCheckObjectData", &recieveDataCB); //client.addHandler("getFile", &getFileCB); client.requestOnce("requestEnableMotor"); client.request("handleCheckObjectData", 10); updates.requestUpdates(); if (checkObject) client.requestOnceWithString("getFile", "./image/ball.jpg"); ArPose pose; namedWindow("image", 0); while (client.getRunningWithLock()) { //client.requestOnce("sendData"); if (checkObject) { // if (!a) { cout <<"OK"<<endl; // client.requestOnceWithString("getFile", "./image/ball.jpg"); client.addHandler("getFile", &getFileCB); // client.remHandler("getFile", &getFileCB); //} else { //client.remHandler("getFile", &getFileCB); //} Mat image; image = imread("./image/ball.jpg", CV_LOAD_IMAGE_COLOR); imshow("image", image); char c = (char)waitKey(10); if( c == 27 ) break; } ArUtil::sleep(200); } // client.requestStop("getFile"); cout <<"Da tim thay qua bong o vi tri pose("<<pose.getX()<<", "<<pose.getY()<<")"<<endl; cout <<"Vi tri pose("<<pose.getX()<<", "<<pose.getY()<<")"<<endl; /* The client stopped running, due to disconnection from the server, general * Aria shutdown, or some other reason. */ client.disconnect(); Aria::exit(0); return 0; }
void InputHandler::right(void) { ArNetPacket packet; packet.doubleToBuf(-3.2); myClient->requestOnce("deltaHeading", &packet); }
void InputHandler::down(void) { ArNetPacket packet; packet.doubleToBuf(-25); myClient->requestOnce("deltaVel", &packet); }
void NavigationClient::Main() { std::cout << "Navigation client started" << std::endl; int argsNumber; argsNumber = 3; char *arguments[argsNumber]; arguments[0]="./arg_test"; arguments[1]="-host"; //arguments[2]="10.41.42.1"; //se puede poner también patrolbot arguments[2]="77.7.27.1"; int robotCase, counter; ArClientBase client; ArPose pose(0, 0, 0); ArPose GoToPose(3000.0, 0.0, -90.0); ArNetPacket posePacket, directGoToPosePacket; ArArgumentParser parser(&argsNumber, arguments);posePacket.empty(); ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); headingsForBedroom.push_back(45); headingsForBedroom.push_back(25); headingsForBedroom.push_back(0); headingsForLiving.push_back(-20); headingsForLiving.push_back(-55); headingsForLiving.push_back(-80); headingsForLiving.push_back(-110); headingsForLiving.push_back(-140); openDoor = false; if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed()) { clientConnector.logOptions(); exit(0); } printf("Connecting...\n"); if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server rejected connection, exiting\n"); else printf("Could not connect to server, exiting\n"); exit(1); } printf("Connected to server.\n"); client.addHandler("pathPlannerStatus", new ArGlobalFunctor1<ArNetPacket*>(&handlePathPlannerStatus)); client.addHandler("update", new ArGlobalFunctor1<ArNetPacket*>(&handleRobotUpdate)); client.addHandler("goalName", new ArGlobalFunctor1<ArNetPacket*>(&handleGoalName)); client.addHandler("getGoals", new ArGlobalFunctor1<ArNetPacket*>(&handleGoalList)); client.addHandler("getSensorCurrent", new ArGlobalFunctor1<ArNetPacket*>(&handleSensorCurrent)); client.addHandler("getSensorList", new ArGlobalFunctor1<ArNetPacket*>(&handleSensorList)); client.addHandler("getLocState", new ArGlobalFunctor1<ArNetPacket*>(&handleLocState)); client.runAsync(); client.requestOnce("getGoals"); client.requestOnce("getSensorList"); client.requestOnceWithString("getSensorCurrent", "lms2xx_1"); // client.request("pathPlannerStatus", 5000); client.request("goalName", 1000); client.request("update", 1000); client.requestOnce("getLocState"); sleep(2); int cont =0; while (!openDoor) { cont++; ArUtil::sleep(2000); client.requestOnceWithString("getSensorCurrent", "lms2xx_1"); } printf("*** Door has been OPENED *** \n"); sleep(2); if (client.dataExists("localizeToPose")) { printf(".. Server does have \"localizeToPose\" request.\n"); posePacket.byte4ToBuf(sharedMemory->getInstance().getLocalizationRobotPosition().get_X()); posePacket.byte4ToBuf(sharedMemory->getInstance().getLocalizationRobotPosition().get_Y()); posePacket.byte4ToBuf(sharedMemory->getInstance().getLocalizationRobotPosition().get_Angle()); client.requestOnce("localizeToPose", &posePacket); ArUtil::sleep(1500); } else printf(".. Server doesn't have that request.\n"); for(;;){ string action = sharedMemory->getInstance().getAction(); if (action=="navigate"){ cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl; navigateTo(sharedMemory->getInstance().getStringDestination(), &client); sharedMemory->getInstance().setAction("turn"); }if (action=="navigateToParty"){ cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl; navigateTo(sharedMemory->getInstance().getStringDestination(), &client); sleep(6); sharedMemory->getInstance().startDownToRotations=false; sharedMemory->getInstance().sintetizer.set_Phrase("If you need something please wave your hand to my bottom kinect"); sleep(8); indexHeading=0; sharedMemory->getInstance().setAction("turn"); } else if (action=="navigateBackToEmergency"){ cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl; navigateTo(sharedMemory->getInstance().getStringDestination(), &client); // sharedMemory->sintetizer.set_Phrase("Emergency Situation resolved"); sharedMemory->getInstance().setAction("createReport"); }else if (action=="navigateToEntrance"){ cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl; sharedMemory->getInstance().sintetizer.set_Phrase("Do not worry, I have called the ambulance"); sleep(2); sharedMemory->getInstance().sintetizer.set_Phrase("Please wait a moment, I willl wait for them"); sleep(2); navigateTo(sharedMemory->getInstance().getStringDestination(), &client); sharedMemory->getInstance().setAction("waitForAmbulance"); } else if (action=="navigateCloseTo"){ cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl; navigateTo(sharedMemory->getInstance().getStringDestination(), &client); sharedMemory->getInstance().setAction("requestEmergencyObjects"); } else if (action=="navigateToHome"){ cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl; navigateTo(sharedMemory->getInstance().getStringDestination(), &client); sharedMemory->getInstance().setAction("requestCommand"); } else if (action=="navigateToQuestions"){ cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl; navigateTo(sharedMemory->getInstance().getStringDestination(), &client); sharedMemory->getInstance().setAction("requestQuestions"); } else if (action=="navigateToObject"){ //solo es utilizado por cocktail Party //Si se quita la indicación de lugar en requestOptions aqui debe mandarse el destino predefinido (kitchen?) cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl; navigateTo(sharedMemory->getInstance().getStringDestination(), &client); sharedMemory->getInstance().setAction("recognizeObject"); } else if (action=="navigateToObjectCategory"){ //considera que la posición de la categoria de un objeto (en pick and place) es la misma posición que la de donde esta el objeto en emergencia. cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl; //por default ahorita esta dining como el la categoria del objeto navigateTo(sharedMemory->getInstance().getStringDestination(), &client); if (sharedMemory->getInstance().getTestRunning()=="pick and place" || sharedMemory->getInstance().getTestRunning()=="Emergency" ) sharedMemory->getInstance().setAction("deliverObject"); else sharedMemory->getInstance().setAction("userRecognize"); }else if (action=="navigateToPoint"){ cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl; //TODO verificar que esto limpia el objeto posePacket.empty(); posePacket.byte4ToBuf(sharedMemory->getInstance().lastObjective->getObjetivePosition().get_X()); posePacket.byte4ToBuf(sharedMemory->getInstance().lastObjective->getObjetivePosition().get_Y()); posePacket.byte4ToBuf(sharedMemory->getInstance().lastObjective->getObjetivePosition().get_Angle()); cout << "Enviando punto a navegación: "<< sharedMemory->getInstance().lastObjective->getObjetivePosition().get_X() << "," << sharedMemory->getInstance().lastObjective->getObjetivePosition().get_Y() << "," << sharedMemory->getInstance().lastObjective->getObjetivePosition().get_Angle()<<endl; client.requestOnce("gotoPose", &posePacket); sleep(10); printf("Before while Navigation"); while (strncmp(textData, "Arrived at", 10) != 0){ sleep(10); } printf("Navigation ended"); if (sharedMemory->getInstance().getTestRunning()=="CocktailParty") sharedMemory->getInstance().setAction("userLearn"); else sharedMemory->getInstance().setAction("requestEmergencyObjects"); }else if (action=="navigateForward"){ stringstream command; cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl; command<<"8 " << sharedMemory->getInstance().getGestureDepthPosition(); cout<< "****** AVANZA "<<command.str().c_str()<<" mm"<<endl; client.requestOnceWithString("MicroControllerMotionCommand",command.str().c_str()); sleep(10); printf("Before while Navigation"); while (strncmp(textData, "Stopped", 10) != 0){ sleep(10); } sharedMemory->getInstance().setAction("turn"); }else if (action=="turn"){ int heading=0; stringstream command; cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl; if (sharedMemory->getInstance().startDownToRotations==false){ if (sharedMemory->getInstance().getStringDestination()=="bedroom"){ cout<<"Entrando BEDROOM 1"<<endl; if (indexHeading < headingsForBedroom.size()){ heading=headingsForBedroom[indexHeading]; indexHeading++; cout<<"Entrando a If UNO bedroom"<<endl; }else{ sharedMemory->getInstance().startDownToRotations=true; indexHeading=headingsForBedroom.size()-2; heading=(-1000);//valor dado para detectar que no se obtuvo un valor válido para el heading, dado que se cambia la forma en como se recorre el arreglo cout<<"Entrando a else UNO bedroom"<<endl; } }else {//if (sharedMemory->getInstance().getStringDestination()=="living"){ cout<<"Entrando a LIVING 1"<<endl; if (indexHeading < headingsForLiving.size()){ heading=headingsForLiving[indexHeading]; indexHeading++; cout<<"Entrando a If UNO living"<<endl; }else{ sharedMemory->getInstance().startDownToRotations=true; indexHeading=headingsForLiving.size()-2;//no menos uno porque ya el proceso anterior permition visitar este indice heading=(-1000); cout<<"Entrando a else UNO Living"<<endl; } } }else{ if (sharedMemory->getInstance().getStringDestination()=="bedroom"){ cout<<"Entrando BEDROoM 2"<<endl; if (indexHeading >= 0){ heading=headingsForBedroom[indexHeading]; indexHeading--; cout<<"Entrando a if DOS bedroom"<<endl; }else{ sharedMemory->getInstance().startDownToRotations=false; indexHeading=1; heading=(-1000); cout<<"Entrando a else DOS bedroom"<<endl; } }else {//if (sharedMemory->getInstance().getStringDestination()=="living"){ cout<<"Entrando a LIVING 2"<<endl; if (indexHeading>= 0){ heading=headingsForLiving[indexHeading]; indexHeading--; cout<<"Entrando a if DOS living"<<endl; }else{ sharedMemory->getInstance().startDownToRotations=false; indexHeading=1;//no 0 porque ya el proceso anterior permitió visitar este indice heading=(-1000); cout<<"Entrando a else DOS living"<<endl; } } } if (heading>(-1000)){ command<<"12 " << heading; cout<< "****** ROTAR "<<command.str().c_str()<<" grades con INDEXHEADING: "<<indexHeading<<"valorArray"<< headingsForLiving[indexHeading]<<endl; client.requestOnceWithString("MicroControllerMotionCommand",command.str().c_str()); //sharedMemory->getInstance().sintetizer.set_Phrase("If you need something, please wave your hand to my bottom kinect"); sleep(1); cout<<"*INVERSA al hacer el heading: "<< sharedMemory->getInstance().startDownToRotations << endl; sharedMemory->getInstance().setAction("payAttention"); } }else if (action=="navigateToExit"){ //éste estado solo llamarlo para terminar la prueba cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl; navigateTo("Exit", &client); sharedMemory->getInstance().setAction("turnOff");; } else if (action=="turnOff"){ cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl; //ArUtil::sleep(60000); printf("Server disconnected.\n"); Aria::shutdown(); } } return ; }
void putFile(char *fileName, char *asFileName) { ArNetPacket sendPacket; size_t ui; size_t len; FILE *file; if ((file = ArUtil::fopen(fileName, "r")) == NULL) { ArLog::log(ArLog::Normal, "putFile: can't open file '%s'", fileName); return; } // tell the server we're sending sendPacket.empty(); sendPacket.uByte2ToBuf(0); sendPacket.strToBuf(asFileName); client.requestOnce("putFile", &sendPacket); printf("Starting send of file %s\n", fileName); char buf[30000]; size_t ret; // now send the file while ((ret = fread(buf, 1, sizeof(buf), file)) == sizeof(buf)) { sendPacket.empty(); sendPacket.uByte2ToBuf(1); sendPacket.strToBuf(asFileName); sendPacket.uByte4ToBuf(ret); sendPacket.dataToBuf(buf, ret); client.requestOnce("putFile", &sendPacket); printf("Sent packet with %d\n", ret); } if (ferror(file)) { ArLog::log(ArLog::Normal, "ArServerFileToClient: Error sending file %s", fileName); sendPacket.empty(); sendPacket.uByte2ToBuf(3); sendPacket.strToBuf(asFileName); client.requestOnce("putFile", &sendPacket); return; } sendPacket.empty(); sendPacket.uByte2ToBuf(1); sendPacket.strToBuf(asFileName); sendPacket.uByte4ToBuf(ret); sendPacket.dataToBuf(buf, ret); client.requestOnce("putFile", &sendPacket); printf("Sent packet with %d\n", ret); sendPacket.empty(); sendPacket.uByte2ToBuf(2); sendPacket.strToBuf(asFileName); client.requestOnce("putFile", &sendPacket); if (feof(file)) { ArLog::log(ArLog::Normal, "ArServerFileToClient: Sent file %s", fileName); } fclose(file); }