//* Random Walk Action test *

#include "../00_nav_library/nav_aria_iface.h" #include <iostream> #include <iomanip> #include <conio.h> using namespace std; int main(){ // NAV_Robot R("gdansk.bradley.edu", 8101); NAV_Robot R("localhost", 8101); // NAV_Robot R("com1"); // NAV_Robot R("com4"); if (!R.is_connected()) { cout << "Cannot connect to the robot or robot simulator, exiting" << endl; return(0); } // add a set of actions that combine together to effect the wander behavior ArActionStallRecover recover; ArActionBumpers bumpers; ArActionAvoidFront avoidFrontNear("Avoid Front Near", 225, 0); ArActionAvoidFront avoidFrontFar; ArActionConstantVelocity constantVelocity("Constant Velocity", 400); R.lock(); R.addAction(&recover, 100); R.addAction(&bumpers, 75); R.addAction(&avoidFrontNear, 50); R.addAction(&avoidFrontFar, 49); R.addAction(&constantVelocity, 25); R.unlock(); #ifdef _DEBUG cerr << showpoint << fixed << setprecision(2); // for inspection purpose only #endif while( R.is_connected()) { // keyboard exit if (_kbhit()) /* <conio.h> */ { char c=tolower(_getch()); if (c=='q') break; } #ifdef _DEBUG cerr <<"RNDW "<<" X="<<setw(6)<< R.getX() <<" Y="<<setw(6)<< R.getY() <<" T="<<setw(6)<< R.getTh() << endl; #endif R.Sleep(100); } R.lock(); R.Stop(); R.unlock(); R.lock(); if (R.is_connected()) R.disconnect(); else cerr << "Lost connection, aborting!" << endl; R.unlock(); return(0); }